本文整理汇总了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);
}
}
示例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);
}
示例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();
}
}
示例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);
}
}
}
示例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);
}
}
}