_04_GuessTheNumberTurnTheTables.FileSystemDatabase.GetFreshId C# (CSharp) Method

GetFreshId() public method

public GetFreshId ( ) : int
return int
        public int GetFreshId()
        {
            lock (this.GetType ()) {
                var fileName = Path.Combine (this.directory, "LastKey");
                int newKey;
                if (!File.Exists (fileName)) {
                    newKey = 1;
                } else {
                    var str = File.ReadAllText (fileName);
                    newKey = int.Parse (str) + 1;
                }
                File.WriteAllText (fileName, newKey.ToString ());
                return newKey;
            }
        }

Usage Example

示例#1
0
文件: Main.cs 项目: fsoikin/Shovel
        static Session FreshSession(FileSystemDatabase fsd, Shovel.Instruction[] bytecode, string program)
        {
            var session = new Session();

            session.Id = fsd.GetFreshId();
            session.ShovelVmSources  = program;
            session.ShovelVmBytecode = Shovel.Api.SerializeBytecode(bytecode);
            return(session);
        }
All Usage Examples Of _04_GuessTheNumberTurnTheTables.FileSystemDatabase::GetFreshId