/// <summary>
 /// Copies the elements of the specified <see cref="IPlugin">IPlugin</see> array to the end of the collection.
 /// </summary>
 /// <param name="value">An array of type <see cref="IPlugin">IPlugin</see> containing the objects to add to the collection.</param>
 public void AddRange(IPlugin[] value)
 {
     for (int i = 0;	(i < value.Length); i = (i + 1))
     {
         this.Add(value[i]);
     }
 }
Exemple #2
0
 public bool Register(IPlugin ipi)
 {
     //MenuItem mn = new MenuItem(ipi.Name, new EventHandler(NewLoad));
     Trace.WriteLine("Registered: " + ipi.Name);
     //menuItem1.MenuItems.Add(mn);
     return true;
 }
Exemple #3
0
        /// <summary>
        /// Create single instance
        /// </summary>
        /// <returns></returns>
        public static TaskFacade getInstance(IPlugin pPlugin)
        {
            if (cInstance == null)
            cInstance = new TaskFacade(pPlugin);

              return (cInstance);
        }
Exemple #4
0
 public PluginList WithPlugin(IPlugin plugin)
 {
     var result = new PluginList();
     result._plugins.AddRange(Plugins);
     result._plugins.Add(plugin);
     return result;
 }
 public PluginEntry(IPlugin plugin,string filename)
 {
     m_filename = filename;
     m_plugin = plugin;
     m_enabled = false;
     m_licensed = false;
 }
Exemple #6
0
 private DomainFacade(IPlugin pPlugin)
 {
     cPlugin = pPlugin;
       cObserverList = new List<IObserver>();
       cRecordList = new BindingList<DNSPoisonRecord>();
       cInfrastructure = InfrastructureFacade.getInstance(pPlugin);
 }
Exemple #7
0
        /// <summary>
        /// Create single instance
        /// </summary>
        /// <returns></returns>
        public static DomainFacade getInstance(IPlugin pPlugin)
        {
            if (cInstance == null)
            cInstance = new DomainFacade(pPlugin);

              return (cInstance);
        }
        public bool StopPlugin(IPlugin plugin)
        {
            AppDomain domain;

            Domains.TryRemove(plugin, out domain);

            try
            {
                AppDomain.Unload(domain);
            }
            catch (CannotUnloadAppDomainException ex)
            {
                Domains.TryAdd(plugin, domain);
                return false;
            }
            try
            {
                var val = plugin.GetDomainName();
            }
            catch (AppDomainUnloadedException ex)
            {
            }

            return true;
        }
 public void Initialize(IPlugin plugin)
 {
     pipeListener = new NamedPipeListener<string>("SlavApp.Minion.Resembler");
     pipeListener.MessageReceived += (sender, e) => { OnMessageReceived(plugin, e); };
     pipeListener.Error += (sender, e) => { OnError(e); };
     pipeListener.Start();
 }
        /// <summary>
        /// Write skins file without a skin.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="skindeletenr"></param>
        /// <returns></returns>
        public static bool WriteSkinsFileDeleteSkin(IPlugin.IPluginHost host, int skindeletenr)
        {
            XmlTextWriter xmlwriter = null;
            bool succeed = false;
            try
            {
                xmlwriter = WriteSkinFileHeader(host.GetSkinsFile());
                for (int i = 0; i < host.CountSkins; i++)
                {
                    if (skindeletenr != i)
                    {
                        Skin currentskin = SkinFactory.GetSkin(host, i);
                        WriteSkinsFileSkin(xmlwriter, currentskin);
                    }
                }

                xmlwriter = WriteSkinFileFooter(xmlwriter);
                succeed = true;
            }
            finally
            {
                if (xmlwriter != null)
                {
                    xmlwriter.Close();
                }
            }

            return succeed;
        }
        /// <summary>
        /// Writes the skins file to disk to with all NoteFly skins.
        /// </summary>
        /// <param name="host"></param>
        /// <param name="editskinnr"></param>
        /// <param name="editskin"></param>
        /// <returns>true if writing skins file was succesfull.</returns>
        public static bool WriteSkinsFileEditSkin(IPlugin.IPluginHost host, int editskinnr, Skin editskin)
        {
            XmlTextWriter xmlwriter = null;
            bool succeed = false;
            try
            {
                xmlwriter = WriteSkinFileHeader(host.GetSkinsFile());
                for (int i = 0; i < host.CountSkins; i++)
                {
                    Skin currentskin = null;
                    if (editskinnr == i)
                    {
                        currentskin = editskin;
                    }
                    else
                    {
                        currentskin = SkinFactory.GetSkin(host, i);
                    }

                    WriteSkinsFileSkin(xmlwriter, currentskin);
                }

                xmlwriter = WriteSkinFileFooter(xmlwriter);
                succeed = true;
            }
            finally
            {
                if (xmlwriter != null)
                {
                    xmlwriter.Close();
                }
            }

            return succeed;
        }
