コード例 #1
0
        public void AddAssembly(CrmPluginAssembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            else if (m_assemblyList.ContainsKey(assembly.AssemblyId))
            {
                throw new ArgumentException("Assembly is already in the list");
            }
            else
            {
                ValidateEntity(assembly);
            }

            m_assemblyList.Add(assembly.AssemblyId, assembly);
            var assemblies = m_assemblyList.Values.Where(a => a.Name == assembly.Name);

            if (assemblies.Any(a => a.AssemblyId != assembly.AssemblyId)) //multiple versions
            {
                foreach (var c_Assembly in assemblies)
                {
                    if (c_Assembly.MultipleVersions)
                    {
                        continue;
                    }
                    c_Assembly.MultipleVersions = true;
                    foreach (var plugin in c_Assembly.Plugins.Values)
                    {
                        plugin.AssemblyVersion = c_Assembly.Version;
                    }
                }
            }
        }
コード例 #2
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");
            }
        }
コード例 #3
0
        public void AddAssembly(CrmPluginAssembly assembly)
        {
            if (assembly == null)
            {
                throw new ArgumentNullException("assembly");
            }
            else if (m_assemblyList.ContainsKey(assembly.AssemblyId))
            {
                throw new ArgumentException("Assembly is already in the list");
            }
            else
            {
                ValidateEntity(assembly);
            }

            m_assemblyList.Add(assembly.AssemblyId, assembly);
        }
コード例 #4
0
 private void ValidateEntity(CrmPluginAssembly assembly)
 {
     if (assembly == null)
     {
         throw new ArgumentNullException();
     }
     else if (m_assemblyList.ContainsKey(assembly.AssemblyId))
     {
         throw new ArgumentException("Assembly is already in the list");
     }
     else if (assembly.Organization != this)
     {
         throw new ArgumentException("Organization must match");
     }
     else if (assembly.AssemblyId == Guid.Empty)
     {
         throw new ArgumentException("AssemblyId must be set to valid Guid");
     }
 }
コード例 #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);
        }
コード例 #6
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);
        }
コード例 #7
0
        public void RemoveAssembly(Guid assemblyId)
        {
            if (m_assemblyList.ContainsKey(assemblyId))
            {
                CrmPluginAssembly assembly = m_assemblyList[assemblyId];

                //Copy the list of plugins. Can't use the enumerator because we are changing the underlying data
                Guid[] pluginIdList = new Guid[assembly.Plugins.Count];
                assembly.Plugins.Keys.CopyTo(pluginIdList, 0);

                //Loop through the plugin id's
                foreach (Guid pluginId in pluginIdList)
                {
                    RemovePlugin(assembly, pluginId);
                }

                m_assemblyList.Remove(assemblyId);
            }
            else
            {
                throw new ArgumentException("Invalid Assembly Id", "assemblyId");
            }
        }