当前位置: 首页>>代码示例>>C#>>正文


C# IPlugin.GetType方法代码示例

本文整理汇总了C#中IPlugin.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# IPlugin.GetType方法的具体用法?C# IPlugin.GetType怎么用?C# IPlugin.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IPlugin的用法示例。


在下文中一共展示了IPlugin.GetType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RunPlugin

 public bool RunPlugin(IPlugin pluginToRun)
 {
     notificationService.Notify(pluginToRun.GetType().Name, "Running", NotificationType.Information);
     var succeeded = pluginToRun.Run();
     notificationService.Notify(pluginToRun.GetType().Name, succeeded ? "Succeeded" : "Failed", NotificationType.Information);
     return succeeded;
 }
开发者ID:jen20,项目名称:Jubilee,代码行数:7,代码来源:VerboseOutputPluginRunner.cs

示例2: Init

        public void Init(IPlugin plugin, IEnumerable<System.Reflection.Assembly> assemblies)
        {
            this.Plugin = plugin;
            this.Assembly = plugin.GetType().Assembly;
            this.Types = plugin.GetType().Assembly.GetTypes();

            if (DependentAssemblys == null)
            {
                DependentAssemblys = new List<Assembly>();
            }
            var assems = assemblies;//.Where(p => plugin.DependentAssembly.Contains(p.GetName().Name)).ToList();
            DependentAssemblys.AddRange(assems);

        }
开发者ID:jefth,项目名称:PluginMvcWeb,代码行数:14,代码来源:PluginDescriptor.cs

示例3: GetPluginRoot

 private string GetPluginRoot(IPlugin item)
 {
     var library = DnxPlatformServices.Default.LibraryManager.GetLibrary(item.GetType().GetTypeInfo().Assembly.GetName().Name);
     var path = library.Path;
     if (library.Type == "Project")
         path = System.IO.Path.GetDirectoryName(path);
     return path;
 }
开发者ID:genusP,项目名称:AspNet5-Modularity,代码行数:8,代码来源:PluginManager.cs

示例4: AddReference

 /// <summary>
 /// Add an array of references to your command here
 /// </summary>
 /// <param name="plugin">The plugin d that this reference... references, you should most likely use 'this'</param>    
 public static void AddReference(IPlugin plugin)
 {
     if (plugin.GetType().GetInterface("ICommand", false) != null) //nothing prevents a plugin from being a command (except this line)
     {
     }
     else
     {
         Plugins.Add(plugin);
     }
 }
开发者ID:Maicke98,项目名称:MCForge-Vanilla,代码行数:14,代码来源:Plugin.cs

示例5: Plugin

 /// <summary>
 /// 
 /// </summary>
 /// <param name="plugin"></param>
 public Plugin(IPlugin plugin)
 {
     var plugType = plugin.GetType();
     this.Name = plugType.Name;
     this.FullName = plugType.FullName;
     this.AuthorCode = plugin.Author;
     this.Description = plugin.Description;
     base.Id = plugin.Id;
     this.Title = plugin.Title;
     this.IsEnabled = 0;
 }
开发者ID:mingkongbin,项目名称:anycmd,代码行数:15,代码来源:Plugin.cs

示例6: GetParameters

        public static List<PluginParameterAttribute> GetParameters(IPlugin plugin)
        {
            var list = new List<PluginParameterAttribute>();
            var type = plugin.GetType();

            var properties = type.GetProperties();
            foreach (var property in properties)
            {
                object[] attrs = property.GetCustomAttributes(typeof(PluginParameterAttribute), false);
                if (attrs.Count() > 0)
                {
                    list.Add(((PluginParameterAttribute[])attrs).Single());
                }
            }

            return list;
        }
开发者ID:fbeye,项目名称:mystream,代码行数:17,代码来源:ParameterUtility.cs

示例7: GetAttr

		/// <summary>
		/// 取得指定插件的AcDownPluginInformationAttribute属性
		/// </summary>
		/// <param name="plugin">插件引用</param>
		/// <exception cref="AcDownAttributeNotImplementedException" />
		/// <returns></returns>
		public AcDownPluginInformationAttribute GetAttr(IPlugin plugin)
		{
			try
			{
				object[] types = plugin.GetType().GetCustomAttributes(typeof(AcDownPluginInformationAttribute), true);
				var attrib = (AcDownPluginInformationAttribute)types[0];
				return attrib;
			}
			catch
			{
				throw new AcDownAttributeNotImplementedException(plugin);
			}
		}
开发者ID:kwedr,项目名称:acdown,代码行数:19,代码来源:PluginManager.cs

