Ejemplo n.º 1
0
        public static PluginRunContext Parse(PluginConfigItem configItem, IPluginContext context)
        {
            string runContext = configItem.RunContext;
            if (string.IsNullOrEmpty(runContext))
                runContext = MainThread;
            // on the same current thread
            if (runContext == MainThread)
            {
                if (!Contexts.ContainsKey(runContext))
                    Contexts[runContext] = new PluginRunContext(configItem, context);
            }
            else if (runContext == NewThread)
            {
                if (!Contexts.ContainsKey(runContext))
                    // get a new thread
                    Contexts[runContext] = new MultiThreadPluginRunContext(configItem, context);
            }
            else if (runContext == NewProcess)
            {
                if (!Contexts.ContainsKey(runContext))
                    // get a new process
                    Contexts[runContext] = new MultiProcessPluginRunContext(configItem, context);
            }
            else if (runContext == NewAppDomain)
            {
                if (!Contexts.ContainsKey(runContext))
                    // get a new AppDomain
                    Contexts[runContext] = new MultiAppDomainPuginRunContext(configItem, context);
            }
            Contexts[runContext].ConfigItem = configItem;
            Contexts[runContext].Context = context;
            configItem.PluginRunContext = Contexts[runContext];

            return Contexts[runContext];
        }
Ejemplo n.º 2
0
 private void LoadIntoNavigation(List <PluginConfigItem> plugins)
 {
     for (int i = 0; i < plugins.Count; i++)
     {
         PluginConfigItem theItem = plugins[i];
         try
         {
             if (theItem.Status == PluginConfigItemStatus.OK)
             {
                 this._pluginContext.PluginContainer.AddConnectionPointItem(theItem,
                                                                            ExecutePlugin
                                                                            );
             }
             else
             {
                 LogUtils.LogError(new Exception(theItem.Status.ToString()));
             }
         }
         catch (Exception ex)
         {
             LogUtils.LogError(ex);
             theItem.Status = PluginConfigItemStatus.LoadPluginIntoNavigationFailure;
         }
     }
 }
Ejemplo n.º 3
0
 public PluginClosingEventArgs(IPlugin thePlugin, PluginConfigItem thePluginConfig, string closingReason, bool cancel)
 {
     Plugin        = thePlugin;
     PluginConfig  = thePluginConfig;
     ClosingReason = closingReason;
     Cancel        = cancel;
 }
Ejemplo n.º 4
0
        public void ParsePluginByContainer(ConnectionPointContainer container)
        {
            XmlNodeList pluginNodeList = GetPluginNodeList(container);

            if (pluginNodeList == null || pluginNodeList.Count == 0)
            {
                return;
            }
            if (!PluginList.ContainsKey(container.Name))
            {
                PluginList.Add(container.Name, new List <PluginConfigItem>());
            }
            List <PluginConfigItem> containerPluginList = PluginList[container.Name];

            foreach (XmlNode node in pluginNodeList)
            {
                PluginConfigItem foundItem = null;

                string url = ParsePluginUrl(node);

                foundItem = GetPluginByUrl(containerPluginList, url);
                if (foundItem == null)
                {
                    containerPluginList.Add(
                        ParsePluginConfigItem(node)
                        );
                }
            }
        }
Ejemplo n.º 5
0
 public PluginClosingEventArgs(IPlugin thePlugin, PluginConfigItem thePluginConfig, string closingReason, bool cancel)
 {
     Plugin = thePlugin;
     PluginConfig = thePluginConfig;
     ClosingReason = closingReason;
     Cancel = cancel;
 }
 public ThreadRun(PluginConfigItem ConfigItem, IPluginContext Context, AutoResetEvent theSignal, Dictionary <string, IPlugin> plugins, MultiThreadPluginRunContext parent)
 {
     this.ConfigItem = ConfigItem;
     this.Context    = Context;
     this.theSignal  = theSignal;
     this.thePlugins = plugins;
     this.parent     = parent;
 }
