private void ProcessChildProperty(ChildElementDefinition childDefinition, PropertyInfo property, Type targetType, object target, object childObject) { _log.DebugFormat("ProcessChildProperty called; ElementName='{0}', Property={1}.", childDefinition.ElementDefinition.ElementName, property.Name); string containerMethod; if (childDefinition.ContainerMethod is StandardContainerMethod) { StandardContainerMethod method = (StandardContainerMethod)childDefinition.ContainerMethod; if (method == StandardContainerMethod.Assign) { SetPropertyValue(property, target, childObject); return; } else { containerMethod = Enum.GetName(typeof(StandardContainerMethod), childDefinition.ContainerMethod); } } else { containerMethod = childDefinition.ContainerMethod as string; } MethodInfo targetMethod = property.PropertyType.GetMethod(containerMethod, new Type[] { targetType }); if (targetMethod == null) { throw ThrowHelper.New <InternalErrorException>(this, InternalErrors.ContainerMethodNotFoundOnObject, containerMethod, targetType.FullName); } try { targetMethod.Invoke(property.GetValue(target, null), new object[] { childObject }); } catch (TargetInvocationException ex) { if (ex.InnerException != null) { throw ThrowHelper.Rethrow(this, ex.InnerException, ErrorMessages.UnableToInvokeMethodError, string.Format("the {0} method on the {1} property", containerMethod, property.Name)); } else { throw; } } }
public ElementDefinition(XName elementName, Type targetType, ConstructorParameter[] constructorParameters, ElementAttribute[] attributes, ChildElementDefinition child) : this(elementName, targetType, constructorParameters, attributes, new ChildElementDefinition[] { child }, null) { }
public ElementDefinition(XName elementName, Type targetType, ElementAttribute[] attributes, ChildElementDefinition child) : this(elementName, targetType, null, attributes, new ChildElementDefinition[] { child }, null) { }