Exemple #12
0
        /// <summary>
        /// Create single instance
        /// </summary>
        /// <param name="pFWConfig"></param>
        /// <returns></returns>
        public static DomainFacade getInstance(InjectionConfig pFWConfig, IPlugin pPlugin)
        {
            if (cInstance == null)
            cInstance = new DomainFacade(pFWConfig, pPlugin);

              return (cInstance);
        }
        /// <summary>
        /// The configure.
        /// </summary>
        /// <param name="targetPlugin">
        /// The target plugin.
        /// </param>
        /// <returns>
        /// The <see cref="IConfig"/>.
        /// </returns>
        public IConfig Configure(IPlugin targetPlugin)
        {
            IConfig currentConfig = targetPlugin.Configuration,
                    defaultConfig = targetPlugin.DefaultConfig,
                    targetConfig = currentConfig ?? defaultConfig;

            if (targetConfig != null && defaultConfig != null)
            {
                using (
                    var configDialog =
                        new ObjectBrowserDialog(
                            string.Format(CultureInfo.InvariantCulture, "{0} Configuration", targetPlugin.GetDetail().Key).Trim(),
                            targetConfig,
                            defaultConfig,
                            this._logger))
                {
                    var result = configDialog.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        return configDialog.ResultObject as IConfig;
                    }
                }
            }

            return currentConfig;
        }
Exemple #14
0
 private DomainFacade(IPlugin pPlugin)
 {
     cPlugin = pPlugin;
       cInfrastructure = InfrastructureFacade.getInstance(pPlugin);
       cRecordList = new List<Session.Config.Session>();
       cObserverList = new List<IObserver>();
 }
Exemple #15
0
 private DomainFacade(InjectionConfig pProxyConfig, IPlugin pPlugin)
 {
     cPlugin = pPlugin;
       cInfrastructure = InfrastructureFacade.getInstance(pProxyConfig, pPlugin);
       cRecordList = new List<InjectedURLRecord>();
       cObservers = new List<IObserver>();
 }
Exemple #16
0
 private DomainFacade(IPlugin pPlugin)
 {
     cPlugin = pPlugin;
       cObserverList = new List<IObserver>();
       cInfrastructure = InfrastructureFacade.getInstance(pPlugin);
       cRecordList = new List<HTTPRequests>();
 }
 internal PluginInfo(IPlugin plugin, string description, string pluginRoot, Assembly assembly)
 {
     Plugin = plugin;
     Description = description;
     PluginRoot = pluginRoot;
     Assembly = assembly;
 }
 public virtual int CompareTo(IPlugin other)
 {
     if (other == null)
         return 1;
     var result = SortOrder.CompareTo(other.SortOrder) * 2 + String.CompareOrdinal(Name, other.Name);
     return result;
 }
 public static string BundleContent(this UrlHelper helper, IPlugin bundle, string url)
 {
     string _bundlerootUrl = System.Web.HttpContext.Current.Request.Url.Authority.ToString() + @"/" + LEnvironment.Provider.PluginsDirectoryName;
     string pluginName = bundle.Assembly.GetName().Name;
     string path = "http://" + _bundlerootUrl + @"/" + pluginName + @"/" + url;
     return path;
 }
Exemple #20
0
        /// <summary>
        /// Create single instance
        /// </summary>
        /// <param name="pFWConfig"></param>
        /// <returns></returns>
        public static TaskFacade getInstance(InjectionConfig pProxyConfig, IPlugin pPlugin)
        {
            if (cInstance == null)
            cInstance = new TaskFacade(pProxyConfig, pPlugin);

              return (cInstance);
        }