Ejemplo n.º 7
0
 public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
     if (container.Navigations != null && container.Navigations.Count > 0)
     {
         TreeView theTree = SelectNavigation(container, thePath);
         if (theTree != null)
         {
             AddTreeNodeIntoTree(container, theTree.Nodes, theItem, thePath, thePath.MenuPathParts, callback);
         }
     }
 }
Ejemplo n.º 8
0
 public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
     if (container.ToolStrips != null && container.ToolStrips.Count > 0)
     {
         ToolBar theToolbar = SelectToolStrip(container, thePath);
         if (theToolbar != null)
         {
             AddMenuItemIntoMenu(container, theToolbar.Items, theItem, thePath, thePath.MenuPathParts, callback);
         }
     }
 }
Ejemplo n.º 9
0
 public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
     if (container.ToolStrips != null && container.ToolStrips.Count > 0)
     {
         ToolStrip theToolbar = SelectToolStrip(container, thePath);
         if (theToolbar != null)
         {
             AddMenuItemIntoMenu(container, theToolbar.Items, theItem, thePath, thePath.MenuPathParts, callback);
         }
     }
 }
Ejemplo n.º 10
0
 public override void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
     if (container.Navigations != null && container.Navigations.Count > 0)
     {
         TreeView theTree = SelectNavigation(container, thePath);
         if (theTree != null)
         {
             AddTreeNodeIntoTree(container, theTree.Nodes, theItem, thePath, thePath.MenuPathParts, callback);
         }
     }
 }
Ejemplo n.º 11
0
        public static PluginConfigItem GetPluginConfigItem(IPluginContext context, string url)
        {
            PluginConfigItem theItem = PluginConfigParser.GetPluginByUrl(
                PluginConfigParser.GetCachePluginList()[context.PluginContainer.Name], url
                );

            if (theItem != null)
            {
                return(theItem);
            }
            throw new ArgumentOutOfRangeException();
        }
Ejemplo n.º 12
0
        public void ExecutePlugin(string pluginUrl)
        {
            Debug.Assert(pluginUrl != null);
            PluginConfigItem configItem = PluginConfigParser.GetPluginByUrl(
                PluginList[this._pluginContext.PluginContainer.Name], pluginUrl
                );

            if (configItem == null)
            {
                LogUtils.LogError("GetPluginByUrl Error." + pluginUrl, new ArgumentOutOfRangeException());
                return;
            }
            ExecutePlugin(configItem);
        }
Ejemplo n.º 13
0
        public static PluginConfigItem GetPluginByUrl(List <PluginConfigItem> containerPluginList, string url)
        {
            PluginConfigItem foundItem = null;

            foreach (PluginConfigItem theItem in containerPluginList)
            {
                if (theItem.Url == url)
                {
                    foundItem = theItem;
                    break;
                }
            }
            return(foundItem);
        }
Ejemplo n.º 14
0
 public override void AddIntoMenu(ConnectionPointContainer container, 
                                     PluginConfigItem theItem, 
                                     PluginMenuPath thePath, ExecutePluginCallback callback)
 {
     if (null != container.Menus && container.Menus.Count > 0)
     {
         Menu menu = SelectMenu(container, thePath);
         if (null != menu)
         {
             AddMenuItemIntoMenu(container,
                                 menu.Items,
                                 theItem,
                                 thePath,
                                 thePath.MenuPathParts, callback);
         }
     }
 }
Ejemplo n.º 15
0
 public override void AddIntoMenu(ConnectionPointContainer container,
                                  PluginConfigItem theItem,
                                  PluginMenuPath thePath, ExecutePluginCallback callback)
 {
     if (null != container.Menus && container.Menus.Count > 0)
     {
         Menu menu = SelectMenu(container, thePath);
         if (null != menu)
         {
             AddMenuItemIntoMenu(container,
                                 menu.Items,
                                 theItem,
                                 thePath,
                                 thePath.MenuPathParts, callback);
         }
     }
 }
