Beispiel #1
0
        void UpdatePackageAgent(
            PackageAgent newAgent,
            PackageAgent existingAgent,
            AddItem existingDisabledAgentItem,
            bool updateEnabled,
            bool shouldSkipSave,
            ref bool isDirty)
        {
            if (string.Equals(newAgent.Name, existingAgent.Name, StringComparison.OrdinalIgnoreCase))
            {
                if ((!string.Equals(newAgent.Agent, existingAgent.Agent, StringComparison.OrdinalIgnoreCase) ||
                     newAgent.ProtocolVersion != existingAgent.ProtocolVersion) && newAgent.IsPersistable)
                {
                    Settings.AddOrUpdate(ConfigurationConstants2.PackageAgents, newAgent.AsAgentItem());
                    isDirty = true;
                }

                if (updateEnabled)
                {
                    if (newAgent.IsEnabled && existingDisabledAgentItem != null)
                    {
                        Settings.Remove(ConfigurationConstants2.DisabledPackageAgents, existingDisabledAgentItem);
                        isDirty = true;
                    }

                    if (!newAgent.IsEnabled && existingDisabledAgentItem == null)
                    {
                        AddDisabledAgent(newAgent.Name, shouldSkipSave: true, isDirty: ref isDirty);
                    }
                }

                if (!shouldSkipSave && isDirty)
                {
                    Settings.SaveToDisk();
                    OnPackageAgentsChanged();
                    isDirty = false;
                }
            }
        }
Beispiel #2
0
        void AddPackageAgent(PackageAgent agent, bool shouldSkipSave, ref bool isDirty)
        {
            if (agent.IsPersistable)
            {
                Settings.AddOrUpdate(ConfigurationConstants2.PackageAgents, agent.AsAgentItem());
                isDirty = true;
            }

            if (agent.IsEnabled)
            {
                RemoveDisabledAgent(agent.Name, shouldSkipSave: true, isDirty: ref isDirty);
            }
            else
            {
                AddDisabledAgent(agent.Name, shouldSkipSave: true, isDirty: ref isDirty);
            }

            if (!shouldSkipSave && isDirty)
            {
                Settings.SaveToDisk();
                OnPackageAgentsChanged();
                isDirty = false;
            }
        }