public void Load(string filename = FILENAME)
        {
            SettingsRoot root = null;

            if (!File.Exists(filename))
            {
                return;
            }

            try
            {
                string xml = File.ReadAllText(filename);
                root = Serializer.XmlToObject <SettingsRoot>(xml);

                foreach (var item in root.Children)
                {
                    IoCContainer.Update(item);
                }
            }
            catch (Exception ex)
            {
                Trace.TraceError(ex.GetMessages());
                string errorFilename = filename + ".error";
                if (File.Exists(errorFilename))
                {
                    File.Delete(errorFilename);
                }
                File.Move(filename, errorFilename);
            }
        }
        private SettingsRoot CreateSettingsRoot(IEnumerable <ISettings> collection)
        {
            var result = new SettingsRoot();

            result.Children.AddRange(collection);

            return(result);
        }
Ejemplo n.º 3
0
        private SettingsRoot CreateSettingsRoot(IEnumerable<ISettings> collection)
        {
            var result = new SettingsRoot();

            result.Children.AddRange(collection);

            return result;
        }
Ejemplo n.º 4
0
        public static SettingsRoot Load(string filename)
        {
            SettingsRoot result = null;

            if (File.Exists(filename))
            {
                try
                {
                    string xml = File.ReadAllText(filename);
                    result = Serializer.XmlToObject <SettingsRoot>(xml);
                }
                catch (Exception ex)
                {
                    Trace.TraceError(ex.GetMessages());
                    string errorFilename = filename + ".error";
                    if (File.Exists(errorFilename))
                    {
                        File.Delete(errorFilename);
                    }
                    File.Move(filename, errorFilename);
                }
            }
            return(result);
        }