Ejemplo n.º 16
0
 public void AddConnectionPointItem(PluginConfigItem theItem, ExecutePluginCallback callback)
 {
     if (_proxy != null)
     {
         _proxy.AddConnectionPointItem(theItem, callback);
         return;
     }
     foreach (PluginMenuPath thePath in theItem.MenuPaths)
     {
         PluginMenuBuilder.MakeBuilder(thePath.LocateType).AddIntoMenu(
             this,
             theItem,
             thePath,
             callback
             );
     }
 }
Ejemplo n.º 17
0
        public static PluginRunContext Parse(PluginConfigItem configItem, IPluginContext context)
        {
            string runContext = configItem.RunContext;

            if (string.IsNullOrEmpty(runContext))
            {
                runContext = MainThread;
            }
            // on the same current thread
            if (runContext == MainThread)
            {
                if (!Contexts.ContainsKey(runContext))
                {
                    Contexts[runContext] = new PluginRunContext(configItem, context);
                }
            }
            else if (runContext == NewThread)
            {
                if (!Contexts.ContainsKey(runContext))
                {
                    // get a new thread
                    Contexts[runContext] = new MultiThreadPluginRunContext(configItem, context);
                }
            }
            else if (runContext == NewProcess)
            {
                if (!Contexts.ContainsKey(runContext))
                {
                    // get a new process
                    Contexts[runContext] = new MultiProcessPluginRunContext(configItem, context);
                }
            }
            else if (runContext == NewAppDomain)
            {
                if (!Contexts.ContainsKey(runContext))
                {
                    // get a new AppDomain
                    Contexts[runContext] = new MultiAppDomainPuginRunContext(configItem, context);
                }
            }
            Contexts[runContext].ConfigItem = configItem;
            Contexts[runContext].Context    = context;
            configItem.PluginRunContext     = Contexts[runContext];

            return(Contexts[runContext]);
        }
Ejemplo n.º 18
0
 public void AddConnectionPointItem(PluginConfigItem theItem, ExecutePluginCallback callback)
 {
     if (_proxy != null)
     {
         _proxy.AddConnectionPointItem(theItem, callback);
         return;
     }
     foreach (PluginMenuPath thePath in theItem.MenuPaths)
     {
         PluginMenuBuilder.MakeBuilder(thePath.LocateType).AddIntoMenu(
             this,
             theItem,
             thePath,
             callback
         );
     }
 }
Ejemplo n.º 19
0
        protected void AddTreeNodeIntoTree(ConnectionPointContainer container, TreeNodeCollection nodes, PluginConfigItem theItem, PluginMenuPath thePath, IList<PluginMenuItemPart> thePaths, ExecutePluginCallback callback)
        {
            if (thePaths.Count < 1) return;

            PluginMenuItemPart firstPart = thePaths[0];
            PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, nodes);
            IList<PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths);

            if (!menuStruct.IsCreate)
            {
                AddTreeNodeIntoTree(container, nodes[menuStruct.Index].Nodes,
                       theItem, thePath, otherParts, callback);
            }
            else
            {
                TreeNode theMenuItem = new TreeNode(firstPart.TextStyle.Text);
                CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex));

                nodes.Insert(
                    menuStruct.Index,
                    theMenuItem
                );

                if (thePaths.Count > 1)
                {
                    AddTreeNodeIntoTree(container, theMenuItem.Nodes, theItem, thePath, otherParts, callback);
                }
                else
                {
                    theMenuItem.Name = theItem.Url;
                    theMenuItem.Tag = new object[] { theItem, callback };

                    theMenuItem.TreeView.NodeMouseClick -= new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick);
                    theMenuItem.TreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick);

                    return;
                }
            }
        }
