public virtual TypedPageData CreateAndPopulateTypedInstance(PageData originalPage, Type typedType) { TypedPageData typedPage = CreateInstance(typedType); TypedPageData.PopuplateInstance(originalPage, typedPage); return(typedPage); }
internal void PopuplateInstance(TypedPageData destination, string hierarchy) { Hierarchy = new PageTypePropertyGroupHierarchy { Value = hierarchy }; TypedPageData = destination; }
public virtual TypedPageData CreateAndPopulateTypedInstance(PageData originalPage, Type typedType) { TypedPageData typedPage = CreateInstance(typedType); TypedPageData.PopuplateInstance(originalPage, typedPage); PropertyInfo[] properties = typedPage.GetType().GetPublicOrPrivateProperties(); CreateAndPopulateNestedPropertyGroupInstances(typedPage, typedPage, properties, string.Empty); return(typedPage); }
private void CreateAndPopulateNestedPropertyGroupInstances(TypedPageData typedPage, object classInstance, IEnumerable<PropertyInfo> properties, string hierarchy) { foreach (PropertyInfo property in properties.Where(current => current.PropertyType.BaseType == typeof(PageTypePropertyGroup))) { PageTypePropertyGroup propertyGroup = CreatePropertyGroupInstance(property.PropertyType); string propertyName = PageTypePropertyGroupHierarchy.ResolvePropertyName(hierarchy, property.Name); propertyGroup.PopuplateInstance(typedPage, propertyName); property.SetValue(classInstance, propertyGroup, null); } }
internal void CreateAndPopulateNestedPropertyGroupInstances(TypedPageData typedPage, object classInstance, IEnumerable <PropertyInfo> properties, string hierarchy) { foreach (PropertyInfo property in properties.Where(current => current.PropertyType.BaseType == typeof(PageTypePropertyGroup))) { PageTypePropertyGroup propertyGroup = CreatePropertyGroupInstance(property.PropertyType); string propertyName = PageTypePropertyGroupHierarchy.ResolvePropertyName(hierarchy, property.Name); propertyGroup.PopuplateInstance(typedPage, propertyName); property.SetValue(classInstance, propertyGroup, null); } }
public void Intercept(IInvocation invocation) { TypedPageData page = (TypedPageData)invocation.InvocationTarget; string propertyName = invocation.Method.GetPropertyName(); if (invocation.Method.IsGetter()) { invocation.ReturnValue = page[propertyName]; if (invocation.ReturnValue == null && invocation.Method.ReturnType == typeof(bool)) { invocation.ReturnValue = false; } } else { page.SetValue(propertyName, invocation.Arguments[0]); } }