Ejemplo n.º 1
0
        public void RemoveStep(CrmPlugin plugin, Guid stepId)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }
            else if (plugin.Steps.ContainsKey(stepId))
            {
                plugin.RemoveStep(stepId);
            }
            else if (m_stepList.ContainsKey(stepId))
            {
                CrmPluginStep step = m_stepList[stepId];

                //Copy the list of images. Can't use the enumerator because we are changing the underlying data
                Guid[] imageIdList = new Guid[step.Images.Count];
                step.Images.Keys.CopyTo(imageIdList, 0);

                //Loop through the image id's
                foreach (Guid imageId in imageIdList)
                {
                    RemoveImage(step, imageId);
                }

                m_stepList.Remove(stepId);
            }
            else
            {
                throw new ArgumentException("Step is not in list", "stepId");
            }
        }
Ejemplo n.º 2
0
        public void ClearPlugins(Guid assemblyId)
        {
            CrmPlugin[] pluginList;
            if (assemblyId == Guid.Empty)
            {
                m_imageList.Clear();
                m_stepList.Clear();

                //Copy the list of plugins. Can't use the enumerator because we are changing the underlying data
                pluginList = new CrmPlugin[m_pluginList.Count];
                m_pluginList.Values.CopyTo(pluginList, 0);
            }
            else if (m_assemblyList.ContainsKey(assemblyId))
            {
                //Copy the list of plugins. Can't use the enumerator because we are changing the underlying data
                pluginList = m_assemblyList[assemblyId].Plugins.ToArray();
            }
            else
            {
                throw new ArgumentException("Invalid Entity Id", "assemblyId");
            }

            //Loop through the plugin id's
            foreach (CrmPlugin plugin in pluginList)
            {
                RemovePlugin(plugin.AssemblyId, plugin.PluginId);
            }
        }
Ejemplo n.º 3
0
        public void RemovePlugin(CrmPluginAssembly assembly, Guid pluginId)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            else if (assembly.Plugins.ContainsKey(pluginId))
            {
                assembly.RemovePlugin(pluginId);
            }
            else if (m_pluginList.ContainsKey(pluginId))
            {
                CrmPlugin plugin = m_pluginList[pluginId];

                //Copy the list of steps. Can't use the enumerator because we are changing the underlying data
                Guid[] stepIdList = new Guid[plugin.Steps.Count];
                plugin.Steps.Keys.CopyTo(stepIdList, 0);

                //Loop through the step id's
                foreach (Guid stepId in stepIdList)
                {
                    RemoveStep(plugin, stepId);
                }

                m_pluginList.Remove(pluginId);
            }
            else
            {
                throw new ArgumentException("Plugin is not in list", "pluginId");
            }
        }
Ejemplo n.º 4
0
        public void AddPlugin(CrmPlugin plugin)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }

            m_pluginList.Add(plugin.PluginId, plugin);

            if (m_org != null)
            {
                Organization.AddPlugin(this, plugin);
            }
        }
Ejemplo n.º 5
0
        public CrmPluginAssembly Clone(bool includeOrganization)
        {
            CrmPluginAssembly newAssembly;

            if (includeOrganization)
            {
                newAssembly = new CrmPluginAssembly(m_org);
            }
            else
            {
                newAssembly = new CrmPluginAssembly(null);
            }

            newAssembly.m_assemblyId       = m_assemblyId;
            newAssembly.m_Name             = m_Name;
            newAssembly.CreatedOn          = CreatedOn;
            newAssembly.Culture            = Culture;
            newAssembly.CustomizationLevel = m_customizationLevel;
            newAssembly.Enabled            = Enabled;
            newAssembly.IsolationMode      = IsolationMode;
            newAssembly.ModifiedOn         = ModifiedOn;
            newAssembly.ServerFileName     = ServerFileName;
            newAssembly.PublicKeyToken     = PublicKeyToken;
            newAssembly.SourceType         = SourceType;
            newAssembly.Version            = Version;

            //Create a new plugin list
            Dictionary <Guid, CrmPlugin> newPluginList = new Dictionary <Guid, CrmPlugin>();

            foreach (CrmPlugin plugin in m_pluginList.Values)
            {
                //Clone the plugin
                CrmPlugin clonedPlugin = (CrmPlugin)plugin.Clone(includeOrganization);

                //Add the plugin to the new list
                newPluginList.Add(clonedPlugin.PluginId, clonedPlugin);
            }

            //Assign the list to the new object
            newAssembly.m_pluginList = newPluginList;

            return(newAssembly);
        }