Ejemplo n.º 20
0
        public static IDictionary<string, string> GetCategoryUrlList(string category)
        {
            Debug.Assert(category != null);
            IDictionary<string, string> result = new Dictionary<string, string>();
            foreach (XmlNode pluginNode in GetPluginXmlDoc().SelectNodes("Plugins/Plugin"))
            {
                PluginConfigItem item = new PluginConfigItem();
                item.Url = ParsePluginUrl(pluginNode);
                item.MenuPaths = ParsePluginMenuPaths(pluginNode);

                if (category == item.GetCategory())
                {
                    string key = item.GetId();
                    if (item.MenuPaths != null && item.MenuPaths.Count > 0)
                    {
                        key = item.MenuPaths[0].MenuPathParts[item.MenuPaths[0].MenuPathParts.Count - 1].TextStyle.Text;
                    }
                    result[key] = item.Url;
                }
            }
            return result;
        }
Ejemplo n.º 21
0
        private void LoadPluginDll(PluginConfigItem configItem)
        {
            IPluginLocator    theLocator    = PluginLocatorFactory.GetLocator(configItem.QualifiedName.LoadProtocol);
            IList <PluginDll> expandingDlls = new List <PluginDll>();
            IList <PluginDll> _changedList  = new List <PluginDll>();

            for (int i = 0; i < configItem.PluginDlls.Count; i++)
            {
                PluginDll theDll = configItem.PluginDlls[i];
                if (theDll.NewVersion)
                {
                    bool loaded = theLocator.LoadDll(this._pluginContext.PluginContainer.Name, theDll, expandingDlls);

                    if (!loaded)
                    {
                        configItem.Status = PluginConfigItemStatus.LoadPluginDllFailure;
                        break;
                    }
                    else
                    {
                        theDll.NewVersion = false;
                        _changedList.Add(theDll);
                    }
                }
            }

            if (_changedList.Count > 0)
            {
                PluginLocatorBase.SavePluginDllVersion(_changedList);
            }
            foreach (PluginDll expandingDll in expandingDlls)
            {
                if (!PluginLocatorBase.IsInPluginDlls(expandingDll, configItem.PluginDlls))
                {
                    configItem.PluginDlls.Add(expandingDll);
                }
            }
        }
Ejemplo n.º 22
0
        public static IDictionary <string, string> GetCategoryUrlList(string category)
        {
            Debug.Assert(category != null);
            IDictionary <string, string> result = new Dictionary <string, string>();

            foreach (XmlNode pluginNode in GetPluginXmlDoc().SelectNodes("Plugins/Plugin"))
            {
                PluginConfigItem item = new PluginConfigItem();
                item.Url       = ParsePluginUrl(pluginNode);
                item.MenuPaths = ParsePluginMenuPaths(pluginNode);

                if (category == item.GetCategory())
                {
                    string key = item.GetId();
                    if (item.MenuPaths != null && item.MenuPaths.Count > 0)
                    {
                        key = item.MenuPaths[0].MenuPathParts[item.MenuPaths[0].MenuPathParts.Count - 1].TextStyle.Text;
                    }
                    result[key] = item.Url;
                }
            }
            return(result);
        }
Ejemplo n.º 23
0
        private PluginConfigItem ParsePluginConfigItem(XmlNode node)
        {
            PluginConfigItem theItem = new PluginConfigItem();

            theItem.Status = PluginConfigItemStatus.OK;
            try
            {
                theItem.Url                  = ParsePluginUrl(node);
                theItem.PluginInitArgs       = ParsePluginInitArgs(node);
                theItem.QualifiedName        = ParsePluginLocate(node);
                theItem.Behavior             = ParsePluginBehavior(node);
                theItem.RequireFeatureAccess = ParsePluginPermission(node);
                theItem.RunContext           = ParsePluginRunContext(node);
                theItem.MenuPaths            = ParsePluginMenuPaths(node);
                theItem.PluginDlls           = ParsePluginDlls(node);
            }
            catch (Exception ex)
            {
                LogUtils.LogError(ex);
                theItem.Status = PluginConfigItemStatus.ParsePluginConfigFailure;
            }
            return(theItem);
        }
