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 ChildElementDefinition(ElementDefinition elementDefinition, string containerProperty, Type containerPropertyType, StandardContainerMethod containerMethod) { ElementDefinition = elementDefinition; ContainerProperty = containerProperty; ContainerPropertyType = containerPropertyType; ContainerMethod = containerMethod; }
public ChildElementDefinition(ContainerElementDefinition containerElementDefinition, string containerProperty, Type containerPropertyType, StandardContainerMethod containerMethod) { ContainerElementName = containerElementDefinition.ElementName; ElementDefinition = containerElementDefinition.ChildDefinition; ContainerProperty = containerProperty; ContainerPropertyType = containerPropertyType; ContainerMethod = containerMethod; }