Artemis.Engine.Persistence.OptionRecordService.Read C# (CSharp) Метод

Read() публичный Метод

public Read ( string fileName ) : void
fileName string
Результат void
        public void Read(string fileName)
        {
            var doc = new XmlDocument();

            try
            {
                doc.Load(fileName);
            }
            catch (IOException)
            {
                // If the file does not exist, then simply initialize to all
                // the default values.
                InitializeDefaults(new List<string>());
                return;
            }

            var root = doc.ChildNodes[1] as XmlElement;
            List<string> seen = new List<string>();
            foreach (var child in root.ChildNodes)
            {
                var element = child as XmlElement;
                if (element == null)
                    continue;
                var name = element.Name;

                // If we don't have a record for this option, just ignore it.
                if (!OptionRecords.ContainsKey(name))
                    continue;

                var record = OptionRecords[name];
                var obj = record.GetValueOrDefault(element);
                Set(name, obj);

                seen.Add(name);
            }

            InitializeDefaults(seen);
        }

Usage Example

Пример #1
0
 // Should this really be public?
 public static void Read()
 {
     optionRecordService.Read(OptionFileName);
 }