Пример #1
0
        public MethodMaterializer(IShifterContext context)
        {
            Assume.ArgumentNotNull(context, "context");
            Assume.ArgumentNotNull(context.Instance, "context.Instance");

            this.context = context;
        }
Пример #2
0
        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));
        }
Пример #3
0
        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;
        }
Пример #4
0
        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)));
        }
Пример #5
0
        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;
        }
Пример #6
0
        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;
        }
Пример #7
0
        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;
        }
Пример #8
0
        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);
        }
Пример #9
0
        protected override void InitializeImpl(IShifterContext context)
        {
            var fieldMaterializer = new FieldMaterializer(context);

            fieldMaterializer.Engage();
        }
Пример #10
0
        public PropertyMaterializer(IShifterContext context)
        {
            Assume.ArgumentNotNull(context, "context");

            this.context = context;
        }
Пример #11
0
        protected override void InitializeImpl(IShifterContext context)
        {
            var methodMaterializer = new MethodMaterializer(context);

            methodMaterializer.Engage();
        }
Пример #12
0
 protected abstract void InitializeImpl(IShifterContext context);
Пример #13
0
 public ResolveProvider(IShifterContext context)
 {
     this.context = context;
 }
Пример #14
0
 public abstract T Selecter(IShifterContext context);
Пример #15
0
        protected override void InitializeImpl(IShifterContext context)
        {
            var propertyMaterializer = new PropertyMaterializer(context);

            propertyMaterializer.Engage();
        }
Пример #16
0
 public abstract IEnumerable <T> Select(IShifterContext context);
Пример #17
0
 public ConstructorMaterializer(IShifterContext context)
 {
     this.context = context;
 }