Exemple #21
0
        /// <summary>
        /// Creates the tool strip button for plugin.
        /// </summary>
        /// <param name="plugin">The plugin.</param>
        /// <returns></returns>
        public static ToolStripButton CreateToolStripButtonForPlugin( IPlugin plugin )
        {
            Image img = plugin.Image == null ? DroidExplorer.Resources.Images.android : plugin.Image;
            ToolStripButton tsb = new ToolStripButton ( plugin.Text, plugin.Image, delegate ( object sender, EventArgs e ) {

                try {
                    plugin.Execute ( plugin.PluginHost, plugin.PluginHost.CurrentDirectory );
                } catch ( Exception ex ) {
                    //throw;
                    sender.LogError ( ex.Message, ex );
                }
            }, plugin.Name );
            tsb.DisplayStyle = plugin.DisplayStyle;

            // check for min tools version (there has to be a better way to check this)
            var minPT = plugin.MinimumSDKPlatformToolsVersion;
            var minT = plugin.MinimumSDKToolsVersion;
            var sdkv = 0;
            var sval = CommandRunner.Instance.GetProperty ( "ro.build.version.sdk" );
            int.TryParse ( sval, out sdkv );

            tsb.Enabled = sdkv >= minT;

            return tsb;
        }
 public PluginCommunicationResponse(IPlugin responder, string result,
     object responseData = null)
 {
     Plugin = responder;
     Result = result;
     ResponseData = responseData;
 }
Exemple #23
0
        /// <summary>
        /// Create single instance
        /// </summary>
        /// <returns></returns>
        public static DomainFacade getInstance(IPAccountingConfig pConfig, IPlugin pPlugin)
        {
            if (cInstance == null)
            cInstance = new DomainFacade(pConfig, pPlugin);

              return (cInstance);
        }
        /// <summary>
        /// 注册一个插件
        /// </summary>
        public bool Register(IPlugin vPlug)
        {
            /*
            ListBoxItem item = new ListBoxItem();
            item.MouseDoubleClick += NewLoad;
            list1.Items.Add(vPlug.PlugName);*/
            try
            {
                this.regPluginList.Add(vPlug);//添加到已注册列表

                GridItem button = new GridItem("Image/fullbox_desk_clear.png", vPlug.PlugName);
                int pluNum = this.regPluginList.Count;
                int x = (pluNum - 1) % 6;
                int y = (pluNum - 1) / 6;
                AddToGrid(button, x, y);

                //----超出部分未处理

                return true;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                return false;
            }
        }
Exemple #25
0
 /// <summary>
 /// 
 /// </summary>
 private DomainFacade(IPAccountingConfig pConfig, IPlugin pPlugin)
 {
     cPlugin = pPlugin;
       cRecordList = new List<AccountingItem>();
       cObserverList = new List<IObserver>();
       cInfrastructure = InfrastructureFacade.getInstance(pConfig, pPlugin, ref cRecordList);
 }
        public PluginTreeNode(Type type)
        {
            _type = type;
            _instance = (IPlugin)Activator.CreateInstance(_type);

            IPluginData[] data = _instance.GetData();
            foreach (IPluginData item in data)
            {
                if (item.Children == null)
                {
                    Nodes.Add(new LeafTreeNode(item));
                }
                else
                {
                    int i = Nodes.Add(new BranchTreeNode(item));
                    var newNode = Nodes[i];
                    foreach (IPluginData childItem in item.Children)
                    {
                        if (childItem.Children == null)
                        {
                            newNode.Nodes.Add(new LeafTreeNode(childItem));
                        }
                        else
                        {
                            newNode.Nodes.Add(new BranchTreeNode(childItem));
                        }
                    }
                }
            }

            Text = DisplayName;
        }
Exemple #27
0
 /// <summary>
 /// 
 /// </summary>
 public DomainFacade(ProxyConfig pProxyConfig, IPlugin pPlugin)
 {
     cPlugin = pPlugin;
       cRecordList = new List<IMAP4Account>();
       cObserverList = new List<IObserver>();
       cInfrastructure = InfrastructureFacade.getInstance(pProxyConfig, pPlugin);
 }
Exemple #28
0
 public override void Initialise(IPlugin plugin)
 {
     ICommandConsole console = plugin as ICommandConsole;
     if (console == null)
         return;
     console.Initialize(m_defaultPrompt, m_source, m_baseOpenSim);
 }
