/// <summary> /// Method to populate the Plugins according to the Registration Object. /// </summary> /// <param name="registration">The Registration Object indicating which Plugins to retrieve.</param> /// <param name="xrmPluginAssembly">The Assembly object to populate.</param> /// <param name="assembly">The Assembly from whence to extract Assembly Details.</param> /// <param name="defaultGroupName">The Default Group Name String Property.</param> internal XrmPluginAssembly GetRegistrationPlugins(string xrmServerDetails, Registration registration, XrmPluginAssembly xrmPluginAssembly, Assembly assembly, string defaultGroupName) { try { foreach (Type type in assembly.GetExportedTypes()) { if (type.IsAbstract || !type.IsClass) { continue; } foreach (Plugin plugin in registration.Plugins) { if (type.FullName == plugin.PluginName) { XrmPluginType xrmPluginType = XrmPluginType.Plugin; XrmPluginIsolatable xrmPluginIsolatable = XrmPluginIsolatable.Unknown; string workflowGroupName = defaultGroupName; string pluginName = type.FullName; Version sdkVersion = GetSdkVersion(type, ref xrmPluginType, ref xrmPluginIsolatable, ref workflowGroupName, ref pluginName); if (sdkVersion != null) { xrmPluginAssembly.SdkVersion = new Version(sdkVersion.Major, sdkVersion.Minor); XrmPlugin xrmPlugin = new XrmPlugin(); xrmPlugin.TypeName = type.FullName; xrmPlugin.Name = pluginName; xrmPlugin.PluginType = xrmPluginType; ItemExists pluginExists = GetRegistrationPluginId(pluginName, xrmServerDetails); xrmPlugin.PluginId = pluginExists.ItemId; xrmPlugin.FriendlyName = pluginExists.ItemId.ToString(); xrmPlugin.Exists = pluginExists.Exists; xrmPlugin.AssemblyId = xrmPluginAssembly.AssemblyId; xrmPlugin.AssemblyName = xrmPluginAssembly.Name; xrmPlugin.Isolatable = xrmPluginIsolatable; if (xrmPluginType == XrmPluginType.WorkflowActivity && !string.IsNullOrWhiteSpace(workflowGroupName)) { xrmPlugin.WorkflowActivityGroupName = workflowGroupName; } xrmPlugin = StepHelper.GetPluginSteps(xrmServerDetails, plugin, xrmPlugin, pluginName, pluginExists); xrmPluginAssembly.Plugins.Add(xrmPlugin); } } } } return(xrmPluginAssembly); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
/// <summary> /// Method to retrieve the Version of the Plugin Assembly /// </summary> /// <param name="xrmPluginAssembly">The Plugin Assembly from whence to retrieve the Version.</param> /// <param name="type">The Assembly Type being interrogated.</param> /// <param name="xrmPluginType">The Plugin Type Enumerator.</param> /// <param name="xrmPluginIsolatable">The Plugin Isolatable Enumerator.</param> /// <param name="workflowGroupName">The CWA Name.</param> /// <param name="pluginName">The Plugin Name.</param> /// <returns></returns> private Version GetSdkVersion(Type type, ref XrmPluginType xrmPluginType, ref XrmPluginIsolatable xrmPluginIsolatable, ref string workflowGroupName, ref string pluginName) { try { SdkVersion = null; XrmType = type.GetInterface(typeof(IPlugin).FullName); V4Type = type.GetInterface("Microsoft.Crm.Sdk.IPlugin"); if (XrmType != null) { xrmPluginType = XrmPluginType.Plugin; xrmPluginIsolatable = XrmPluginIsolatable.Yes; SdkVersion = XrmType.Assembly.GetName().Version; } else if (V4Type != null) { xrmPluginType = XrmPluginType.Plugin; xrmPluginIsolatable = XrmPluginIsolatable.No; SdkVersion = new Version(4, 0); } else if (type.IsSubclassOf(typeof(System.Activities.Activity)) || type.IsSubclassOf(typeof(System.Activities.Activity))) { xrmPluginType = XrmPluginType.WorkflowActivity; xrmPluginIsolatable = XrmPluginIsolatable.No; SdkVersion = new Version(); if (type.IsSubclassOf(typeof(System.Activities.Activity))) { foreach (Attribute attribute in type.GetCustomAttributes(true)) { if (attribute != null && (attribute.GetType().FullName == "Microsoft.Crm.Workflow.CrmWorkflowActivityAttribute")) { Dynamic = attribute; workflowGroupName = Dynamic.GroupName; pluginName = Dynamic.Name; break; } } } } return(SdkVersion); } catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ) { throw; } }
public PluginType(XrmPluginType type, string typeName) { TypeName = typeName; Type = type; }