public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context) { // get page of context var parent = context.Parent; while (!parent.IsPage) { if (parent.Parent == null) { return(AllowedDefinitionResult.Deny); } parent = parent.Parent; } var parentType = parent.GetType(); if (ChildType.IsAssignableFrom(context.ChildDefinition.ItemType)) { if (Attribute.Types != null && !Attribute.Types.Any(t => t.IsAssignableFrom(parentType))) { //Trace.TraceInformation(context.ChildDefinition.ItemType.Name + " denied on " + parentType.Name); return(AllowedDefinitionResult.Deny); } //if (this.Attribute.TemplateKeys != null && !this.Attribute.TemplateKeys.Contains(context.ParentDefinition.TemplateKey)) // return AllowedDefinitionResult.Deny; } return(AllowedDefinitionResult.DontCare); }
public AllowedDefinitionResult IsAllowed(AllowedDefinitionQuery context) { if (ChildType.IsAssignableFrom(context.ChildDefinition.ItemType)) { if (this.Attribute.Types != null && !this.Attribute.Types.Any(t => t.IsAssignableFrom(context.ParentDefinition.ItemType))) { return(AllowedDefinitionResult.Deny); } if (this.Attribute.TemplateKeys != null && !this.Attribute.TemplateKeys.Contains(context.ParentDefinition.TemplateKey)) { return(AllowedDefinitionResult.Deny); } } return(AllowedDefinitionResult.DontCare); }