コード例 #1
0
ファイル: PluginRunContext.cs プロジェクト: nateliu/StarSharp
        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];
        }
コード例 #2
0
ファイル: PluginConfig.cs プロジェクト: nateliu/StarSharp
 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;
         }
     }
 }
コード例 #3
0
 public PluginClosingEventArgs(IPlugin thePlugin, PluginConfigItem thePluginConfig, string closingReason, bool cancel)
 {
     Plugin        = thePlugin;
     PluginConfig  = thePluginConfig;
     ClosingReason = closingReason;
     Cancel        = cancel;
 }
コード例 #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)
                        );
                }
            }
        }
コード例 #5
0
 public PluginClosingEventArgs(IPlugin thePlugin, PluginConfigItem thePluginConfig, string closingReason, bool cancel)
 {
     Plugin = thePlugin;
     PluginConfig = thePluginConfig;
     ClosingReason = closingReason;
     Cancel = cancel;
 }
コード例 #6
0
 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;
 }
コード例 #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);
         }
     }
 }
コード例 #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);
         }
     }
 }
コード例 #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);
         }
     }
 }
コード例 #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);
         }
     }
 }
コード例 #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();
        }
コード例 #12
0
ファイル: PluginConfig.cs プロジェクト: nateliu/StarSharp
        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);
        }
コード例 #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);
        }
コード例 #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);
         }
     }
 }
コード例 #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);
         }
     }
 }
コード例 #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
             );
     }
 }
コード例 #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]);
        }
コード例 #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
         );
     }
 }
コード例 #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;
                }
            }
        }
コード例 #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;
        }
コード例 #21
0
ファイル: PluginConfig.cs プロジェクト: nateliu/StarSharp
        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);
                }
            }
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #24
0
ファイル: PluginConfig.cs プロジェクト: nateliu/StarSharp
        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);
            }
        }
コード例 #25
0
ファイル: PluginConfig.cs プロジェクト: nateliu/StarSharp
        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);
            }
        }
コード例 #26
0
 public virtual void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
 }
コード例 #27
0
 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;
 }
コード例 #28
0
ファイル: PluginRunContext.cs プロジェクト: nateliu/StarSharp
 public PluginRunContext(PluginConfigItem configItem, IPluginContext context)
 {
     _theItem = configItem;
     _context = context;
     configItem.PluginRunContext = this;
 }
コード例 #29
0
 public MultiThreadPluginRunContext(PluginConfigItem ConfigItem, IPluginContext Context)
     : base(ConfigItem, Context)
 {
 }
コード例 #30
0
 public MultiThreadPluginRunContext(PluginConfigItem ConfigItem, IPluginContext Context)
     : base(ConfigItem, Context)
 {
 }
コード例 #31
0
 public MultiProcessPluginRunContext(PluginConfigItem theItem, IPluginContext context)
     : base(theItem, context)
 {
 }
コード例 #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;
                }
            }
        }
コード例 #33
0
 public MultiProcessPluginRunContext(PluginConfigItem theItem, IPluginContext context)
     : base(theItem, context)
 {
 }
コード例 #34
0
 public MultiAppDomainPuginRunContext(PluginConfigItem theItem, IPluginContext context)
     : base(theItem, context)
 {
 }
コード例 #35
0
 public PluginRunContext(PluginConfigItem configItem, IPluginContext context)
 {
     _theItem = configItem;
     _context = context;
     configItem.PluginRunContext = this;
 }
コード例 #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;
                }
            }
        }
コード例 #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;
                }
            }
        }
コード例 #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;
        }
コード例 #39
0
ファイル: PluginConfig.cs プロジェクト: nateliu/StarSharp
        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);
            }
        }
コード例 #40
0
 public virtual void AddIntoMenu(ConnectionPointContainer container, PluginConfigItem theItem, PluginMenuPath thePath, ExecutePluginCallback callback)
 {
 }
コード例 #41
0
 public MultiAppDomainPuginRunContext(PluginConfigItem theItem, IPluginContext context)
     : base(theItem, context)
 {
 }