/// <exclude /> protected override void OnInitialize() { if (!typeof(IData).IsAssignableFrom(this.InterfaceType)) { AddValidationError("TreeValidationError.Common.NotImplementingIData", this.InterfaceType, typeof(IData)); return; } IEnumerable <Type> siblingInterfaceTypes = this.ParentNode.ChildNodes.Where(f => f.GetType() == typeof(DataElementsTreeNode)).Select(f => ((DataElementsTreeNode)f).InterfaceType).ToList(); if (siblingInterfaceTypes.Count() != siblingInterfaceTypes.Distinct().Count()) { AddValidationError("TreeValidationError.DataElementsTreeNode.SameInterfaceUsedTwice", this.InterfaceType); return; } this.KeyPropertyInfo = this.CurrentDataInterfaceType.GetKeyProperties()[0]; foreach (ParentIdFilterNode parentIdFilterNode in this.FilterNodes.OfType <ParentIdFilterNode>()) { if (this.ParentFilteringHelpers == null) { this.ParentFilteringHelpers = new Dictionary <Type, ParentFilterHelper>(); } if (this.ParentFilteringHelpers.ContainsKey(parentIdFilterNode.ParentFilterType)) { AddValidationError("TreeValidationError.DataElementsTreeNode.SameParentFilterInterfaceUsedTwice", parentIdFilterNode.ParentFilterType); return; } var helper = new ParentFilterHelper { ParentIdFilterNode = parentIdFilterNode, ParentReferencedPropertyInfo = this.InterfaceType.GetPropertiesRecursively().Single(f => f.Name == parentIdFilterNode.ReferenceFieldName), ParentRefereePropertyName = parentIdFilterNode.ParentFilterType.GetKeyProperties()[0].Name }; this.ParentFilteringHelpers.Add(parentIdFilterNode.ParentFilterType, helper); } this.JoinParentIdFilterNode = null; this.JoinDataElementsTreeNode = null; foreach (TreeNode descendantTreeNode in this.DescendantsBreadthFirst()) { var dataElementTreeNode = descendantTreeNode as DataElementsTreeNode; if (dataElementTreeNode == null) { continue; } ParentIdFilterNode parentIdFilterNode = dataElementTreeNode.FilterNodes.OfType <ParentIdFilterNode>() .FirstOrDefault(f => f.ParentFilterType == this.InterfaceType); if (parentIdFilterNode != null) { if (this.JoinParentIdFilterNode == null) { this.JoinParentIdFilterNode = parentIdFilterNode; this.JoinDataElementsTreeNode = dataElementTreeNode; this.JoinInnerKeyReferencePropertyInfo = this.JoinDataElementsTreeNode.CurrentDataInterfaceType.GetAllProperties().Single(f => f.Name == this.JoinParentIdFilterNode.ReferenceFieldName); } else if (this.Display != LeafDisplayMode.Lazy) { AddValidationError("TreeValidationError.DataElementsTreeNode.MoreThanOnParentFilterIsPointingToMe", this.InterfaceType); return; } } } if (this.Label != null) { this.LabelDynamicValuesHelper = new DynamicValuesHelper(this.Label); this.LabelDynamicValuesHelper.Initialize(this); } if (this.ToolTip != null) { this.ToolTipDynamicValuesHelper = new DynamicValuesHelper(this.ToolTip); this.ToolTipDynamicValuesHelper.Initialize(this); } if (!typeof(ILocalizedControlled).IsAssignableFrom(this.InterfaceType)) { this.ShowForeignItems = false; } }
/// <exclude /> protected override void OnInitialize() { if (!typeof(IData).IsAssignableFrom(this.InterfaceType)) { AddValidationError("TreeValidationError.Common.NotImplementingIData", this.InterfaceType, typeof(IData)); return; } IEnumerable<Type> siblingInterfaceTypes = this.ParentNode.ChildNodes.Where(f => f.GetType() == typeof(DataElementsTreeNode)).Select(f => ((DataElementsTreeNode)f).InterfaceType).ToList(); if (siblingInterfaceTypes.Count() != siblingInterfaceTypes.Distinct().Count()) { AddValidationError("TreeValidationError.DataElementsTreeNode.SameInterfaceUsedTwice", this.InterfaceType); return; } this.KeyPropertyInfo = this.CurrentDataInterfaceType.GetKeyProperties()[0]; foreach (ParentIdFilterNode parentIdFilterNode in this.FilterNodes.OfType<ParentIdFilterNode>()) { if (this.ParentFilteringHelpers == null) this.ParentFilteringHelpers = new Dictionary<Type, ParentFilterHelper>(); if (this.ParentFilteringHelpers.ContainsKey(parentIdFilterNode.ParentFilterType)) { AddValidationError("TreeValidationError.DataElementsTreeNode.SameParentFilterInterfaceUsedTwice", parentIdFilterNode.ParentFilterType); return; } var helper = new ParentFilterHelper { ParentIdFilterNode = parentIdFilterNode, ParentReferencedPropertyInfo = this.InterfaceType.GetPropertiesRecursively().Single(f => f.Name == parentIdFilterNode.ReferenceFieldName), ParentRefereePropertyName = parentIdFilterNode.ParentFilterType.GetKeyProperties()[0].Name }; this.ParentFilteringHelpers.Add(parentIdFilterNode.ParentFilterType, helper); } this.JoinParentIdFilterNode = null; this.JoinDataElementsTreeNode = null; foreach (TreeNode descendantTreeNode in this.DescendantsBreadthFirst()) { var dataElementTreeNode = descendantTreeNode as DataElementsTreeNode; if (dataElementTreeNode == null) continue; ParentIdFilterNode parentIdFilterNode = dataElementTreeNode.FilterNodes.OfType<ParentIdFilterNode>() .FirstOrDefault(f => f.ParentFilterType == this.InterfaceType); if (parentIdFilterNode != null) { if (this.JoinParentIdFilterNode == null) { this.JoinParentIdFilterNode = parentIdFilterNode; this.JoinDataElementsTreeNode = dataElementTreeNode; this.JoinInnerKeyReferencePropertyInfo = this.JoinDataElementsTreeNode.CurrentDataInterfaceType.GetAllProperties().Single(f => f.Name == this.JoinParentIdFilterNode.ReferenceFieldName); } else if (this.Display != LeafDisplayMode.Lazy) { AddValidationError("TreeValidationError.DataElementsTreeNode.MoreThanOnParentFilterIsPointingToMe", this.InterfaceType); return; } } } if (this.Label != null) { this.LabelDynamicValuesHelper = new DynamicValuesHelper(this.Label); this.LabelDynamicValuesHelper.Initialize(this); } if (this.ToolTip != null) { this.ToolTipDynamicValuesHelper = new DynamicValuesHelper(this.ToolTip); this.ToolTipDynamicValuesHelper.Initialize(this); } if (!typeof(ILocalizedControlled).IsAssignableFrom(this.InterfaceType)) { this.ShowForeignItems = false; } }