//////////////////////////////////////////////////////////////////////////////// #region ImplicitBindingsHelpers protected internal static void SetupImplicitPropResolvers <CType>(Resolver <CType> resolver) where CType : class { Type typeT = typeof(CType); do { var props = from p in typeT.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) select new { Info = p as MemberInfo, MemType = p.PropertyType }; var fields = from f in typeT.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance) select new { Info = f as MemberInfo, MemType = f.FieldType }; var propsAndFields = props.Union(fields) .Where(pf => pf.Info.GetCustomAttributes(typeof(InjectAttribute), true).Length != 0) .Where(pf => pf.Info.DeclaringType == typeT); foreach (var pf in propsAndFields) { InvokeSetupImplicitPropResolvers <CType> (pf.Info, pf.MemType, pf.Info.Name, resolver); } } while ((typeT = typeT.BaseType) != null && typeT != typeof(object)); // setup singleton if (typeof(CType).GetCustomAttributes(typeof(SingletonAttribute), false).Length > 0) { resolver.AsSingleton(true); } }
public IInjectorBinding <CType> AsSingleton(bool singlton = true) { resolver.AsSingleton(singlton); return(this); }