Ejemplo n.º 24
0
        public void ExecutePlugin(PluginConfigItem configItem)
        {
            Debug.Assert(configItem.Url != null);
            try
            {
                LoadPluginDll(configItem);

                PluginRunContext runContext = PluginRunContext.Parse(configItem, _pluginContext);

                bool dllLoaded = runContext.LoadPluginDlls();
                if (!dllLoaded)
                {
                    configItem.Status = PluginConfigItemStatus.CreatePluginDllFailure;
                }

                configItem.PluginRunContext = runContext;

                runContext.ExecutePlugin();
            }
            catch (Exception ex)
            {
                LogUtils.LogError(ex);
            }
        }
Ejemplo n.º 25
0
        public void ExecutePlugin(PluginConfigItem configItem)
        {
            Debug.Assert(configItem.Url != null);
            try
            {
                LoadPluginDll(configItem);

                PluginRunContext runContext = PluginRunContext.Parse(configItem, _pluginContext);

                bool dllLoaded = runContext.LoadPluginDlls();
                if (!dllLoaded)
                {
                    configItem.Status = PluginConfigItemStatus.CreatePluginDllFailure;
                }

                configItem.PluginRunContext = runContext;

                runContext.ExecutePlugin();
            }
            catch (Exception ex)
            {
                LogUtils.LogError(ex);
            }
        }
Ejemplo n.º 26
0
 public virtual void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
 }
 public ThreadRun(PluginConfigItem ConfigItem, IPluginContext Context, AutoResetEvent theSignal, Dictionary<string, IPlugin> plugins, MultiThreadPluginRunContext parent)
 {
     this.ConfigItem = ConfigItem;
     this.Context = Context;
     this.theSignal = theSignal;
     this.thePlugins = plugins;
     this.parent = parent;
 }
Ejemplo n.º 28
0
 public PluginRunContext(PluginConfigItem configItem, IPluginContext context)
 {
     _theItem = configItem;
     _context = context;
     configItem.PluginRunContext = this;
 }
 public MultiThreadPluginRunContext(PluginConfigItem ConfigItem, IPluginContext Context)
     : base(ConfigItem, Context)
 {
 }
 public MultiThreadPluginRunContext(PluginConfigItem ConfigItem, IPluginContext Context)
     : base(ConfigItem, Context)
 {
 }
 public MultiProcessPluginRunContext(PluginConfigItem theItem, IPluginContext context)
     : base(theItem, context)
 {
 }
Ejemplo n.º 32
0
        protected void AddTreeNodeIntoTree(ConnectionPointContainer container, TreeNodeCollection nodes, PluginConfigItem theItem, PluginMenuPath thePath, IList <PluginMenuItemPart> thePaths, ExecutePluginCallback callback)
        {
            if (thePaths.Count < 1)
            {
                return;
            }

            PluginMenuItemPart         firstPart  = thePaths[0];
            PluginMenuPartStruct       menuStruct = GetMenuItemIndex(firstPart, nodes);
            IList <PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths);

            if (!menuStruct.IsCreate)
            {
                AddTreeNodeIntoTree(container, nodes[menuStruct.Index].Nodes,
                                    theItem, thePath, otherParts, callback);
            }
            else
            {
                TreeNode theMenuItem = new TreeNode(firstPart.TextStyle.Text);
                CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex));

                nodes.Insert(
                    menuStruct.Index,
                    theMenuItem
                    );

                if (thePaths.Count > 1)
                {
                    AddTreeNodeIntoTree(container, theMenuItem.Nodes, theItem, thePath, otherParts, callback);
                }
                else
                {
                    theMenuItem.Name = theItem.Url;
                    theMenuItem.Tag  = new object[] { theItem, callback };

                    theMenuItem.TreeView.NodeMouseClick -= new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick);
                    theMenuItem.TreeView.NodeMouseClick += new TreeNodeMouseClickEventHandler(TreeView_NodeMouseClick);

                    return;
                }
            }
        }
 public MultiProcessPluginRunContext(PluginConfigItem theItem, IPluginContext context)
     : base(theItem, context)
 {
 }
 public MultiAppDomainPuginRunContext(PluginConfigItem theItem, IPluginContext context)
     : base(theItem, context)
 {
 }