示例8: MountPluginMenu

 private static void MountPluginMenu(IPlugin currentPlugin, MenuItem parent, IEnumerable<IMenu> subMenus)
 {
     if (subMenus != null)
     {
         foreach (IMenu menu in subMenus)
         {
             MenuItem item = new MenuItem(menu.Label, (sender, e) =>
             {
                 string pluginName = currentPlugin.GetType().Namespace + "." + currentPlugin.GetType().Name;
                 string menuName = menu.Name;
                 DoActionPlugin(pluginName, menuName, currentPlugin, menu);
                 ((MenuItem)sender).Checked = menu.Checked;
             });
             item.Checked = menu.Checked;
             parent.MenuItems.Add(item);
             MountPluginMenu(currentPlugin, item, menu.Children);
         }
     }
 }
开发者ID:joaopaulog,项目名称:Binner,代码行数:19,代码来源:Program.cs

示例9: DefaultPluginManager

 internal DefaultPluginManager(IPlugin plugin)
 {
     _instance = plugin;
     _attribute = plugin.GetType().GetAttribute<PluginAttribute>();
 }
开发者ID:randacc,项目名称:hdkn,代码行数:5,代码来源:DefaultPluginManager.cs

示例10: ConfigureManager

		/// <summary>
		/// Initializes a new instance of the <see cref="PluginLoader.Configure.ConfigureManager"/> class.
		/// </summary>
		/// <param name="instance">the plugin instance</param>
		public ConfigureManager (IPlugin instance)
			:this(instance.GetType())
		{

		}
开发者ID:uccu,项目名称:PluginLoader,代码行数:9,代码来源:ConfigureManager.cs

示例11: StartupPlugin

        //internal static void Initialize()
        //{
        //    if (mGlobalInstance == null)
        //    {
        //        mGlobalInstance = new PluginManager(true);
        //        LoadPlugins(mGlobalInstance);
        //    }
        //    if (mProjectInstance != null)
        //    {
        //        foreach (IPlugin plugin in mProjectInstance.mPluginContainers.Keys)
        //        {
        //            ShutDownPlugin(plugin, PluginShutDownReason.GlueShutDown);
        //        }
        //    }
        //    mProjectInstance = new PluginManager(false);
        //    mInstances.Clear();
        //    mInstances.Add(mGlobalInstance);
        //    mInstances.Add(mProjectInstance);
        //    LoadPlugins(mProjectInstance);
        //}
        internal static void StartupPlugin(IPlugin plugin, PluginManager instance)
        {
            // See if the plugin already exists - it may implement multiple interfaces
            if (!instance.mPluginContainers.ContainsKey(plugin))
            {
                PluginContainer pluginContainer = new PluginContainer(plugin);
                instance.mPluginContainers.Add(plugin, pluginContainer);

                try
                {
                    plugin.UniqueId = plugin.GetType().FullName;

                    if (!mPluginSettingsSave.DisabledPlugins.Contains(plugin.UniqueId))
                    {

                        plugin.StartUp();
                    }
                    else
                    {
                        pluginContainer.IsEnabled = false;
                    }
                }
                catch (Exception e)
                {
            #if DEBUG
                    MessageBox.Show("Plugin failed to start up:\n\n" + e.ToString());
            #endif
                    pluginContainer.Fail(e, "Plugin failed in StartUp");
                }
            }
        }
开发者ID:jiailiuyan,项目名称:Gum,代码行数:51,代码来源:PluginManager.cs

示例12: TryLoad

 internal bool TryLoad( ServiceHost serviceHost, Func<IPlugin> pluginCreator, object pluginKey )
 {
     if( _instance == null )
     {
         try
         {
             _instance = pluginCreator();
             if( _instance == null )
             {
                 _loadError = new CKException( R.PluginCreatorReturnedNull, pluginKey );
                 return false;
             }
             Type t = _instance.GetType();
             if( typeof( IDynamicService ).IsAssignableFrom( t ) )
             {
                 Type iType = t.GetInterfaces().FirstOrDefault( i => i != typeof( IDynamicService ) && typeof( IDynamicService ).IsAssignableFrom( i ) );
                 if( iType != null )
                 {
                     Service = serviceHost.EnsureProxy( iType );
                 }
             }
         }
         catch( Exception ex )
         {
             _loadError = ex;
             return false;
         }
     }
     return true;
 }
开发者ID:Nementon,项目名称:ck-desktop,代码行数:30,代码来源:PluginProxyBase.cs

