示例#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]);
        }
示例#2
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];
        }