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


C# IObjectFactory.RegisterType方法代码示例

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


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

示例1: Initialize

 public void Initialize(IObjectFactory factory)
 {
     foreach (var type in AssemblyScanner.GetAllTypes())
     {
         var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
         if (attr != null && attr.Length == 1)
         {
             var st = attr[0].Scope;
             factory.RegisterType(type, type, st);
             foreach (var i in type.GetInterfaces())
                 factory.RegisterType(type, i, st);
         }
     }
 }
开发者ID:nutrija,项目名称:revenj,代码行数:14,代码来源:ServiceAspect.cs

示例2: Initialize

		public void Initialize(IObjectFactory factory)
		{
			foreach (var type in AssemblyScanner.GetAllTypes())
			{
				var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
				if (attr != null && attr.Length == 1)
					factory.RegisterType(type, attr[0].Scope, new[] { type }.Union(type.GetInterfaces()).ToArray());
			}
		}
开发者ID:dstimac,项目名称:revenj,代码行数:9,代码来源:ServiceAspect.cs

示例3: Initialize

 public void Initialize(IObjectFactory factory)
 {
     foreach (var type in AssemblyScanner.GetAllTypes().Where(it => it.IsPublic || it.IsNestedPublic))
     {
         var interfaces =
             (from i in type.GetInterfaces()
              where i.IsGenericType
                  && i.GetGenericTypeDefinition() == typeof(IDomainEventHandler<>)
              select i).ToList();
         if (interfaces.Count > 0)
         {
             var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
             if (attr == null || attr.Length == 0)
             {
                 factory.RegisterType(type);
                 foreach (var i in interfaces)
                     factory.RegisterType(type, i, InstanceScope.Transient);
             }
         }
     }
 }
开发者ID:nutrija,项目名称:revenj,代码行数:21,代码来源:EventProcessorAspect.cs

示例4: Initialize

 public void Initialize(IObjectFactory factory)
 {
     foreach (var type in AssemblyScanner.GetAllTypes().Where(it => it.IsPublic || it.IsNestedPublic))
     {
         if (type.GetInterfaces().Any(it => it.IsGenericType && it.GetGenericTypeDefinition() == typeof(IServerService<,>)))
         {
             var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
             if (attr == null || attr.Length == 0)
                 factory.RegisterType(type);
         }
     }
 }
开发者ID:nutrija,项目名称:revenj,代码行数:12,代码来源:ServerServiceAspect.cs

示例5: Initialize

 public void Initialize(IObjectFactory factory)
 {
     var plugins = new Dictionary<Type, InstanceScope>();
     foreach (var type in AssemblyScanner.GetAllTypes())
     {
         var attr = type.GetCustomAttributes(typeof(PluginAttribute), false) as PluginAttribute[];
         if (attr != null && attr.Length == 1)
             plugins.Add(type, attr[0].Scope);
     }
     foreach (var type in AssemblyScanner.GetAllTypes())
     {
         if (type.IsClass && !type.IsAbstract)
         {
             foreach (var i in type.GetInterfaces())
                 if (plugins.ContainsKey(i))
                     factory.RegisterType(type, i, plugins[i]);
         }
     }
 }
开发者ID:nutrija,项目名称:revenj,代码行数:19,代码来源:PluginAspect.cs

示例6: Initialize

		public void Initialize(IObjectFactory factory)
		{
			foreach (var type in AssemblyScanner.GetAllTypes())
			{
				if (type.IsAbstract || !type.IsClass)
					continue;
				var interfaces =
					(from i in type.GetInterfaces()
					 where i.IsGenericType
						 && i.GetGenericTypeDefinition() == typeof(IDomainEventHandler<>)
					 select i).ToList();
				if (interfaces.Count > 0)
				{
					var attr = type.GetCustomAttributes(typeof(ServiceAttribute), false) as ServiceAttribute[];
					if (attr == null || attr.Length == 0)
						factory.RegisterType(type, InstanceScope.Transient, new[] { type }.Union(interfaces).ToArray());
				}
			}
		}
开发者ID:dstimac,项目名称:revenj,代码行数:19,代码来源:EventProcessorAspect.cs


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