Ejemplo n.º 35
0
 public PluginRunContext(PluginConfigItem configItem, IPluginContext context)
 {
     _theItem = configItem;
     _context = context;
     configItem.PluginRunContext = this;
 }
Ejemplo n.º 36
0
        protected void AddMenuItemIntoMenu(ConnectionPointContainer container, ToolStripItemCollection toolStripItemCollection, PluginConfigItem theItem, PluginMenuPath thePath, IList<PluginMenuItemPart> thePaths, ExecutePluginCallback callback)
        {
            if (thePaths.Count < 1) return;

            PluginMenuItemPart firstPart = thePaths[0];
            PluginMenuPartStruct menuStruct = GetMenuItemIndex(firstPart, toolStripItemCollection);
            IList<PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths);

            if (!menuStruct.IsCreate)
            {
                AddMenuItemIntoMenu(container, (toolStripItemCollection[menuStruct.Index] as
                    ToolStripMenuItem).DropDownItems,
                    theItem, thePath, otherParts, callback);

            }
            else
            {
                if (firstPart.TextStyle.Text.Trim() == "-")
                {
                    toolStripItemCollection.Insert(
                        menuStruct.Index,
                        new ToolStripSeparator()
                    );
                    return;
                }
                ToolStripMenuItem theMenuItem = new ToolStripMenuItem(firstPart.TextStyle.Text);

                CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex));
                toolStripItemCollection.Insert(
                    menuStruct.Index,
                    theMenuItem
                );

                if (thePaths.Count > 1)
                {
                    AddMenuItemIntoMenu(container, theMenuItem.DropDownItems, theItem, thePath, otherParts, callback);
                }
                else
                {
                    theMenuItem.Name = theItem.Url;
                    theMenuItem.Tag = new object[] { theItem, callback };
                    string[] behaviors = theItem.Behavior.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string action in behaviors)
                    {
                        PluginConfigItemBehaviorMode theBehavior = (PluginConfigItemBehaviorMode)Enum.Parse(typeof(PluginConfigItemBehaviorMode), action, true);
                        switch (theBehavior)
                        {
                            case PluginConfigItemBehaviorMode.Click:
                                theMenuItem.Click -= TheMenuItem_Click;
                                theMenuItem.Click += TheMenuItem_Click;
                                break;
                            case PluginConfigItemBehaviorMode.MouseOver:
                                theMenuItem.MouseMove -= new MouseEventHandler(TheMenuItem_MouseMove);
                                theMenuItem.MouseMove += new MouseEventHandler(TheMenuItem_MouseMove);
                                break;
                        }
                    }
                    return;
                }
            }
        }