Ejemplo n.º 6
0
        public void AddPlugin(CrmPlugin plugin)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }

            if (MultipleVersions)
            {
                plugin.AssemblyVersion = Version;
            }

            m_pluginList.Add(plugin.PluginId, plugin);

            if (m_org != null)
            {
                Organization.AddPlugin(this, plugin);
            }
        }
Ejemplo n.º 7
0
        public CrmPlugin Clone(bool includeOrganization)
        {
            CrmPlugin newPlugin;

            if (includeOrganization)
            {
                newPlugin = new CrmPlugin(m_org);
            }
            else
            {
                newPlugin = new CrmPlugin(null);
            }

            newPlugin.m_assemblyName       = m_assemblyName;
            newPlugin.m_createdOn          = m_createdOn;
            newPlugin.m_customizationLevel = m_customizationLevel;
            newPlugin.m_friendlyName       = m_friendlyName;
            newPlugin.m_friendlyNameIgnore = m_friendlyNameIgnore;
            newPlugin.m_isolatable         = m_isolatable;
            newPlugin.m_modifiedOn         = m_modifiedOn;
            newPlugin.m_pluginAssemblyId   = m_pluginAssemblyId;
            newPlugin.m_pluginId           = m_pluginId;
            newPlugin.m_plugType           = m_plugType;
            newPlugin.m_typeName           = m_typeName;

            //Create a new step list
            Dictionary <Guid, CrmPluginStep> newStepList = new Dictionary <Guid, CrmPluginStep>();

            foreach (CrmPluginStep step in m_stepList.Values)
            {
                //Clone the step
                CrmPluginStep clonedStep = step.Clone(includeOrganization);

                //Add the step to the new list
                newStepList.Add(clonedStep.StepId, clonedStep);
            }

            //Assign the list to the new object
            newPlugin.m_stepList = newStepList;

            return(newPlugin);
        }
Ejemplo n.º 8
0
        public void AddPlugin(CrmPluginAssembly assembly, CrmPlugin plugin)
        {
            if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }
            else if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            else if (!assembly.Plugins.ContainsKey(plugin.PluginId))
            {
                assembly.AddPlugin(plugin);
                return;
            }
            else
            {
                ValidateEntity(plugin);
            }

            m_pluginList.Add(plugin.PluginId, plugin);
        }
        public void AddStep(CrmPlugin plugin, CrmPluginStep step)
        {
            if (step == null)
            {
                throw new ArgumentNullException("step");
            }
            else if (plugin == null)
            {
                throw new ArgumentNullException("plugin");
            }
            else if (!plugin.Steps.ContainsKey(step.StepId))
            {
                plugin.AddStep(step);
                return;
            }
            else
            {
                ValidateEntity(step);
            }

            m_stepList.Add(step.StepId, step);
        }
Ejemplo n.º 10
0
 private void ValidateEntity(CrmPlugin plugin)
 {
     if (plugin == null)
     {
         throw new ArgumentNullException();
     }
     else if (m_pluginList.ContainsKey(plugin.PluginId))
     {
         throw new ArgumentException("Plugin is already in the list");
     }
     else if (plugin.Organization != this)
     {
         throw new ArgumentException("Organization must match");
     }
     else if (plugin.AssemblyId == Guid.Empty)
     {
         throw new ArgumentException("AssemblyId must be set to valid Guid");
     }
     else if (plugin.PluginId == Guid.Empty)
     {
         throw new ArgumentException("PluginId must be set to valid Guid");
     }
 }