public bool ReadyToBuild(IObjectBuildContext ctx) { Type targetType = (ctx.ComponentType != null) ? ctx.ComponentType : ctx.ServiceType; IReflector r = Reflector.Bind(targetType, ReflectorPolicy.TypePublic); return(PolicyUtility.IsReady(_propertyValue, r.GetPropertyType(_propertyName), ctx)); }
public void BuildUp(IObjectBuildContext ctx) { if (ctx.SkipInitializationPolicy) { return; } IReflector r = Reflector.Bind(ctx.Instance); object val = PolicyUtility.Build(_propertyValue, r.GetPropertyType(_propertyName), ctx); r.SetPropertyValue(_propertyName, val); }
protected object[] PrepareArgs(IObjectBuildContext ctx, MethodBase method) { ParameterInfo[] pInfos = method.GetParameters(); object[] args = new object[pInfos.Length]; string val; for (int idx = 0; idx < args.Length; idx++) { ParameterInfo pInfo = pInfos[idx]; bool hint = _injectionHints.TryGetValue(pInfo.Name, out val); if (!hint && pInfo.IsOptional) { args[idx] = pInfo.DefaultValue; } else { args[idx] = PolicyUtility.Build(val, pInfo.ParameterType, ctx); } } return(args); }
protected bool IsReady(MethodBase method, IObjectBuildContext ctx) { foreach (ParameterInfo pInfo in method.GetParameters()) { string key = pInfo.Name; if ((!_injectionHints.ContainsKey(key)) && pInfo.IsOptional) { continue; } else { string val = null; _injectionHints.TryGetValue(key, out val); if (!PolicyUtility.IsReady(val, pInfo.ParameterType, ctx)) { return(false); } } } return(true); }