public MethodMaterializer(IShifterContext context) { Assume.ArgumentNotNull(context, "context"); Assume.ArgumentNotNull(context.Instance, "context.Instance"); this.context = context; }
public override ConstructorInfo Selecter(IShifterContext context) { Assume.ArgumentNotNull(context, "context"); var bindingFlags = new BindingFlagsCombiner().Execute(context.Container.Options.ResolvePrivateMembers); var constructors = new List <ConstructorInfo>(context.TypeToResolve.GetConstructors(bindingFlags)); var injectMarkedConstructors = constructors.FindAll(constructor => constructor.IsDefined(typeof(InjectAttribute), false)); if (injectMarkedConstructors.Count > 1) { throw new NotSupportedException(Strings.MultipleConstructorInjectionIsNotSupported); } if (injectMarkedConstructors.Count == 1) { return(injectMarkedConstructors[0]); } if (constructors.Count > 0) { return(constructors[0]); } return(context.TypeToResolve.GetConstructor(Type.EmptyTypes)); }
public PropertyInjector(PropertyInfo property, IShifterContext context, object value) { Assume.ArgumentNotNull(property, "property"); Assume.ArgumentNotNull(context, "context"); this.property = property; this.context = context; this.value = value; }
public override IEnumerable <PropertyInfo> Select(IShifterContext context) { Assume.ArgumentNotNull(context, "context"); var bindingFlags = new BindingFlagsCombiner().Execute(context.Container.Options.ResolvePrivateMembers); var propertyList = new List <PropertyInfo>(context.TypeToResolve.GetProperties(bindingFlags)); return(propertyList.Where(property => property.IsDefined(typeof(InjectAttribute), false))); }
public ConstructorInjector(ConstructorInfo constructor, IShifterContext context, object[] arguments) { Assume.ArgumentNotNull(constructor, "constructor"); Assume.ArgumentNotNull(context, "context"); this.constructor = constructor; this.context = context; this.arguments = arguments; }
public MethodInjector(IShifterContext context, MethodBase method, object[] parameters) { Assume.ArgumentNotNull(context, "context"); Assume.ArgumentNotNull(method, "method"); Assume.ArrayNotNullOrEmpty(parameters, "parameters"); this.context = context; this.method = method; this.parameters = parameters; }
public FieldInjector(IShifterContext context, FieldInfo field, object value) { Assume.ArgumentNotNull(context, "context"); Assume.ArgumentNotNull(field, "field"); Assume.ArgumentNotNull(value, "value"); this.context = context; this.field = field; this.value = value; }
public ShifterContext(Type typeToResolve, IShifterContainer container, IEnumerable <Func <IResolutionStrategy> > strategyFactoryFactories) { Assume.ArgumentNotNull(typeToResolve, "typeToResolve"); Assume.ArgumentNotNull(container, "container"); Assume.ArgumentNotNull(strategyFactoryFactories, "strategyFactoryFactories"); TypeToResolve = typeToResolve; Container = container; StrategyFactories = strategyFactoryFactories; }
public void Initialize(IShifterContext context) { Assume.ArgumentNotNull(context, "context"); if (context.Instance == null) { throw new TypeResolvingFailedException(string.Format(Strings.InstanceIsNull, context.TypeToResolve.Name)); } InitializeImpl(context); }
public PropertyMaterializer(IShifterContext context) { Assume.ArgumentNotNull(context, "context"); this.context = context; }