예제 #1
0
        private static void ParsePersistentState(string content)
        {
            string[] Lines = content.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            foreach (string Line in Lines)
            {
                string[] Splitted = Line.Split('=');
                if (Splitted.Length < 2)
                {
                    continue;
                }

                string Key   = Splitted[0].Trim().ToLower();
                string Value = Splitted[1];
                for (int i = 2; i < Splitted.Length; i++)
                {
                    Value += "=" + Splitted[i];
                }
                Value = Value.Trim();

                StateTable.Add(Key, Value);

                if (DebugTrace)
                {
                    Debug.WriteLine($"{Key}={Value}");
                }
            }
        }
예제 #2
0
        public static void SetValue(string key, string value)
        {
            if (StateTable == null)
            {
                LoadPersistentState();
            }

            if (StateTable.ContainsKey(key))
            {
                if (DebugTrace)
                {
                    Debug.WriteLine($"SetValue(\"{key}\") -> {value}");
                }

                StateTable[key] = value;
            }
            else
            {
                if (DebugTrace)
                {
                    Debug.WriteLine($"[{key}, {value}] added");
                }

                StateTable.Add(key, value);
            }

            Commit();
        }