本文整理汇总了C#中IPluginManager.GetPluginsForType方法的典型用法代码示例。如果您正苦于以下问题:C# IPluginManager.GetPluginsForType方法的具体用法?C# IPluginManager.GetPluginsForType怎么用?C# IPluginManager.GetPluginsForType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPluginManager
的用法示例。
在下文中一共展示了IPluginManager.GetPluginsForType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SystemsManager
public SystemsManager( IPluginManager pluginManager, ILogManager logManager, INGinCore core, IMainLoopManager mainLoopManager )
{
this.LogManager = logManager;
foreach ( SystemAttribute plugin in pluginManager.GetPluginsForType( typeof( SystemAttribute ) ) )
{
// create and store system
//ConstructorInfo constructor = plugin.SystemType.GetConstructor( plugin.ConstructorParameterTypes );
//ISystem system = plugin.SystemType.InvokeMember( plugin.SystemType.Name, global::System.Reflection.BindingFlags.CreateInstance, null, null, new object[] { this.LogManager } ) as ISystem;
ISystem system = core.GetService( plugin.SystemType ) as ISystem;
lock ( this.registeredSystemsLock )
{
this.registeredSystems.Add( system.Name, system );
}
}
}
示例2: ConfigureServices
/// <summary>
/// Retrieves all types marked as service and registers them with the builder.
/// </summary>
/// <param name="builder">The autofac builder to register the services with.</param>
/// <param name="pluginManager">The plugin manager to retrieve the service plugin details from.</param>
private void ConfigureServices( ContainerBuilder builder, IPluginManager pluginManager, ILogManager logManager )
{
logManager.Trace( Namespace.LoggerName, LogLevel.Information, "Configuring services..." );
foreach ( Attribute att in pluginManager.GetPluginsForType( typeof( ServiceAttribute ) ) )
{
ServiceAttribute serviceAtt = att as ServiceAttribute;
Type instanceType, interfaceType;
instanceType = serviceAtt.InstanceType;
interfaceType = ( serviceAtt.InterfaceType == null ) ? serviceAtt.InstanceType : serviceAtt.InterfaceType;
if ( serviceAtt.AsSingleton )
{
logManager.Trace( Namespace.LoggerName, LogLevel.Debugging, "Registering service {0} as {1}. Scope: {2}", instanceType.FullName, interfaceType.FullName, "Singleton" );
builder.Register( instanceType ).As( interfaceType ).SingletonScoped();
}
else
{
logManager.Trace( Namespace.LoggerName, LogLevel.Debugging, "Registering service {0} as {1}. Scope: {2}", instanceType.FullName, interfaceType.FullName, "Factory" );
builder.Register( instanceType ).As( interfaceType ).FactoryScoped();
}
}
}
示例3: ConfigureEntityExtensions
private void ConfigureEntityExtensions( ContainerBuilder builder, IPluginManager pluginManager, ILogManager logManager )
{
logManager.Trace( Namespace.LoggerName, LogLevel.Information, "Configuring entity extensions..." );
try
{
IEnumerable<Attribute> plugins = pluginManager.GetPluginsForType( typeof( EntityExtensionAttribute ) );
foreach ( Attribute att in plugins )
{
EntityExtensionAttribute extAtt = att as EntityExtensionAttribute;
Type instanceType, interfaceType;
instanceType = extAtt.EntityExtensionType;
interfaceType = ( extAtt.InterfaceType == null ) ? extAtt.EntityExtensionType : extAtt.InterfaceType;
logManager.Trace( Namespace.LoggerName, LogLevel.Debugging, "Registering entity extension {0} as {1}.", instanceType.FullName, interfaceType.FullName );
builder.Register( instanceType ).As( interfaceType).FactoryScoped();
}
}
catch ( NGin.Core.Exceptions.PluginNotFoundException )
{
logManager.Trace( Namespace.LoggerName, LogLevel.Error, "No entity extensions registerred." );
}
}
示例4: ConfigureSystems
private void ConfigureSystems( ContainerBuilder builder, IPluginManager pluginManager, ILogManager logManager )
{
logManager.Trace( Namespace.LoggerName, LogLevel.Information, "Configuring systems..." );
foreach ( Attribute att in pluginManager.GetPluginsForType( typeof( SystemAttribute ) ) )
{
SystemAttribute systemAtt = att as SystemAttribute;
Type instanceType, interfaceType;
instanceType = systemAtt.SystemType;
interfaceType = ( systemAtt.InterfaceType == null ) ? systemAtt.SystemType : systemAtt.InterfaceType;
logManager.Trace( Namespace.LoggerName, LogLevel.Debugging, "Registering system {0} as {1}.", instanceType.FullName, interfaceType.FullName );
builder.Register( instanceType ).As( interfaceType ).SingletonScoped();
}
}
示例5: Initialize
internal void Initialize( IPluginManager pluginManager, IMachine stateMachine, INGinCore core )
{
// ensure plugin manager is not null
if ( pluginManager == null )
{
string message = "The plugin manager must not be null.";
ArgumentNullException argnEx = new ArgumentNullException( "logManager", message );
this.LogManager.Trace( Namespace.LoggerName, LogLevel.Error, argnEx, message );
throw argnEx;
}
// ensure state machine is not null
if ( stateMachine == null )
{
string message = "The state machine must not be null.";
ArgumentNullException argnEx = new ArgumentNullException( "stateMachine", message );
this.LogManager.Trace( Namespace.LoggerName, LogLevel.Error, argnEx, message );
throw argnEx;
}
if ( core == null )
{
string message = "The core must not be null.";
ArgumentNullException argnEx = new ArgumentNullException( "core", message );
this.LogManager.Trace( Namespace.LoggerName, LogLevel.Error, argnEx, message );
throw argnEx;
}
IEnumerable<Attribute> statePlugins = pluginManager.GetPluginsForType( typeof( NGinRootStateAttribute ) );
// ensure that only one root state is defined
if ( statePlugins.Count<Attribute>() > 1 )
{
string message = "More than one root state plugin was found. There must be only 1.";
InvalidOperationException invOpEx = new InvalidOperationException( message );
this.LogManager.Trace( Namespace.LoggerName, LogLevel.Error, invOpEx, message );
throw invOpEx;
}
// get attribute
NGinRootStateAttribute rootStateAtt = statePlugins.ElementAt<Attribute>( 0 ) as NGinRootStateAttribute;
// make sure attribute is not null
if ( rootStateAtt == null )
{
string message = "Error loading the root state plugin.";
InvalidOperationException invOpEx = new InvalidOperationException( message );
this.LogManager.Trace( Namespace.LoggerName, LogLevel.Error, invOpEx, message );
throw invOpEx;
}
// add type to machine root
Type rootStateType = rootStateAtt.RootStateType;
IState state = core.GetService( rootStateType ) as IState;
if ( state == null )
{
string message = String.Format( System.Globalization.CultureInfo.InvariantCulture, "An error occurred while retrieving instance of {0}.", rootStateType.FullName );
InvalidOperationException invopEx = new InvalidOperationException( message );
this.LogManager.Trace( Namespace.LoggerName, LogLevel.Error, invopEx, message );
throw invopEx;
}
this.StateMachine.RootState.AddSubState( state );
stateMachine.Initialize( state.Name );
}