Exemple #29
0
        public Battle(IEnumerable<IEnumerable<Character>> teams, IPlugin interopPlugin, IJSScriptHelper scriptHelper, IRandomHelper randomHelper)
        {
            if(teams == null)
            {
                throw new ArgumentNullException(nameof(teams));
            }

            if(interopPlugin == null)
            {
                throw new ArgumentNullException(nameof(interopPlugin));
            }

            if(scriptHelper == null)
            {
                throw new ArgumentNullException(nameof(scriptHelper));
            }

            if(randomHelper == null)
            {
                throw new ArgumentNullException(nameof(randomHelper));
            }

            this.AllCharactersInTeams = new Dictionary<string, ICollection<SpecificCharacter>>();

            foreach (var team in teams)
            {
                var teamCharacters = (ICollection<SpecificCharacter>)team.Select(x => new SpecificCharacter(x));
                this.AllCharactersInTeams.Add("team", teamCharacters);
            }

            this.InteropPlugin = interopPlugin;
            this.ScriptHelper = scriptHelper;
            this.RandomHelper = randomHelper;
        }
Exemple #30
0
        /// <summary>
        /// Create single instance
        /// </summary>
        /// <param name="pWebServerConfig"></param>
        /// <returns></returns>
        public static TaskFacade getInstance(WebServerConfig pWebServerConfig, IPlugin pPlugin)
        {
            if (cInstance == null)
            cInstance = new TaskFacade(pWebServerConfig, pPlugin);

              return (cInstance);
        }
Exemple #31
0
 private IEnumerable <ConfigurationPageInfo> GetConfigPages(IPlugin plugin)
 {
     return(GetPluginPages(plugin).Select(i => new ConfigurationPageInfo(plugin, i.Item1)));
 }
Exemple #32
0
 /// <summary>
 /// Returns a string with the assembly's location.
 /// </summary>
 public string GetPluginAssemblyLocation(IPlugin plugin)
 {
     return(plugin.GetType().Assembly.Location);
 }
 public SimulatedWindSensor(ILogger logger, IPlugin plugin)
 {
     _plugin = plugin;
     _logger = logger;
 }
Exemple #34
0
 public void Register(string name, IPlugin plugin)
 {
     plugins.Add(name, plugin);
 }
Exemple #35
0
        public Component LoadComponent(string filePath)
        {
            FileInfo file = new FileInfo(filePath);

            // Preliminary check
            // must exist
            if (!file.Exists)
            {
                throw new PluginException(string.Format("File {0} does not exist. Cannot load Component.", filePath));
            }
            // must be a dll file
            if (!file.Extension.Equals(".dll"))
            {
                throw new PluginException(string.Format("File {0} is not a dll file. Cannot load Component.", filePath));
            }

            //Create a new assembly from the plugin file we're adding..
            Assembly  pluginAssembly = Assembly.LoadFrom(filePath);
            Component component      = null;

            //Next we'll loop through all the Types found in the assembly
            foreach (Type pluginType in pluginAssembly.GetTypes())
            {
                if (pluginType.IsPublic)        //Only look at public types
                {
                    if (!pluginType.IsAbstract) //Only look at non-abstract types
                    {
                        //Gets a type object of the interface we need the plugins to match
                        Type typeInterface = pluginType.GetInterface("Pic.Plugin.IPlugin", true);

                        //Make sure the interface we want to use actually exists
                        if (typeInterface != null)
                        {
                            //Create a new available plugin since the type implements the IPlugin interface
                            IPlugin plugin = (IPlugin)Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
                            if (null != plugin)
                            {
                                component = new Component(plugin);

                                //Set the Plugin's host to this class which inherited IPluginHost
                                plugin.Host = this;

                                //Call the initialization sub of the plugin
                                plugin.Initialize();

                                //cleanup a bit
                                plugin = null;
                            }
                        }
                        typeInterface = null; //Mr. Clean
                    }
                }
            }
            pluginAssembly = null; //more cleanup

            // check that a component was actually created
            if (null == component)
            {
                throw new Pic.Plugin.PluginException(string.Format("Failed to load valid component from existing file {0}", filePath));
            }

            // insert component in cache for fast retrieval
            ComponentLoader.InsertInCache(component);

            return(component);
        }
