Exemplo n.º 1
0
        /// <summary>
        ///  Set the values for a handler
        /// </summary>
        private void SetHandlerValues(XElement node, HandlerSettings handler, uSyncSettings defaultSettings)
        {
            node.SetAttributeValue("Alias", handler.Alias);
            node.SetAttributeValue("Enabled", handler.Enabled);

            if (handler.GuidNames.IsOverridden)
            {
                node.SetAttributeValue("GuidNames", handler.GuidNames.Value);
            }

            if (handler.UseFlatStructure.IsOverridden)
            {
                node.SetAttributeValue("UseFlatStructure", handler.UseFlatStructure.Value);
            }

            if (handler.FailOnMissingParent.IsOverridden)
            {
                node.SetAttributeValue("FailOnMissingParent", handler.FailOnMissingParent.Value);
            }

            node.SetAttributeValue("Actions", string.Join(",", handler.Actions));

            if (handler.Settings != null && handler.Settings.Count > 0)
            {
                foreach (var setting in handler.Settings)
                {
                    var s = node.FindOrCreate("Add", "Key", setting.Key);
                    s.SetAttributeValue("Value", setting.Value);
                }

                node.RemoveMissingElements("Add", "Key", handler.Settings.Keys.ToList());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        ///  load hte config for a single handler.
        /// </summary>
        public HandlerSettings LoadHandlerConfig(XElement node, uSyncSettings defaultSettings)
        {
            if (node == null)
            {
                return(null);
            }
            var alias = node.Attribute("Alias").ValueOrDefault(string.Empty);

            if (string.IsNullOrEmpty(alias))
            {
                return(null);
            }

            var enabled = node.Attribute("Enabled").ValueOrDefault(true);

            var settings = new HandlerSettings(alias, enabled);

            // these values can be set locally, but if they aren't
            // we get them from the global setting.
            settings.GuidNames           = GetLocalValue(node.Attribute("GuidNames"), defaultSettings.UseGuidNames);
            settings.UseFlatStructure    = GetLocalValue(node.Attribute("UseFlatStructure"), defaultSettings.UseFlatStructure);
            settings.Actions             = node.Attribute("Actions").ValueOrDefault("All").ToDelimitedList().ToArray();
            settings.FailOnMissingParent = GetLocalValue(node.Attribute("FailOnMissingParent"), defaultSettings.FailOnMissingParent);
            settings.Group = node.Attribute("Group").ValueOrDefault(string.Empty);

            // handlers can have their own individual settings beneath a node
            //
            // <Handler Alias="simple" ... >
            //  <Add Key="settingName" Value="settingValue" />
            // </Handler>
            //
            // These get added to a Settings dictionary for the handler, so it
            // can access them as needed (v8.7+ also passed to serializers)
            //


            var perHandlerSettings = new Dictionary <string, string>();

            // merge in the defaults
            if (defaultSettings.DefaultHandlerSettings != null)
            {
                defaultSettings.DefaultHandlerSettings.ToList()
                .ForEach(x => perHandlerSettings[x.Key] = x.Value);
            }

            // merge in the handler.
            var handlerSettings = LoadKeyValueSettings(node);

            if (handlerSettings != null)
            {
                handlerSettings.ToList()
                .ForEach(x => perHandlerSettings[x.Key] = x.Value);
            }

            settings.Settings = perHandlerSettings;

            return(settings);
        }
Exemplo n.º 3
0
        /// <summary>
        ///  Save the settings to disk.
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="fireReload"></param>
        /// <returns></returns>
        public uSyncSettings SaveSettings(uSyncSettings settings, bool fireReload = false)
        {
            var node = GetSettingsFile(true);

            node.CreateOrSetElement("Folder", settings.SettingsFolder);
            node.CreateOrSetElement("FlatFolders", settings.UseFlatStructure);
            node.CreateOrSetElement("ImportAtStartup", settings.ImportAtStartup);
            node.CreateOrSetElement("ExportAtStartup", settings.ExportAtStartup);
            node.CreateOrSetElement("ExportOnSave", settings.ExportOnSave);
            node.CreateOrSetElement("UseGuidFilenames", settings.UseGuidNames);
            node.CreateOrSetElement("ReportDebug", settings.ReportDebug);
            node.CreateOrSetElement("RebuildCacheOnCompletion", settings.RebuildCacheOnCompletion);
            node.CreateOrSetElement("FailOnMissingParent", settings.FailOnMissingParent);
            node.CreateOrSetElement("ShowVersionCheckWarning", settings.ShowVersionCheckWarning);
            node.CreateOrSetElement("EnableHistory", settings.EnableHistory);

            if (settings.HandlerSets.Count > 0)
            {
                // remove the existing handlerSets node?
                var handlerSets = node.FindOrCreate("HandlerSets");
                handlerSets.SetAttributeValue("Default", settings.DefaultSet);

                foreach (var set in settings.HandlerSets)
                {
                    // find the handler node for this set.
                    var setNode = handlerSets.FindOrCreate("Handlers", "Name", set.Name);

                    foreach (var handler in set.Handlers)
                    {
                        var handlerNode = setNode.FindOrCreate("Handler", "Alias", handler.Alias);
                        SetHandlerValues(handlerNode, handler, settings);
                    }

                    // remove and missing handlers (so on disk but not in settings)
                    setNode.RemoveMissingElements("Handler", "Alias", set.Handlers.Select(x => x.Alias));
                }

                // remove missing HandlerSets (on disk not in settings)
                handlerSets.RemoveMissingElements("Handlers", "Name", settings.HandlerSets.Select(x => x.Name));

                var legacyNode = node.Element("Handlers");
                if (legacyNode != null)
                {
                    legacyNode.Remove();
                }
            }

            SaveSettingsFile(node);

            if (fireReload)
            {
                this.Settings = LoadSettings();
            }

            return(settings);
        }
        public void SaveHandlerConfig(XElement node, HandlerSettings config, uSyncSettings globalSettings)
        {
            if (node == null)
            {
                return;
            }

            node.SetAttributeValue("Alias", config.Alias);
            node.SetAttributeValue("Enabled", config.Enabled);

            if (config.GuidNames.IsOverridden)
            {
                node.SetAttributeValue("GuidNames", config.GuidNames);
            }

            if (config.UseFlatStructure.IsOverridden)
            {
                node.SetAttributeValue("UseFlatStructure", config.UseFlatStructure);
            }

            if (config.BatchSave.IsOverridden)
            {
                node.SetAttributeValue("BatchSave", config.BatchSave);
            }

            if (config.FailOnMissingParent.IsOverridden)
            {
                node.SetAttributeValue("FailOnMissingParent", config.FailOnMissingParent);
            }

            if (config.Actions.Length > 0 && !(config.Actions.Length == 1 && config.Actions[0].InvariantEquals("all")))
            {
                node.SetAttributeValue("Actions", string.Join(",", config.Actions));
            }

            if (config.Settings != null && config.Settings.Any())
            {
                var settingNode = new XElement("Settings");

                foreach (var setting in config.Settings)
                {
                    settingNode.Add(new XElement("Add",
                                                 new XAttribute("Key", setting.Key),
                                                 new XAttribute("Value", setting.Value)));
                }

                var existing = node.Element("Settings");
                if (existing != null)
                {
                    existing.Remove();
                }

                node.Add(settingNode);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        ///  Load the usync settings from disk.
        /// </summary>
        public uSyncSettings LoadSettings()
        {
            uSyncSettings settings = new uSyncSettings();

            var node = GetSettingsFile();

            if (node == null)
            {
                logger.Warn <uSyncConfig>($"Failed to load the {uSyncBackOfficeConstants.ConfigFile} file from disk, working with defaults.");
                return(SaveSettings(settings));
            }

            settings.RootFolder               = ValueFromWebConfigOrDefault("Folder", node.Element("Folder").ValueOrDefault(settings.RootFolder));
            settings.UseFlatStructure         = ValueFromWebConfigOrDefault("FlatFolders", node.Element("FlatFolders").ValueOrDefault(true));
            settings.ImportAtStartup          = ValueFromWebConfigOrDefault("ImportAtStartup", node.Element("ImportAtStartup").ValueOrDefault(true));
            settings.ExportAtStartup          = ValueFromWebConfigOrDefault("ExportAtStartup", node.Element("ExportAtStartup").ValueOrDefault(false));
            settings.ExportOnSave             = ValueFromWebConfigOrDefault("ExportOnSave", node.Element("ExportOnSave").ValueOrDefault(true));
            settings.UseGuidNames             = ValueFromWebConfigOrDefault("UseGuidFilenames", node.Element("UseGuidFilenames").ValueOrDefault(false));
            settings.ReportDebug              = node.Element("ReportDebug").ValueOrDefault(false);
            settings.AddOnPing                = node.Element("AddOnPing").ValueOrDefault(true);
            settings.RebuildCacheOnCompletion = node.Element("RebuildCacheOnCompletion").ValueOrDefault(false);
            settings.FailOnMissingParent      = node.Element("FailOnMissingParent").ValueOrDefault(true);

            settings.CacheFolderKeys = node.Element("CacheFolderKeys").ValueOrDefault(true);

            // load the handlers
            var handlerSets = node.Element("HandlerSets");

            if (handlerSets != null)
            {
                settings.HandlerSets = LoadHandlerSets(handlerSets, settings, out string defaultSet);
                settings.DefaultSet  = defaultSet;
            }
            else
            {
                var handlers = node.Element("Handlers");
                if (handlers != null)
                {
                    // old config, load as default :(
                    settings.HandlerSets = new List <HandlerSet>();
                    var defaultSet = LoadSingleHandlerSet(handlers, settings);
                    settings.HandlerSets.Add(defaultSet);
                }
            }

            settings.CustomMappings = LoadAppKeysFromNode(node, "Mappings", true);

            // fire the loaded event, so things can tell when they are loaded.
            Reloaded?.Invoke(settings);

            return(settings);
        }
Exemplo n.º 6
0
        /// <summary>
        ///  load hte config for a single handler.
        /// </summary>
        public HandlerSettings LoadHandlerConfig(XElement node, uSyncSettings defaultSettings)
        {
            if (node == null)
            {
                return(null);
            }
            var alias = node.Attribute("Alias").ValueOrDefault(string.Empty);

            if (string.IsNullOrEmpty(alias))
            {
                return(null);
            }

            var enabled = node.Attribute("Enabled").ValueOrDefault(true);

            var settings = new HandlerSettings(alias, enabled);

            // these values can be set locally, but if they aren't
            // we get them from the global setting.
            settings.GuidNames           = GetLocalValue(node.Attribute("GuidNames"), defaultSettings.UseGuidNames);
            settings.UseFlatStructure    = GetLocalValue(node.Attribute("UseFlatStructure"), defaultSettings.UseFlatStructure);
            settings.Actions             = node.Attribute("Actions").ValueOrDefault("All").ToDelimitedList().ToArray();
            settings.FailOnMissingParent = GetLocalValue(node.Attribute("FailOnMissingParent"), defaultSettings.FailOnMissingParent);

            // handlers can have their own individual settings beneath a node
            //
            // <Handler Alias="simple" ... >
            //  <Add Key="settingName" Value="settingValue" />
            // </Handler>
            //
            // These get added to a Settings dictionary for the handler, so it
            // can access them as needed (v8.7+ also passed to serializers)
            //

            var perHandlerSettings = new Dictionary <string, string>();

            foreach (var settingItem in node.Elements("Add"))
            {
                var key   = settingItem.Attribute("Key").ValueOrDefault(string.Empty);
                var value = settingItem.Attribute("Value").ValueOrDefault(string.Empty);

                if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(value))
                {
                    continue;
                }
                perHandlerSettings.Add(key, value);
            }

            settings.Settings = perHandlerSettings;

            return(settings);
        }
        public uSyncSettings LoadSettings()
        {
            uSyncSettings settings = new uSyncSettings();

            var node = GetSettingsFile();

            if (node == null)
            {
                return(SaveSettings(settings));
            }

            settings.RootFolder               = ValueFromWebConfigOrDefault("Folder", node.Element("Folder").ValueOrDefault(settings.RootFolder));
            settings.UseFlatStructure         = ValueFromWebConfigOrDefault("FlatFolders", node.Element("FlatFolders").ValueOrDefault(true));
            settings.ImportAtStartup          = ValueFromWebConfigOrDefault("ImportAtStartup", node.Element("ImportAtStartup").ValueOrDefault(true));
            settings.ExportAtStartup          = ValueFromWebConfigOrDefault("ExportAtStartup", node.Element("ExportAtStartup").ValueOrDefault(false));
            settings.ExportOnSave             = ValueFromWebConfigOrDefault("ExportOnSave", node.Element("ExportOnSave").ValueOrDefault(true));
            settings.UseGuidNames             = ValueFromWebConfigOrDefault("UseGuidFilenames", node.Element("UseGuidFilenames").ValueOrDefault(false));
            settings.BatchSave                = node.Element("BatchSave").ValueOrDefault(false);
            settings.ReportDebug              = node.Element("ReportDebug").ValueOrDefault(false);
            settings.AddOnPing                = node.Element("AddOnPing").ValueOrDefault(true);
            settings.RebuildCacheOnCompletion = node.Element("RebuildCacheOnCompletion").ValueOrDefault(false);
            settings.FailOnMissingParent      = node.Element("FailOnMissingParent").ValueOrDefault(true);

            // load the handlers
            var handlerSets = node.Element("HandlerSets");

            if (handlerSets != null)
            {
                settings.HandlerSets = LoadHandlerSets(handlerSets, settings, out string defaultSet);
                settings.DefaultSet  = defaultSet;
            }
            else
            {
                var handlers = node.Element("Handlers");
                if (handlers != null)
                {
                    // old config, load as default :(
                    settings.HandlerSets = new List <HandlerSet>();
                    var defaultSet = LoadSingleHandlerSet(handlers, settings);
                    settings.HandlerSets.Add(defaultSet);
                }
            }

            // fire the loaded event, so things can tell when they are loaded.
            Reloaded?.Invoke(settings);

            return(settings);
        }
        public HandlerSettings LoadHandlerConfig(XElement node, uSyncSettings defaultSettings)
        {
            if (node == null)
            {
                return(null);
            }
            var alias = node.Attribute("Alias").ValueOrDefault(string.Empty);

            if (string.IsNullOrEmpty(alias))
            {
                return(null);
            }

            var enabled = node.Attribute("Enabled").ValueOrDefault(true);

            var settings = new HandlerSettings(alias, enabled);

            // these values can be set locally, but if they aren't
            // we get them from the global setting.
            settings.GuidNames           = GetLocalValue(node.Attribute("GuidNames"), defaultSettings.UseGuidNames);
            settings.UseFlatStructure    = GetLocalValue(node.Attribute("UseFlatStructure"), defaultSettings.UseFlatStructure);
            settings.BatchSave           = GetLocalValue(node.Attribute("BatchSave"), defaultSettings.BatchSave);
            settings.Actions             = node.Attribute("Actions").ValueOrDefault("All").ToDelimitedList().ToArray();
            settings.FailOnMissingParent = GetLocalValue(node.Attribute("FailOnMissingParent"), defaultSettings.FailOnMissingParent);

            // var settingNode = node.Element("Settings");
            // if (settingNode != null)
            // {
            var perHandlerSettings = new Dictionary <string, string>();

            foreach (var settingItem in node.Elements("Add"))
            {
                var key   = settingItem.Attribute("Key").ValueOrDefault(string.Empty);
                var value = settingItem.Attribute("Value").ValueOrDefault(string.Empty);

                if (string.IsNullOrWhiteSpace(key) || string.IsNullOrWhiteSpace(value))
                {
                    continue;
                }

                perHandlerSettings.Add(key, value);
            }

            settings.Settings = perHandlerSettings;
            // }

            return(settings);
        }
Exemplo n.º 9
0
        /// <summary>
        ///  Load the handler sets from the 'Handlers' section of the file
        /// </summary>
        private IList <HandlerSet> LoadHandlerSets(XElement node, uSyncSettings defaultSettings, out string defaultSet)
        {
            var sets = new List <HandlerSet>();

            defaultSet = ValueFromWebConfigOrDefault("DefaultHandlerSet", node.Attribute("Default").ValueOrDefault("default"));

            logger.Debug <uSyncConfig>("Handlers : Default Set {defaultSet}", defaultSet);

            foreach (var setNode in node.Elements("Handlers"))
            {
                var handlerSet = LoadSingleHandlerSet(setNode, defaultSettings);
                if (handlerSet.Handlers.Count > 0)
                {
                    sets.Add(handlerSet);
                }
            }

            return(sets);
        }
Exemplo n.º 10
0
        /// <summary>
        ///  Load the handler set (a collection of handlers)
        /// </summary>
        /// <remarks>
        ///  each handler set has a name, it lets us have diffrent sets for diffrent tasks
        /// </remarks>
        private HandlerSet LoadSingleHandlerSet(XElement setNode, uSyncSettings defaultSettings)
        {
            var handlerSet = new HandlerSet();

            handlerSet.Name = setNode.Attribute("Name").ValueOrDefault("default");

            foreach (var handlerNode in setNode.Elements("Handler"))
            {
                var handlerSettings = LoadHandlerConfig(handlerNode, defaultSettings);
                if (handlerSettings != null)
                {
                    logger.Debug <uSyncConfig>("Loading Handler {alias} {enabled} [{actions}]",
                                               handlerSettings.Alias, handlerSettings.Enabled, string.Join(",", handlerSettings.Actions));

                    handlerSet.Handlers.Add(handlerSettings);
                }
            }

            return(handlerSet);
        }
Exemplo n.º 11
0
        public uSyncSettings LoadSettings()
        {
            uSyncSettings settings = new uSyncSettings();

            var node = GetSettingsFile();

            if (node == null)
            {
                return(SaveSettings(settings));
            }

            settings.RootFolder       = node.Element("Folder").ValueOrDefault(settings.RootFolder);
            settings.UseFlatStructure = node.Element("FlatFolders").ValueOrDefault(true);
            settings.ImportAtStartup  = node.Element("ImportAtStartup").ValueOrDefault(true);
            settings.ExportAtStartup  = node.Element("ExportAtStartup").ValueOrDefault(false);
            settings.ExportOnSave     = node.Element("ExportOnSave").ValueOrDefault(true);
            settings.UseGuidNames     = node.Element("UseGuidFilenames").ValueOrDefault(false);
            settings.BatchSave        = node.Element("BatchSave").ValueOrDefault(false);
            settings.ReportDebug      = node.Element("ReportDebug").ValueOrDefault(false);
            settings.AddOnPing        = node.Element("AddOnPing").ValueOrDefault(true);

            var handlerConfig = node.Element("Handlers");

            if (handlerConfig != null && handlerConfig.HasElements)
            {
                settings.EnableMissingHandlers = handlerConfig.Attribute("EnableMissing").ValueOrDefault(true);

                foreach (var handlerNode in handlerConfig.Elements("Handler"))
                {
                    var handlerSetting = LoadHandlerConfig(handlerNode, settings);

                    if (handlerSetting != null)
                    {
                        settings.Handlers.Add(handlerSetting);
                    }
                }
            }

            return(settings);
        }
Exemplo n.º 12
0
        /// <summary>
        ///  Load the usync settings from disk.
        /// </summary>
        public uSyncSettings LoadSettings()
        {
            uSyncSettings settings = new uSyncSettings();

            var node = GetSettingsFile();

            if (node == null)
            {
                logger.Warn <uSyncConfig>($"Failed to load the {uSyncBackOfficeConstants.ConfigFile} file from disk, working with defaults.");
                return(SaveSettings(settings));
            }

            settings.SettingsFolder = ValueFromWebConfigOrDefault("Folder", node.Element("Folder").ValueOrDefault(settings.RootFolder));
            var allowUnsafeFolder = ValueFromWebConfigOrDefault("AllowUnsafeFolder", node.Element("Folder").Attribute("AllowUnsafe").ValueOrDefault(false));

            settings.RootFolder = GetPhysicalFolder(settings.SettingsFolder, allowUnsafeFolder);

            settings.UseFlatStructure = ValueFromWebConfigOrDefault("FlatFolders", node.Element("FlatFolders").ValueOrDefault(true));
            settings.ImportAtStartup  = ValueFromWebConfigOrDefault("ImportAtStartup", node.Element("ImportAtStartup").ValueOrDefault(true));

            // new add a group to use on import at startup (so say only import settings)
            var startupGroup      = string.Empty;
            var importStartupNode = node.Element("ImportAtStartup");

            if (importStartupNode != null)
            {
                startupGroup = importStartupNode.Attribute("Group").ValueOrDefault(startupGroup);
            }
            settings.ImportAtStartupGroup = ValueFromWebConfigOrDefault("ImportAtStartup.Group", startupGroup);


            settings.ExportAtStartup          = ValueFromWebConfigOrDefault("ExportAtStartup", node.Element("ExportAtStartup").ValueOrDefault(false));
            settings.ExportOnSave             = ValueFromWebConfigOrDefault("ExportOnSave", node.Element("ExportOnSave").ValueOrDefault(true));
            settings.UseGuidNames             = ValueFromWebConfigOrDefault("UseGuidFilenames", node.Element("UseGuidFilenames").ValueOrDefault(false));
            settings.ReportDebug              = node.Element("ReportDebug").ValueOrDefault(false);
            settings.AddOnPing                = node.Element("AddOnPing").ValueOrDefault(true);
            settings.RebuildCacheOnCompletion = node.Element("RebuildCacheOnCompletion").ValueOrDefault(false);
            settings.FailOnMissingParent      = node.Element("FailOnMissingParent").ValueOrDefault(true);
            settings.ShowVersionCheckWarning  = node.Element("ShowVersionCheckWarning").ValueOrDefault(true);

            settings.CacheFolderKeys = node.Element("CacheFolderKeys").ValueOrDefault(true);
            settings.EnableHistory   = node.Element("EnableHistory").ValueOrDefault(true);

            settings.SignalRRoot = ValueFromWebConfigOrDefault("SignalRRoot", node.Element("SignalRRoot")
                                                               .ValueOrDefault("backoffice/signalr/hubs"))
                                   .TrimStart(new[] { '/' });


            settings.DefaultHandlerSettings = LoadKeyValueSettings(node.Element("HandlerDefaults"));

            // load the handlers
            var handlerSets = node.Element("HandlerSets");

            if (handlerSets != null)
            {
                settings.HandlerSets = LoadHandlerSets(handlerSets, settings, out string defaultSet);
                settings.DefaultSet  = defaultSet;
            }
            else
            {
                var handlers = node.Element("Handlers");
                if (handlers != null)
                {
                    // old config, load as default :(
                    settings.HandlerSets = new List <HandlerSet>();
                    var defaultSet = LoadSingleHandlerSet(handlers, settings);
                    settings.HandlerSets.Add(defaultSet);
                }
            }

            settings.CustomMappings = LoadAppKeysFromNode(node, "Mappings", true);


            // fire the loaded event, so things can tell when they are loaded.
            Reloaded?.Invoke(settings);

            return(settings);
        }
Exemplo n.º 13
0
 public uSyncConfig(IProfilingLogger logger)
 {
     this.logger   = logger;
     this.Settings = LoadSettings();
 }
Exemplo n.º 14
0
        public uSyncSettings SaveSettings(uSyncSettings settings, bool fireReload = false)
        {
            var node = GetSettingsFile(true);

            node.CreateOrSetElement("Folder", settings.RootFolder);
            node.CreateOrSetElement("FlatFolders", settings.UseFlatStructure);
            node.CreateOrSetElement("ImportAtStartup", settings.ImportAtStartup);
            node.CreateOrSetElement("ExportAtStartup", settings.ExportAtStartup);
            node.CreateOrSetElement("ExportOnSave", settings.ExportOnSave);
            node.CreateOrSetElement("UseGuidFilenames", settings.UseGuidNames);
            node.CreateOrSetElement("BatchSave", settings.BatchSave);
            node.CreateOrSetElement("ReportDebug", settings.ReportDebug);

            if (settings.Handlers != null && settings.Handlers.Any())
            {
                var handlerConfig = node.Element("Handlers");
                if (handlerConfig == null)
                {
                    handlerConfig = new XElement("Handlers",
                                                 new XAttribute("EnableMissing", true));
                    node.Add(handlerConfig);
                }


                foreach (var handler in settings.Handlers)
                {
                    if (!handler.GuidNames.IsOverridden)
                    {
                        handler.GuidNames.SetDefaultValue(settings.UseGuidNames);
                    }

                    if (!handler.UseFlatStructure.IsOverridden)
                    {
                        handler.UseFlatStructure.SetDefaultValue(settings.UseFlatStructure);
                    }

                    if (!handler.BatchSave.IsOverridden)
                    {
                        handler.BatchSave.SetDefaultValue(settings.BatchSave);
                    }

                    var handlerNode = handlerConfig.Elements("Handler").FirstOrDefault(x => x.Attribute("Alias").Value == handler.Alias);
                    if (handlerNode == null)
                    {
                        handlerNode = new XElement("Handler");
                        handlerConfig.Add(handlerNode);
                    }

                    SaveHandlerConfig(handlerNode, handler, settings);
                }
            }
            else
            {
                // if the handlers is null, we should write out the handlers we have loaded,
                // so that there is something in the config
            }
            SaveSettingsFile(node);

            if (fireReload)
            {
                this.Settings = LoadSettings();
                Reloaded?.Invoke(settings);
            }

            return(settings);
        }
Exemplo n.º 15
0
 public uSyncConfig()
 {
     this.Settings = LoadSettings();
 }