Ejemplo n.º 37
0
        protected void AddMenuItemIntoMenu(ConnectionPointContainer container,
                                           ItemCollection menuItemCollection,
                                           PluginConfigItem theItem,
                                           PluginMenuPath thePath,
                                           IList <PluginMenuItemPart> thePaths, ExecutePluginCallback callback)
        {
            if (thePaths.Count < 1)
            {
                return;
            }

            PluginMenuItemPart         firstPart  = thePaths[0];
            PluginMenuPartStruct       menuStruct = GetMenuItemIndex(firstPart, menuItemCollection);
            IList <PluginMenuItemPart> otherParts = GetLeavesMenuItemParts(thePaths);

            if (!menuStruct.IsCreate)
            {
                AddMenuItemIntoMenu(container,
                                    (menuItemCollection[menuStruct.Index] as MenuItem).Items,
                                    theItem,
                                    thePath,
                                    otherParts, callback);
            }
            else
            {
                if (firstPart.TextStyle.Text.Trim() == "-")
                {
                    menuItemCollection.Insert(menuStruct.Index, new Separator());
                    return;
                }

                MenuItem theMenuItem = new MenuItem()
                {
                    Header = firstPart.TextStyle.Text
                };

                CreateMenuEndItem(firstPart, theMenuItem, GetImageList(container, thePath.MenuImageIndex));
                menuItemCollection.Insert(menuStruct.Index, theMenuItem);

                if (thePaths.Count > 1)
                {
                    AddMenuItemIntoMenu(container, theMenuItem.Items, theItem, thePath, otherParts, callback);
                }
                else
                {
                    theMenuItem.Name = theItem.Url;
                    theMenuItem.Tag  = new object[] { theItem, callback };
                    string[] behaviors = theItem.Behavior.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string action in behaviors)
                    {
                        PluginConfigItemBehaviorMode theBehavior = (PluginConfigItemBehaviorMode)Enum.Parse(typeof(PluginConfigItemBehaviorMode), action, true);
                        switch (theBehavior)
                        {
                        case PluginConfigItemBehaviorMode.Click:
                            theMenuItem.Click -= TheMenuItem_Click;
                            theMenuItem.Click += TheMenuItem_Click;
                            break;

                        case PluginConfigItemBehaviorMode.MouseOver:
                            theMenuItem.MouseMove -= TheMenuItem_MouseMove;
                            theMenuItem.MouseMove += TheMenuItem_MouseMove;
                            break;
                        }
                    }
                    return;
                }
            }
        }
Ejemplo n.º 38
0
        private PluginConfigItem ParsePluginConfigItem(XmlNode node)
        {
            PluginConfigItem theItem = new PluginConfigItem();
            theItem.Status = PluginConfigItemStatus.OK;
            try
            {
                theItem.Url = ParsePluginUrl(node);
                theItem.PluginInitArgs = ParsePluginInitArgs(node);
                theItem.QualifiedName = ParsePluginLocate(node);
                theItem.Behavior = ParsePluginBehavior(node);
                theItem.RequireFeatureAccess = ParsePluginPermission(node);
                theItem.RunContext = ParsePluginRunContext(node);
                theItem.MenuPaths = ParsePluginMenuPaths(node);
                theItem.PluginDlls = ParsePluginDlls(node);

            }
            catch (Exception ex)
            {
                LogUtils.LogError(ex);
                theItem.Status = PluginConfigItemStatus.ParsePluginConfigFailure;
            }
            return theItem;
        }
Ejemplo n.º 39
0
        private void LoadPluginDll(PluginConfigItem configItem)
        {
            IPluginLocator theLocator = PluginLocatorFactory.GetLocator(configItem.QualifiedName.LoadProtocol);
            IList<PluginDll> expandingDlls = new List<PluginDll>();
            IList<PluginDll> _changedList = new List<PluginDll>();
            for (int i = 0; i < configItem.PluginDlls.Count; i++)
            {
                PluginDll theDll = configItem.PluginDlls[i];
                if (theDll.NewVersion)
                {
                    bool loaded = theLocator.LoadDll(this._pluginContext.PluginContainer.Name, theDll, expandingDlls);

                    if (!loaded)
                    {
                        configItem.Status = PluginConfigItemStatus.LoadPluginDllFailure;
                        break;
                    }
                    else
                    {
                        theDll.NewVersion = false;
                        _changedList.Add(theDll);
                    }
                }
            }

            if (_changedList.Count > 0)
            {
                PluginLocatorBase.SavePluginDllVersion(_changedList);
            }
            foreach (PluginDll expandingDll in expandingDlls)
            {
                if (!PluginLocatorBase.IsInPluginDlls(expandingDll, configItem.PluginDlls))
                    configItem.PluginDlls.Add(expandingDll);
            }
        }
Ejemplo n.º 40
0
 public virtual void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
 }
Ejemplo n.º 41
0
 public MultiAppDomainPuginRunContext(PluginConfigItem theItem, IPluginContext context)
     : base(theItem, context)
 {
 }