商业源码是比较完整,适合商业应用的资源,需要使用金币进行购买...
为了满足广大企业开发的需求,51Aspx特提供软件项目订制和开发服务
LightFactory轻量级注入框架源码
程序介绍
LightFactory非常快!
委托创建对象仅需要一个函数和一个if语句。LightFactory是非常高性能的依赖注入的框架。
LightFactory is extremely fast!
To invoke your object-generator delegate LightFactory used only 1 method call and check only 1 if-condition. Its make LightFactory one of the most high-performance Dependency Injection framework ever!
使用非常简单,看代码
public class Program
{
/// <summary>
/// STEP 1: Create you own factory which will inherit FactoryBase and provide type registration in InitTypes method.
/// </summary>
class SamplerFactory : FactoryBase
{
/// <summary>
/// STEP 2: Register new instance of you factory class with FactoryBase.RegisterFactory(...) call
/// </summary>
public override void InitFactory()
{
Define<ICollection<int>, int[]>(arr => new List<int>(arr));
}
}
public static void Main()
{
/// <summary>
/// STEP 3: Register SampleFactory instance before use it
/// </summary>
FactoryBase.RegisterFactory(new SamplerFactory());
/// <summary>
/// STEP 4: Use Factory<T>.Create() method and its overloads to create new instances.
/// </summary>
ICollection colletion = Factory<ICollection>.Create(new int[] { 1, 2, 3 });
}
}
|
|
|
|
综合讨论
下载前咨询(0人) | 下载后讨论(0)人
我要参与