示例#1
0
        public void RegisterWorkflowActivities(string path)
        {
            var assemblyFilePath = new FileInfo(path);

            if (Reflection.IgnoredAssemblies.Contains(assemblyFilePath.Name))
            {
                return;
            }
            // Load each assembly
            Assembly assembly = Reflection.LoadAssembly(assemblyFilePath.FullName);

            if (assembly == null)
            {
                return;
            }

            AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += (sender, args) => Assembly.ReflectionOnlyLoad(args.Name);

            // Search for any types that interhit from IPlugin
            IEnumerable <Type> pluginTypes = Reflection.GetTypesInheritingFrom(assembly, typeof(System.Activities.CodeActivity));

            if (pluginTypes.Count() > 0)
            {
                var plugin = RegisterAssembly(assemblyFilePath, assembly, pluginTypes, isWorkflowActivity: true);
                if (plugin != null)
                {
                    RegisterActivities(pluginTypes, plugin);
                }
            }
        }
示例#2
0
        public void RegisterPlugin(string file, bool excludePluginSteps = false)
        {
            var assemblyFilePath = new FileInfo(file);

            if (assemblyFilePath.Name.StartsWith("System.") || Reflection.IgnoredAssemblies.Contains(assemblyFilePath.Name))
            {
                return;
            }

            // Load each assembly
            Assembly peekAssembly = Reflection.LoadAssembly(assemblyFilePath.FullName);

            if (peekAssembly == null)
            {
                return;
            }

            _trace.WriteLine("Checking assembly '{0}' for plugins", assemblyFilePath.Name);

            // Search for any types that interhit from IPlugin
            IEnumerable <Type> pluginTypes = Reflection.GetTypesImplementingInterface(peekAssembly, typeof(Microsoft.Xrm.Sdk.IPlugin));

            if (pluginTypes.Any())
            {
                _trace.WriteLine("{0} plugin(s) found!", pluginTypes.Count());

                var plugin = RegisterAssembly(assemblyFilePath, peekAssembly, pluginTypes);

                if (plugin != null && !excludePluginSteps)
                {
                    RegisterPluginSteps(pluginTypes, plugin);
                }
            }
        }