public void Intercept(IInvocation invocation) { TypedPageData page; string propertyName = invocation.Method.GetPropertyName(); if (invocation.InvocationTarget is PageTypePropertyGroup) { PageTypePropertyGroup propertyGroup = invocation.InvocationTarget as PageTypePropertyGroup; propertyName = PageTypePropertyGroupHierarchy.ResolvePropertyName(propertyGroup.Hierarchy.Value, propertyName); page = propertyGroup.TypedPageData; } else { page = invocation.InvocationTarget as TypedPageData; } 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]); } }
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); } }