Exemple #36
0
        public ParameterStack GetInitializedParameterStack(IPlugin plugin)
        {
            // check if already available in cache
            ParameterStack stack = null;

            stack = ComponentLoader.GetStackFromCache(plugin.Guid);
            if (null == stack)
            {
                if (!(_searchMethod is IComponentSearchMethod))
                {
                    throw new PluginException("Component loader was not initialized with a valid plugin search method.");
                }

                IPluginExt1 pluginExt1 = plugin as IPluginExt1;
                IPluginExt2 pluginExt2 = plugin as IPluginExt2;
                IPluginExt3 pluginExt3 = plugin as IPluginExt3;

                // get parameter stack
                if (null != pluginExt1)
                {
                    stack = plugin.Parameters;
                }
                else if (null != pluginExt2)
                {
                    stack = pluginExt2.BuildParameterStack(null);
                }
                else if (null != pluginExt3)
                {
                    stack = pluginExt3.BuildParameterStack(null);
                }
                // check parameter stack
                if (null == stack)
                {
                    throw new PluginException("Failed to build initial parameter stack.");
                }

                // load parameter values from plugins
                foreach (Parameter param in stack)
                {
                    try
                    {
                        ParameterDouble pd = param as ParameterDouble;
                        if (null != pd)
                        {
                            stack.SetDoubleParameter(pd.Name, _searchMethod.GetDoubleParameterDefaultValue(plugin.Guid, pd.Name));
                        }
                        ParameterBool pb = param as ParameterBool;
                        if (null != pb)
                        {
                            stack.SetBoolParameter(pb.Name, _searchMethod.GetBoolParameterDefaultValue(plugin.Guid, pb.Name));
                        }
                        ParameterInt pi = param as ParameterInt;
                        if (null != pi)
                        {
                            stack.SetIntParameter(pi.Name, _searchMethod.GetIntParameterDefaultValue(plugin.Guid, pi.Name));
                        }
                        ParameterMulti pm = param as ParameterMulti;
                        if (null != pm)
                        {
                            stack.SetMultiParameter(pm.Name, _searchMethod.GetMultiParameterDefaultValue(plugin.Guid, pm.Name));
                        }
                    }
                    catch (Exception /*ex*/)
                    {
                    }
                }
                // save in cache
                ComponentLoader.InsertParameterStackInCache(plugin.Guid, stack);
            }
            return(stack.Clone());
        }
Exemple #37
0
 public void Feedback(string Feedback, IPlugin Plugin)
 {
 }
Exemple #38
0
        public static void LoadAllDlls()
        {
            string[] publishFiles;
            #region  采集地址
            ListISpiderUrlPlugin.Clear();
            if (!Directory.Exists(SpiderUrlPluginPath))
            {
                Directory.CreateDirectory(SpiderUrlPluginPath);
            }
            else
            {
                var exts = new[] { "*Plugin.dll", "*.py" };
                foreach (var ext in exts)
                {
                    publishFiles = Directory.GetFiles(SpiderUrlPluginPath, ext);
                    foreach (string str2 in publishFiles)
                    {
                        try {
                            Assembly assembly = Assembly.LoadFrom(str2);
                            FileInfo fi       = new FileInfo(str2);
                            string   ff       = fi.Name.Replace(fi.Extension, "");
                            ff = ff.Replace("Plugin", "");
                            IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                            ListISpiderUrlPlugin.Add(item);
                        }
                        catch (Exception) { }
                    }
                }
            }
            #endregion

            #region 采集内容
            ListISpiderContentPlugin.Clear();
            if (!Directory.Exists(SpiderContentPluginPath))
            {
                Directory.CreateDirectory(SpiderContentPluginPath);
            }
            else
            {
                publishFiles = Directory.GetFiles(SpiderContentPluginPath, "*Plugin.dll");
                foreach (string str2 in publishFiles)
                {
                    try {
                        Assembly assembly = Assembly.LoadFrom(str2);
                        FileInfo fi       = new FileInfo(str2);
                        string   ff       = fi.Name.Replace(fi.Extension, "");
                        ff = ff.Replace("Plugin", "");
                        IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                        ListISpiderContentPlugin.Add(item);
                    }
                    catch (Exception) { }
                }
            }
            #endregion

            #region 发布内容
            ListIPublishContentPlugin.Clear();
            if (!Directory.Exists(PublishContentPluginPath))
            {
                Directory.CreateDirectory(PublishContentPluginPath);
            }
            else
            {
                publishFiles = Directory.GetFiles(PublishContentPluginPath, "*Plugin.dll");
                foreach (string str2 in publishFiles)
                {
                    try {
                        Assembly assembly = Assembly.LoadFrom(str2);
                        FileInfo fi       = new FileInfo(str2);
                        string   ff       = fi.Name.Replace(fi.Extension, "");
                        ff = ff.Replace("Plugin", "");
                        IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                        ListIPublishContentPlugin.Add(item);
                    }
                    catch (Exception) { }
                }
            }
            #endregion

            #region 保存内容
            ListISaveContentPlugin.Clear();
            if (!Directory.Exists(SaveContentPluginPath))
            {
                Directory.CreateDirectory(SaveContentPluginPath);
            }
            else
            {
                publishFiles = Directory.GetFiles(SaveContentPluginPath, "*Plugin.dll");
                foreach (string str2 in publishFiles)
                {
                    try {
                        Assembly assembly = Assembly.LoadFrom(str2);
                        FileInfo fi       = new FileInfo(str2);
                        string   ff       = fi.Name.Replace(fi.Extension, "");
                        ff = ff.Replace("Plugin", "");
                        IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                        ListISaveContentPlugin.Add(item);
                    }
                    catch (Exception) { }
                }
            }
            #endregion
        }
 public PluginTables(IPlugin plugin)
 {
     this.plugin = plugin;
 }