示例13: RegisterPluginInstance

        private static void RegisterPluginInstance(IPlugin plugin)
        {
            var pluginType = plugin.GetType();

            if (plugin.MinVersion > Version)
            {
                MessageBox.Show(string.Format("The plugin {0} couldn't be loaded because it needs the interface version {1}.\nThe current interface version is {2}.", plugin.UniqueName, plugin.MinVersion, Version));
            }

            Plugins.Add(plugin);

            if (typeof(IPersistentPlugin).IsAssignableFrom(pluginType))
            {
                var persistentPlugin = (IPersistentPlugin)plugin;
                var persistentDirectory = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @".\PersistentPlugins\", plugin.UniqueName);

                if (!Directory.Exists(persistentDirectory))
                {
                    Directory.CreateDirectory(persistentDirectory);
                }

                persistentPlugin.PersistentDirectory = persistentDirectory;
            }

            if (typeof(IDataPlugin).IsAssignableFrom(pluginType))
            {
                var dataPlugin = (IDataPlugin)plugin;
                var ids = dataPlugin.DataIdentifiers;

                foreach (var id in ids.Distinct())
                {
                    if (!DataPlugins.ContainsKey(id))
                    {
                        DataPlugins.Add(id, new List<IDataPlugin>());
                    }

                    DataPlugins[id].Add(dataPlugin);
                }

                if (typeof(IDynamicDataPlugin).IsAssignableFrom(pluginType))
                {
                    var dynamicDataPlugin = (IDynamicDataPlugin)dataPlugin;

                    dynamicDataPlugin.DataIdentifiersChanged = () =>
                        {
                            DataPlugins = DataPlugins.ToDictionary(x => x.Key, x => x.Value.Where(y => y != dynamicDataPlugin).ToList()).Where(x => x.Value.Count != 0).ToDictionary(x => x.Key, x => x.Value);

                            var newIds = dynamicDataPlugin.DataIdentifiers;

                            foreach (var id in newIds.Distinct())
                            {
                                if (!DataPlugins.ContainsKey(id))
                                {
                                    DataPlugins.Add(id, new List<IDataPlugin>());
                                }

                                DataPlugins[id].Add(dynamicDataPlugin);
                            }
                        };
                }
            }

            if (typeof(IFilePlugin).IsAssignableFrom(pluginType))
            {
                var filePlugin = (IFilePlugin)plugin;
                var ids = filePlugin.FileIdentifiers;

                foreach (var id in ids.Distinct())
                {
                    if (!FilePlugins.ContainsKey(id))
                    {
                        FilePlugins.Add(id, new List<IFilePlugin>());
                    }

                    FilePlugins[id].Add(filePlugin);
                }

                if (typeof(IDynamicDataPlugin).IsAssignableFrom(pluginType))
                {
                    var dynamicFilePlugin = (IDynamicFilePlugin)filePlugin;

                    dynamicFilePlugin.DataIdentifiersChanged = () =>
                    {
                        FilePlugins = FilePlugins.ToDictionary(x => x.Key, x => x.Value.Where(y => y != dynamicFilePlugin).ToList()).Where(x => x.Value.Count != 0).ToDictionary(x => x.Key, x => x.Value);

                        var newIds = dynamicFilePlugin.FileIdentifiers;

                        foreach (var id in newIds.Distinct())
                        {
                            if (!DataPlugins.ContainsKey(id))
                            {
                                FilePlugins.Add(id, new List<IFilePlugin>());
                            }

                            FilePlugins[id].Add(dynamicFilePlugin);
                        }
                    };
                }
            }

//.........这里部分代码省略.........
开发者ID:Tamschi,项目名称:RawFile,代码行数:101,代码来源:PluginManager.cs

示例14: Plugin_PluginLoadFailed

 private void Plugin_PluginLoadFailed(IPlugin plugin, Exception err)
 {
     string errorMessage = string.Format(SilverlightMediaFrameworkResources.PluginLoadFailedLogMessage,
                                         plugin.GetType(), err.Message);
     SendLogEntry(KnownLogEntryTypes.GeneralErrorOccurred, LogLevel.Error, errorMessage);
 }
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:6,代码来源:SMFPlayer.cs

示例15: SaveConfiguration

        /// <summary>
        /// 保存插件配置
        /// </summary>
        /// <param name="plugin">需要保存配置的插件引用</param>
        /// <returns>如果保存成功返回true,失败为false</returns>
        public bool SaveConfiguration(IPlugin plugin)
        {
            try
            {
                //取得APPDATA路径名称
                string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
                path = Path.Combine(path, @"Kaedei\AcDown\Plugins\");
                //建立文件夹
                if (!Directory.Exists(path)) Directory.CreateDirectory(path);
                //反射属性
                object[] types = plugin.GetType().GetCustomAttributes(typeof(AcDownPluginInformationAttribute), true);
                var attrib = (AcDownPluginInformationAttribute)types[0];
                //取得完整文件名
                path = Path.Combine(path, attrib.Name + ".xml"); //%appdata%\acdown\plugins\acfundownloader.xml

                //反序列化插件设置
                XmlSerializer s = new XmlSerializer(typeof(SerializableDictionary<string, string>));
                using (FileStream fs = new FileStream(path, FileMode.Create))
                {
                    s.Serialize(fs, plugin.Configuration);
                }
                return true;
            }
            catch
            {
                return false;
            }
        }
开发者ID:renning22,项目名称:SnifferPlayer,代码行数:33,代码来源:PluginManager.cs


注:本文中的IPlugin.GetType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。