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


C# Plugin.GetType方法代码示例

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


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

示例1: RemovePlugin

		public void RemovePlugin(Plugin plugin)
		{
			if (plugin == null)
			{
				throw new ArgumentNullException("plugin");
			}
			if (plugin.Description == null)
			{
				throw new ArgumentException("Plugin.Description cannot be null", "plugin");
			}
			Type pluginType = plugin.GetType();
			string pluginName = plugin.Description.Name;
			if (_typedPlugins.ContainsKey(pluginType))
			{
				_typedPlugins.Remove(pluginType);
				_namedPlugins.Remove(pluginName);
			}
		}
开发者ID:maritaria,项目名称:HotBot,代码行数:18,代码来源:ReflectionPluginManager.cs

示例2: AddPlugin

		public void AddPlugin(Plugin plugin)
		{
			if (plugin == null)
			{
				throw new ArgumentNullException("plugin");
			}
			if (plugin.Description == null)
			{
				throw new ArgumentException("Plugin.Description cannot be null", "plugin");
			}
			Type pluginType = plugin.GetType();
			string pluginName = plugin.Description.Name;
			if (_typedPlugins.ContainsKey(pluginType))
			{
				throw new InvalidOperationException($"A plugin by the type '{pluginType.FullName}' has already been added");
			}
			if (_namedPlugins.ContainsKey(pluginName))
			{
				throw new InvalidOperationException($"Another plugin by the name '{pluginName}' has already been added. It is of the type '{pluginType.FullName}");
			}
			_typedPlugins.Add(pluginType, plugin);
			_namedPlugins.Add(pluginName, plugin);
		}
开发者ID:maritaria,项目名称:HotBot,代码行数:23,代码来源:ReflectionPluginManager.cs

示例3: UpdateDatabase

        private void UpdateDatabase(IDbConnection connection, Plugin plugin)
        {
            var assembly = plugin.GetType().Assembly;

            logger.Info("update database: {0}", assembly.FullName);

            // todo: sql
            var provider = ProviderFactory.Create<SqlServerCeTransformationProvider>(connection, null);
            //var provider = ProviderFactory.Create<SqlServerTransformationProvider>(connection, null);

            using (var migrator = new Migrator(provider, assembly))
            {
                // запрещаем выполнять миграции, для которых не указано "пространство имен"
                if (migrator.AvailableMigrations.Any())
                {
                    var migrationsInfo = assembly.GetCustomAttribute<MigrationAssemblyAttribute>();

                    if (migrationsInfo == null || string.IsNullOrWhiteSpace(migrationsInfo.Key))
                    {
                        logger.Error("assembly {0} contains invalid migration info", assembly.FullName);
                    }
                }

                migrator.Migrate();
            }
        }
开发者ID:Nslookup,项目名称:thinking-home,代码行数:26,代码来源:HomeApplication.cs

示例4: GetScriptEvents

        private void GetScriptEvents(Plugin plugin)
        {
            if (plugin == null)
            {
                return;
            }

            var properties = plugin.GetType()
                .GetProperties()
                .Where(m => m.PropertyType == typeof (ScriptEventHandlerDelegate[]))
                .ToList();

            foreach (var member in properties)
            {
                var eventInfo = member.GetCustomAttributes<ScriptEventAttribute>().SingleOrDefault();

                if (eventInfo != null)
                {
                    if (!scriptEvents.ContainsKey(eventInfo.PluginAlias))
                    {
                        scriptEvents.Add(eventInfo.PluginAlias, new HashSet<string>(StringComparer.CurrentCultureIgnoreCase));
                    }

                    scriptEvents[eventInfo.PluginAlias].Add(eventInfo.EventAlias);
                }
            }
        }
开发者ID:ZooLab,项目名称:thinking-home,代码行数:27,代码来源:ScriptsPlugin.cs

示例5: GetScriptEvents

        private void GetScriptEvents(Plugin plugin)
        {
            if (plugin == null)
            {
                return;
            }

            var properties = plugin.GetType()
                .GetProperties()
                .Where(m => m.PropertyType == typeof(ScriptEventHandlerDelegate[]))
                .ToList();

            foreach (var member in properties)
            {
                var eventInfo = member.GetCustomAttributes<ScriptEventAttribute>().SingleOrDefault();

                if (eventInfo != null)
                {
                    Logger.Info("register script event '{0}' ({1})", eventInfo.EventAlias, member);

                    if (scriptEvents.Contains(eventInfo.EventAlias))
                    {
                        var message = string.Format("duplicate event alias: '{0}'", eventInfo.EventAlias);
                        throw new Exception(message);
                    }

                    scriptEvents.Add(eventInfo.EventAlias);
                }
            }
        }
开发者ID:Nslookup,项目名称:thinking-home,代码行数:30,代码来源:ScriptsPlugin.cs


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