Exemple #40
0
 public PluginDecorator(IPlugin decoratee)
 {
     this.Decoratee = decoratee;
 }
Exemple #41
0
 public PluginDecorator(IPlugin plugin)
 {
 }
Exemple #42
0
 /// <summary>
 /// initializes a new instance of the EventListener struct.
 /// </summary>
 /// <param name="listener">A valid Listener.
 /// All Listeners are in the Chraft.Plugins.Listener namespace.</param>
 /// <param name="plugin">The IPlugin that the listener is attached to.</param>
 /// <param name="Event">The name of the event to listen for.</param>
 public EventListener(IChraftListener listener, IPlugin plugin, Event Event)
 {
     this.Listener = listener;
     this.Event    = Event;
     this.Plugin   = plugin;
 }
Exemple #43
0
        /// <summary>
        /// 加载单个插件
        /// </summary>
        /// <param name="pluginFile"></param>
        public static bool LoadPlugin(string pluginFile)
        {
            PluginPackAttribute attribute = null;
            IPlugin             obj       = null;

            try
            {
                byte[] bytes = File.ReadAllBytes(pluginFile);
                var    ass   = Assembly.Load(bytes);
                var    attbs = ass.GetCustomAttributes(typeof(PluginPackAttribute), true);

                if (attbs.Length != 0)
                {
                    attribute = (PluginPackAttribute)attbs[0];
                }
                else
                {
                    //StringBuilder sb = new StringBuilder();
                    //foreach (object a in ass.GetCustomAttributes(true))
                    //{
                    //    sb.Append("\r\n")
                    //        .Append(a.GetType() == typeof(PluginPackAttribute));
                    //}
                    throw new NotSupportedException("不可识别的插件!请为程序集标记PluginPack特性!");
                }

                var types = ass.GetTypes();
                foreach (Type type in types)
                {
                    if (type.IsClass)
                    {
                        foreach (Type t in type.GetInterfaces())
                        {
                            if (t == typeof(IPlugin))
                            {
                                obj = Activator.CreateInstance(type) as IPlugin;
                                if (obj == null)
                                {
                                    continue;
                                }

                                if (attribute != null)
                                {
                                    plugins.Add(obj, attribute);
                                }
                            }
                        }
                    }
                }
                if (log != null)
                {
                    log.Append(String.Format("\r\n{0}({1}) found plugin. version:{2}",
                                             attribute.Name,
                                             ass.GetName().Name,
                                             attribute.Version));
                }
            }
            catch (Exception err)
            {
                if (log != null)
                {
                    log.Append(String.Format("\r\nAssembly {0} happend exception:{1}",
                                             pluginFile.Substring(pluginFile.LastIndexOfAny(new char[] { '/', '\\' }) + 1),
                                             err.Message));
                }
                return(false);
            }
            return(true);
        }
