private void InitializeObject(IBuilderContext context, object existing, string id, ICreationPolicy policy) { Type type = existing.GetType(); ConstructorInfo constructor = policy.SelectConstructor(context, type, id); if (constructor == null) { if (type.IsValueType) { return; } throw new ArgumentException(Properties.Resources.NoAppropriateConstructor); } object[] parms = policy.GetParameters(context, type, id, constructor); MethodBase method = (MethodBase)constructor; Guard.ValidateMethodParameters(method, parms, existing.GetType()); if (TraceEnabled(context)) { TraceBuildUp(context, type, id, Properties.Resources.CallingConstructor, ParametersToTypeList(parms)); } method.Invoke(existing, parms); }
private static void InitializeObject(IBuilderContext context, object existing, string id, ICreationPolicy policy) { Type type = existing.GetType(); ConstructorInfo constructor = policy.SelectConstructor(context, type, id); if (constructor == null) { if (type.IsValueType) { return; } throw new ArgumentException(Resources.NoAppropriateConstructor); } object[] parms = policy.GetParameters(context, type, id, constructor); MethodBase method = (MethodBase)constructor; ValidateMethodParameters(method, parms, existing.GetType()); method.Invoke(existing, parms); }
private void InitializeObject(IBuilderContext context, object existing, string id, ICreationPolicy policy) { Type type = existing.GetType(); ConstructorInfo constructor = policy.SelectConstructor(context, type, id); if (constructor == null) { if (!type.IsValueType) { throw new ArgumentException(Resources.NoAppropriateConstructor); } } else { object[] parameters = policy.GetParameters(context, type, id, constructor); MethodBase methodInfo = constructor; Guard.ValidateMethodParameters(methodInfo, parameters, existing.GetType()); if (base.TraceEnabled(context)) { base.TraceBuildUp(context, type, id, Resources.CallingConstructor, new object[] { base.ParametersToTypeList(parameters) }); } methodInfo.Invoke(existing, parameters); } }
private static void InitializeObject(IBuilderContext context, object existing, string id, ICreationPolicy policy) { Type type = existing.GetType(); ConstructorInfo constructor = policy.SelectConstructor(context, type, id); if (constructor == null) { if (type.IsValueType) return; throw new ArgumentException(Resources.NoAppropriateConstructor); } object[] parms = policy.GetParameters(context, type, id, constructor); MethodBase method = (MethodBase) constructor; ValidateMethodParameters(method, parms, existing.GetType()); method.Invoke(existing, parms); }
private void InitializeObject(IBuilderContext context, object existing, string id, ICreationPolicy policy) { Type type = existing.GetType(); ConstructorInfo constructor = policy.SelectConstructor(context, type, id); if (constructor == null) { if (type.IsValueType) return; throw new ArgumentException(Properties.Resources.NoAppropriateConstructor); } object[] parms = policy.GetParameters(context, type, id, constructor); MethodBase method = (MethodBase)constructor; Guard.ValidateMethodParameters(method, parms, existing.GetType()); if (TraceEnabled(context)) TraceBuildUp(context, type, id, Properties.Resources.CallingConstructor, ParametersToTypeList(parms)); method.Invoke(existing, parms); }