public ReducerSection(IActivator activator, ITypeRequest subReducer, Expression <StateSubSectionSelectionDelegate <TState, TSectionType> > sectionSelector) { m_sectionSelector = sectionSelector; m_sectionReducer = activator.Get <IReducer <TSectionType> >(subReducer); MemberExpression memberExpression = (MemberExpression)sectionSelector.Body; PropertyInfo propertyInfo = (PropertyInfo)memberExpression.Member; if (!propertyInfo.CanWrite || !propertyInfo.CanRead) { throw new NotAccessableSubSectionProperty($"The property {propertyInfo.Name} is being used as a Sub Section reducer however it is an invalid target. Any property used *MUST* be both to be able to be read and written to."); } m_getValue = (GetterDelegate)Delegate.CreateDelegate(typeof(GetterDelegate), propertyInfo.GetMethod); m_setValue = (SetterDelegate)Delegate.CreateDelegate(typeof(SetterDelegate), propertyInfo.SetMethod); }
/// <summary> /// The default activation implemention that can be overridden by the end users. It is however always /// used at least once to create the first activator. /// </summary> /// <param name="type">The type wanting to be created</param> /// <param name="activationInfo">The type activation info</param> /// <returns>The created instance</returns> internal static object Get(ITypeRequest typeRequest, IEnumerable <IParameter> addtionalParameters = null) { if (typeRequest == null) { throw new ArgumentNullException(nameof(typeRequest)); } List <IParameter> parameters = new List <IParameter>(typeRequest.Parameters); if (addtionalParameters != null) { parameters.AddRange(addtionalParameters); } object instance = Construct(typeRequest.Type, parameters); return(instance); }
/// <summary> /// The default activation implemention that can be overridden by the end users. It is however always /// used at least once to create the first activator. /// </summary> /// <param name="type">The type wanting to be created</param> /// <param name="activationInfo">The type activation info</param> /// <returns>The created instance</returns> internal static T Get <T>(ITypeRequest typeRequest, IEnumerable <IParameter> addtionalParameters = null) => (T)Get(typeRequest, addtionalParameters);
/// <inheritdoc cref="IActivator"/> object IActivator.Get(ITypeRequest typeRequest, IEnumerable <IParameter> addtionalParameters = null) => Get(typeRequest, addtionalParameters);