Exemple #44
0
 public PluginConsumer(IPlugin plugin)
 {
 }
Exemple #45
0
 private TaskFacade(InjectionConfig pProxyConfig, IPlugin pPlugin)
 {
     cPlugin = pPlugin;
     cDomain = DomainFacade.getInstance(pProxyConfig, pPlugin);
 }
Exemple #46
0
 public FailingConstructorPluginDecorator(IPlugin plugin)
 {
     throw new NotImplementedException();
 }
Exemple #47
0
 public void LoadPlugin(IPlugin pluginToLoad)
 {
     throw new NotImplementedException();
 }
 public PluginDatabase(IPlugin plugin)
 {
     this.plugin = plugin;
 }
 public T GetSetting <T>(string key, IPlugin plugin)
 {
     throw new NotImplementedException();
 }
        public static void LoadAllDlls()
        {
            string[] publishFiles;
            #region  采集地址
            ListISpiderUrlPlugin.Clear();
            if (!Directory.Exists(SpiderUrlPluginPath))
            {
                Directory.CreateDirectory(SpiderUrlPluginPath);
            }
            else
            {
                var exts = new[] { "*Plugin.dll", "*.py" };
                foreach (var ext in exts)
                {
                    publishFiles = Directory.GetFiles(SpiderUrlPluginPath, ext);
                    foreach (string str2 in publishFiles)
                    {
                        try {
                            Assembly assembly = Assembly.LoadFrom(str2);
                            FileInfo fi       = new FileInfo(str2);
                            string   ff       = fi.Name.Replace(fi.Extension, "");
                            ff = ff.Replace("Plugin", "");
                            IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                            ListISpiderUrlPlugin.Add(item);
                        }
                        catch (Exception) { }
                    }
                }
            }
            #endregion

            #region 采集内容
            ListISpiderContentPlugin.Clear();
            if (!Directory.Exists(SpiderContentPluginPath))
            {
                Directory.CreateDirectory(SpiderContentPluginPath);
            }
            else
            {
                publishFiles = Directory.GetFiles(SpiderContentPluginPath, "*Plugin.dll");
                foreach (string str2 in publishFiles)
                {
                    try {
                        Assembly assembly = Assembly.LoadFrom(str2);
                        FileInfo fi       = new FileInfo(str2);
                        string   ff       = fi.Name.Replace(fi.Extension, "");
                        ff = ff.Replace("Plugin", "");
                        IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                        ListISpiderContentPlugin.Add(item);
                    }
                    catch (Exception) { }
                }
            }
            #endregion

            #region 发布内容
            ListIPublishContentPlugin.Clear();
            if (!Directory.Exists(PublishContentPluginPath))
            {
                Directory.CreateDirectory(PublishContentPluginPath);
            }
            else
            {
                publishFiles = Directory.GetFiles(PublishContentPluginPath, "*Plugin.dll");
                foreach (string str2 in publishFiles)
                {
                    try {
                        Assembly assembly = Assembly.LoadFrom(str2);
                        FileInfo fi       = new FileInfo(str2);
                        string   ff       = fi.Name.Replace(fi.Extension, "");
                        ff = ff.Replace("Plugin", "");
                        IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                        ListIPublishContentPlugin.Add(item);
                    }
                    catch (Exception) { }
                }
            }
            #endregion

            #region 保存内容
            ListISaveContentPlugin.Clear();
            if (!Directory.Exists(SaveContentPluginPath))
            {
                Directory.CreateDirectory(SaveContentPluginPath);
            }
            else
            {
                publishFiles = Directory.GetFiles(SaveContentPluginPath, "*Plugin.dll");
                foreach (string str2 in publishFiles)
                {
                    try {
                        Assembly assembly = Assembly.LoadFrom(str2);
                        FileInfo fi       = new FileInfo(str2);
                        string   ff       = fi.Name.Replace(fi.Extension, "");
                        ff = ff.Replace("Plugin", "");
                        IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                        ListISaveContentPlugin.Add(item);
                    }
                    catch (Exception) { }
                }
            }
            #endregion

            #region 保存内容
            ListIOutputFormatPlugin.Clear();
            if (!Directory.Exists(SaveContentPluginPath))
            {
                Directory.CreateDirectory(SaveContentPluginPath);
            }
            else
            {
                publishFiles = Directory.GetFiles(SaveContentPluginPath, "*Plugin.dll");
                foreach (string str2 in publishFiles)
                {
                    try
                    {
                        Assembly assembly = Assembly.LoadFrom(str2);
                        //  FileInfo fi = new FileInfo(str2);
                        // string ff = fi.Name.Replace(fi.Extension, "");
                        // ff = ff.Replace("Plugin", "");
                        // IPlugin item = (IPlugin)Activator.CreateInstance(assembly.GetType("V5.DataCollection.Core." + ff));
                        // ListISaveContentPlugin.Add(item);
                    }
                    catch (Exception) { }
                }
                var ass   = AppDomain.CurrentDomain.GetAssemblies();
                var types = ass.SelectMany(x => x.GetTypes()).Where(t => t.GetInterface(typeof(IOutPutFormat).Name) != null);
                foreach (var t in types)
                {
                    IOutPutFormat item = (IOutPutFormat)Activator.CreateInstance(t);
                    ListIOutputFormatPlugin.Add(item);
                }
            }
            #endregion
        }
