Exemplo n.º 1
0
        private void SaveToFile(AnimationSettingsValue <T> update)
        {
            var lines   = GetFileLines();
            var values  = GetValues(lines);
            var updated = false;

            foreach (var value in values)
            {
                if (value.Type == update.Type && value.Matcher == update.Matcher)
                {
                    lines[value.LineIndex.Value] = update.ToString();
                    updated = true;
                    break;
                }
            }
            lock (_locker)
            {
                if (updated)
                {
                    File.WriteAllLines(FilePath, lines);
                }
                else if (update.Value != null)
                {
                    File.AppendAllText(FilePath, Environment.NewLine + update.ToString());
                }
            }
        }
Exemplo n.º 2
0
        public void Delete(string path, string name)
        {
            var delete = new AnimationSettingsValue <T>(path, name, null);

            if (delete.Type == MatcherType.Key)
            {
                KeyFlags.Remove(delete.Matcher);
            }

            if (delete.Type == MatcherType.Path)
            {
                PathFlags.Remove(delete.Matcher);
            }

            SaveToFile(delete);
        }
Exemplo n.º 3
0
        public void Save(string path, string name, T settings)
        {
            var update = new AnimationSettingsValue <T>(path, name, settings);

            if (update.Type == MatcherType.Key)
            {
                KeyFlags[update.Matcher] = update.Value;
            }

            if (update.Type == MatcherType.Path)
            {
                PathFlags[update.Matcher] = update.Value;
            }

            SaveToFile(update);
        }
Exemplo n.º 4
0
        private List <AnimationSettingsValue <T> > GetValues(string[] lines)
        {
            var values = new List <AnimationSettingsValue <T> >();

            for (var i = 0; i < lines.Length; i++)
            {
                var value = AnimationSettingsValue <T> .Parse(lines[i]);

                if (value != null)
                {
                    value.LineIndex = i;
                    values.Add(value);
                }
            }

            return(values);
        }