internal static void Reg(IObjectContainer container) { Func<Object, Object> callback = e => { var ea = e as EntityAccessorBase; if (ea != null) return ea.Kind; return null; }; // 注册内置访问器 container .AutoRegister<IEntityAccessor, HttpEntityAccessor>(callback, EntityAccessorTypes.Http) .AutoRegister<IEntityAccessor, WebFormEntityAccessor>(callback, EntityAccessorTypes.WebForm) .AutoRegister<IEntityAccessor, WinFormEntityAccessor>(callback, EntityAccessorTypes.WinForm) .AutoRegister<IEntityAccessor, BinaryEntityAccessor>(callback, EntityAccessorTypes.Binary) .AutoRegister<IEntityAccessor, XmlEntityAccessor>(callback, EntityAccessorTypes.Xml) .AutoRegister<IEntityAccessor, JsonEntityAccessor>(callback, EntityAccessorTypes.Json); }
internal static void Reg(IObjectContainer container) { Func <Object, Object> callback = e => { var ea = e as EntityAccessorBase; if (ea != null) { return(ea.Kind); } return(null); }; // 注册内置访问器 container .AutoRegister <IEntityAccessor, HttpEntityAccessor>(callback, EntityAccessorTypes.Http) .AutoRegister <IEntityAccessor, WebFormEntityAccessor>(callback, EntityAccessorTypes.WebForm) .AutoRegister <IEntityAccessor, WinFormEntityAccessor>(callback, EntityAccessorTypes.WinForm); //.AutoRegister<IEntityAccessor, BinaryEntityAccessor>(callback, EntityAccessorTypes.Binary) //.AutoRegister<IEntityAccessor, XmlEntityAccessor>(callback, EntityAccessorTypes.Xml) //.AutoRegister<IEntityAccessor, JsonEntityAccessor>(callback, EntityAccessorTypes.Json); }
/// <summary>遍历所有程序集的所有类型,自动注册实现了指定接口或基类的类型。如果没有注册任何实现,则默认注册第一个排除类型</summary> /// <remarks>自动注册一般用于单实例功能扩展型接口</remarks> /// <typeparam name="TInterface">接口类型</typeparam> /// <typeparam name="TImplement">要排除的类型,一般是内部默认实现</typeparam> /// <param name="container">对象容器</param> /// <returns></returns> public static IObjectContainer AutoRegister <TInterface, TImplement>(this IObjectContainer container) { return(container.AutoRegister(typeof(TInterface), typeof(TImplement))); }
/// <summary>遍历所有程序集的所有类型,自动注册实现了指定接口或基类的类型。如果没有注册任何实现,则默认注册第一个排除类型</summary> /// <remarks>自动注册一般用于单实例功能扩展型接口</remarks> /// <typeparam name="TInterface">接口类型</typeparam> /// <typeparam name="TImplement">要排除的类型,一般是内部默认实现</typeparam> /// <param name="container">对象容器</param> /// <param name="getidCallback">用于从外部类型对象中获取标识的委托</param> /// <param name="id">标识</param> /// <param name="priority">优先级</param> /// <returns></returns> public static IObjectContainer AutoRegister <TInterface, TImplement>(this IObjectContainer container, Func <Object, Object> getidCallback = null, Object id = null, Int32 priority = 0) { return(container.AutoRegister(typeof(TInterface), getidCallback, id, priority, typeof(TImplement))); }