本文整理汇总了C#中IRegistry.RegisterInstance方法的典型用法代码示例。如果您正苦于以下问题:C# IRegistry.RegisterInstance方法的具体用法?C# IRegistry.RegisterInstance怎么用?C# IRegistry.RegisterInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRegistry
的用法示例。
在下文中一共展示了IRegistry.RegisterInstance方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetupExtensibility
private static void SetupExtensibility(IRegistry registry)
{
var dynamicProxy = new CastleDynamicProxyProvider();
var aopRepository = new AspectRepository(dynamicProxy);
var dllPlugins =
(from key in ConfigurationManager.AppSettings.AllKeys
where key.StartsWith("PluginsPath", StringComparison.OrdinalIgnoreCase)
let path = ConfigurationManager.AppSettings[key]
let pathRelative = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path)
let chosenPath = Directory.Exists(pathRelative) ? pathRelative : path
select chosenPath)
.ToList();
registry.RegisterInstance(new PluginsConfiguration { Directories = dllPlugins });
registry.Register<SystemInitialization>();
registry.Register<IObjectFactory, DryIocObjectFactory>(Reuse.Singleton);
registry.Register<IExtensibilityProvider, DryIocMefProvider>(Reuse.Singleton);
registry.Register(typeof(IPluginRepository<>), typeof(PluginRepository<>), Reuse.Singleton);
registry.RegisterInstance<IAspectRegistrator>(aopRepository);
registry.RegisterInstance<IAspectComposer>(aopRepository);
//registry.RegisterInstance<IInterceptorRegistrator>(aopRepository);
registry.RegisterInstance<IMixinProvider>(dynamicProxy);
registry.RegisterInstance<IDynamicProxyProvider>(dynamicProxy);
}
示例2: Load
public static void Load(IRegistry registry)
{
registry.RegisterInstance<ISystemState>(new ServerState());
registry.RegisterInstance<IPermissionManager>(new NoAuth());
registry.Register<IRestApplication, RestApplication>(Reuse.Singleton);
registry.Register<RestApplication>(Reuse.Singleton);
//builder.RegisterType<SoapApplication>().As<SoapApplication, ISoapApplication>();
registry.Register<ICommandConverter, CommandConverter>(Reuse.Singleton);
SetupExtensibility(registry);
SetupPostgres(registry);
SetupPatterns(registry);
SetupSerialization(registry);
//builder.RegisterType<RepositoryAuthentication>().As<IAuthentication>();
//builder.RegisterType<RepositoryPrincipalFactory>().As<IPrincipalFactory>();
//registry.Register<IPermissionManager, PermissionManager>(Reuse.Singleton);
registry.Register<IProcessingEngine, ProcessingEngine>(Reuse.Singleton);
registry.Register<IScopePool, ScopePool>(Reuse.Singleton);
}
示例3: SetupPostgres
private static void SetupPostgres(IRegistry registry)
{
var cs = ConfigurationManager.AppSettings["ConnectionString"];
if (string.IsNullOrEmpty(cs))
throw new ConfigurationErrorsException(@"ConnectionString is missing from configuration. Add ConnectionString to <appSettings>
Example: <add key=""ConnectionString"" value=""server=postgres.localhost;port=5432;database=MyDatabase;user=postgres;password=123456;encoding=unicode"" />");
registry.RegisterInstance(new NGS.DatabasePersistence.Postgres.ConnectionInfo(cs));
registry.Register<IDatabaseQueryManager, PostgresQueryManager>(Reuse.InCurrentScope);
registry.Register<IPostgresDatabaseQuery, PostgresDatabaseQuery>();
registry.RegisterDelegate(r => r.Resolve<IDatabaseQueryManager>().CreateQuery(), Reuse.InCurrentScope);
registry.Register<IDataChangeNotification, PostgresDatabaseNotification>(Reuse.Singleton);
registry.Register<IEagerNotification, PostgresDatabaseNotification>(Reuse.Singleton);
registry.Register<IPostgresConverterRepository, PostgresObjectFactory>(Reuse.Singleton);
registry.Register<IPostgresConverterFactory, PostgresObjectFactory>(Reuse.Singleton);
registry.Register<NGS.DatabasePersistence.Postgres.QueryGeneration.QueryExecutor>();
}