private void LoadPlugIns(string filePath)
        {
            Assembly pluginAssembly = Assembly.LoadFrom(filePath);

            object[] pluginAttributes;

            // loops through all the Types found in the assembly...
            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                pluginAttributes = pluginType.GetCustomAttributes(typeof(ProcessorAttribute), true);

                // only looks for a public, non-abstract and having attribute type(s).
                if (pluginType.IsPublic && !pluginType.IsAbstract && pluginAttributes.Length != 0)
                {
                    Type interfaceType = pluginType.GetInterface("ProcessorSDK.IArrayProcessor", true);
                    if (null != interfaceType) // gets the right interface-type.
                    {
                        Types.AvailableArrayProcessor plugin = new Types.AvailableArrayProcessor();
                        plugin.AssemblyPath        = filePath;
                        plugin.Instance            = (IArrayProcessor)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                        plugin.Instance.Attributes = pluginAttributes[0] as ProcessorAttribute;
                        plugin.Instance.Initialize(this);

                        mPlugInCollection.Add(plugin); // loaded done.

                        plugin = null;                 // clean up...
                    }

                    interfaceType = null; // clean up...
                }
            }

            pluginAssembly = null; // clean up...
        }
Esempio n. 2
0
        private void MenuItemClick(object sender, RoutedEventArgs e)
        {
            Types.AvailableArrayProcessor processor = ((MenuItem)sender).Tag as Types.AvailableArrayProcessor;
            UserControl userControl = processor.Instance.Process();

            if (model.Children.Count > 0)
            {
                model.Children.Clear();
            }
            model.Children.Add(userControl);
        }