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 PopuplateInstance(TypedPageData destination, string hierarchy) { Hierarchy = new PageTypePropertyGroupHierarchy { Value = hierarchy }; TypedPageData = destination; }
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); } }
private IEnumerable <PageTypePropertyDefinition> GetPropertyGroupPropertyDefinitions(IPageType pageType, PropertyInfo propertyGroupProperty) { PageTypePropertyGroupAttribute groupAttribute = GetPropertyAttribute <PageTypePropertyGroupAttribute>(propertyGroupProperty); PropertyInfo[] propertyGroupProperties = propertyGroupProperty.PropertyType.GetPublicOrPrivateProperties(); foreach (PropertyInfo property in propertyGroupProperties) { PageTypePropertyAttribute attribute = GetPropertyAttribute <PageTypePropertyAttribute>(property); if (attribute == null) { continue; } string resolvedPropertyName = PageTypePropertyGroupHierarchy.ResolvePropertyName(propertyGroupProperty.Name, property.Name); attribute = AdjustPropertyGroupAttributeProperties(attribute, groupAttribute); yield return(new PageTypePropertyDefinition(resolvedPropertyName, property.PropertyType, pageType, attribute)); } }