public IServiceRegistration Complete <TService, TImplementation>() where TImplementation : TService { this.container.Register <TService, TImplementation>(serviceKey: this.currentServiceName, made: Made.Of(parameters: this.currentParameterSelector, propertiesAndFields: this.currentPropertiesSelector)); this.currentServiceName = null; this.currentParameterSelector = null; this.currentPropertiesSelector = null; return(this); }
public IDipendencyRegistration InjectProperty(string propertyName, Type type) { if (this.currentPropertiesSelector == null) { this.currentPropertiesSelector = PropertiesAndFields.Of.Name(propertyName, type); } else { this.currentPropertiesSelector = PropertiesAndFields.Of.Name(propertyName, type).And(this.currentPropertiesSelector); } return(this); }
public IDipendencyRegistration InjectProperty <TProperty>(string propertyName, TProperty value) { string serviceKey = string.Format("{0}{1}", this.currentServiceName, propertyName); if (this.currentPropertiesSelector == null) { this.currentPropertiesSelector = PropertiesAndFields.Of.Name(propertyName, serviceKey: serviceKey); } else { this.currentPropertiesSelector = PropertiesAndFields.Of.Name(propertyName, serviceKey: serviceKey).And(this.currentPropertiesSelector); } this.container.RegisterInstance(value, serviceKey: serviceKey); return(this); }
public void Registration(IEnumerable <RegistrationDefinition> definitions) { foreach (var definition in definitions) { IReuse reuse = null; switch (definition.RegistrationLifestyle) { case RegistrationLifestyle.Singleton: reuse = new SingletonReuse(); break; case RegistrationLifestyle.SingletonPerScope: reuse = new CurrentScopeReuse(); break; } PropertiesAndFieldsSelector madeOf = null; if (definition.MemberInjectionList != null) { madeOf = PropertiesAndFields.Of; foreach (var injectionInfo in definition.MemberInjectionList) { switch (injectionInfo.InjectionType) { case MemberInjectionType.Field: case MemberInjectionType.Property: madeOf = madeOf.Name(injectionInfo.MemberName); break; case MemberInjectionType.Method: throw new NotSupportedException(); } } } _container.Register(definition.ExportType, definition.ActivationType, reuse, madeOf); } }
public object InjectPropertiesAndFields(object instance, PropertiesAndFieldsSelector propertiesAndFields) { throw new NotImplementedException(); }