Exemple #51
0
 private void RunPlugin(IPlugin plugin)
 {
     plugin.Execute();
 }
Exemple #52
0
 public void InitializePlugin(IPlugin plugin)
 {
     plugin.InitializePlugin();
 }
Exemple #53
0
 public Coroutine(Action action, int waitMilliseconds, IPlugin owner, string name = null, bool autoStart = true) : this(
         action, new WaitTime(waitMilliseconds), owner, name, autoStart)
 {
 }
 public bool AddSettings(string key, object value, IPlugin plugin)
 {
     throw new NotImplementedException();
 }
Exemple #55
0
        private Coroutine(string name, IPlugin owner)
        {
            Name = name ?? MathHepler.GetRandomWord(13);

            OwnerName = Owner == null ? "Free" : Owner.GetType().Namespace;
        }
 void plugin_DataChanged(IPlugin sender, EventArgsDataName e)
 {
     OnNotifyDataChanged(sender, e);
 }
        private void RemoveViewEngine(IPlugin bundle)
        {
            IPluginViewEngine tmp;

            _viewEngines.TryRemove(bundle.PluginDescriptor.SystemName, out tmp);
        }
Exemple #58
0
        public Coroutine(Action action, IYieldBase condition, IPlugin owner, string name = null, bool infinity = true,
                         bool autoStart = true) : this(name, owner)
        {
            Running = autoStart;
            Started = DateTime.Now;
            Owner   = owner;
            switch (condition)
            {
            case WaitTime _:
                TimeoutForAction = ((WaitTime)condition).Milliseconds.ToString();
                break;

            case WaitRender _:
                TimeoutForAction = ((WaitRender)condition).HowManyRenderCountWait.ToString();
                break;

            case WaitRandom _:
                TimeoutForAction = ((WaitRandom)condition).Timeout;
                break;

            case WaitFunction _:
                TimeoutForAction = "Function -1";
                break;
            }

            Action    = action;
            Condition = condition;

            if (infinity)
            {
                IEnumerator CoroutineAction(Action a)
                {
                    yield return(YieldBase.RealWork);

                    while (true)
                    {
                        try
                        {
                            a?.Invoke();
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine($"Coroutine {Name} in {OwnerName} error -> {e}");
                        }

                        Ticks++;
                        yield return(Condition.GetEnumerator());
                    }
                }

                _enumerator = CoroutineAction(action);
            }
            else
            {
                IEnumerator CoroutineAction(Action a)
                {
                    yield return(Condition.GetEnumerator());

                    a?.Invoke();
                    Ticks++;
                }

                _enumerator = CoroutineAction(action);
            }
        }
 private void AddViewEngine(IPlugin bundle)
 {
     _viewEngines.TryAdd(bundle.PluginDescriptor.SystemName, BundleViewEngineFactory.CreateViewEngine(bundle));
 }
 public LocalEventHandler(IPlugin plugin, TreeView tree)
 {
     this.PWork  = plugin.Run;
     this.PInfor = plugin.PluginInfo;
     this.Tree   = tree;
 }