/// <summary> /// Checks that templates are valid for blocks. /// </summary> /// <param name="blockTemplateTable">Table of templates.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> public virtual bool IsBlockValid(IFrameTemplateReadOnlyDictionary blockTemplateTable, IFrameTemplateReadOnlyDictionary nodeTemplateTable) { Debug.Assert(blockTemplateTable != null); List <Type> BlockKeys = new List <Type>(NodeHelper.CreateNodeDictionary <object>().Keys); IFrameTemplateDictionary DefaultDictionary = CreateEmptyTemplateDictionary(); foreach (Type Key in BlockKeys) { AddBlockNodeTypes(DefaultDictionary, Key); } bool IsValid = true; foreach (KeyValuePair <Type, IFrameTemplate> Entry in DefaultDictionary) { IsValid &= blockTemplateTable.ContainsKey(Entry.Key); } foreach (KeyValuePair <Type, IFrameTemplate> Entry in blockTemplateTable) { Type NodeType = Entry.Key; IFrameTemplate Template = Entry.Value; int CommentFrameCount = 0; IsValid &= NodeTreeHelper.IsBlockType(NodeType); IsValid &= Template.IsValid; IsValid &= Template.Root.IsValid(NodeType, nodeTemplateTable, ref CommentFrameCount); } Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that templates are valid for nodes. /// </summary> /// <param name="nodeTemplateTable">Table of templates.</param> public virtual bool IsValid(IFrameTemplateReadOnlyDictionary nodeTemplateTable) { Debug.Assert(nodeTemplateTable != null); IFrameTemplateDictionary DefaultDictionary = CreateDefaultTemplateDictionary(); bool IsValid = true; foreach (KeyValuePair <Type, IFrameTemplate> Entry in DefaultDictionary) { IsValid &= nodeTemplateTable.ContainsKey(Entry.Key); } foreach (KeyValuePair <Type, IFrameTemplate> Entry in nodeTemplateTable) { Type NodeType = Entry.Key; IFrameTemplate Template = Entry.Value; int CommentFrameCount = 0; IsValid &= Template.IsValid; IsValid &= IsValidNodeType(NodeType, Template.NodeType); IsValid &= Template.Root.IsValid(NodeType, nodeTemplateTable, ref CommentFrameCount); IsValid &= CommentFrameCount == 1; Debug.Assert(IsValid); } Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Initializes a new instance of the <see cref="FrameTemplateSet"/> class. /// </summary> /// <param name="nodeTemplateTable">Templates for nodes by their type.</param> /// <param name="blockTemplateTable">Templates for blocks of nodes.</param> public FrameTemplateSet(IFrameTemplateReadOnlyDictionary nodeTemplateTable, IFrameTemplateReadOnlyDictionary blockTemplateTable) { Debug.Assert(IsValid(nodeTemplateTable)); Debug.Assert(IsBlockValid(blockTemplateTable, nodeTemplateTable)); NodeTemplateTable = nodeTemplateTable; BlockTemplateTable = blockTemplateTable; }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= !string.IsNullOrEmpty(Text); Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= Visibility == null || Visibility.IsValid(nodeType); Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= NodeTreeHelperChild.IsChildNodeProperty(nodeType, PropertyName, out Type ChildNodeType); Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= !string.IsNullOrEmpty(PropertyName) && NodeTreeHelper.GetPropertyOf(nodeType, PropertyName) != null; Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= !HasBlockGeometry || (ParentTemplate is ILayoutBlockTemplate); IsValid &= !HasBlockGeometry || (ParentFrame.ParentTemplate == null); Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public virtual bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= Content != null; IsValid &= !string.IsNullOrEmpty(Name); IsValid &= ParentFrame is IFocusSelectionFrame; IsValid &= Content.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); foreach (ILayoutKeywordFrame Item in Items) { IsValid &= (Item.LeftMargin == Margins.None) && (Item.RightMargin == Margins.None); } Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); foreach (IFocusFrameSelector Selector in Selectors) { IsValid &= Selector.IsValid(nodeType, (IFocusTemplateReadOnlyDictionary)nodeTemplateTable, nameof(BaseNode.IBlock.NodeList)); } Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= Visibility == null || Visibility.IsValid(nodeType); foreach (IFocusFrameSelector Selector in Selectors) { IsValid &= Selector.IsValid(nodeType, (IFocusTemplateReadOnlyDictionary)nodeTemplateTable, PropertyName); } Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= Items != null && Items.Count > 0; foreach (IFrameFrame Item in Items) { IsValid &= Item.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); } Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= Visibility == null || Visibility.IsValid(nodeType); IsValid &= BlockVisibility == null || BlockVisibility.IsValid(nodeType); #if DEBUG // For code coverage purpose. CollectSelectors(new Dictionary <string, IFocusFrameSelectorList>()); #endif Debug.Assert(IsValid); return(IsValid); }
private protected virtual IFrameTemplateSet BuildDefault() { if (_Default != null && _Default.GetType() == GetType()) // Recreate the default if the layer has changed. { return(_Default); } IFrameTemplateReadOnlyDictionary DefaultNodeTemplateTable = BuildDefaultNodeTemplateTable(); IFrameTemplateReadOnlyDictionary DefaultBlockTemplateTable = BuildDefaultBlockListTemplate(); Debug.Assert(IsValid(DefaultNodeTemplateTable)); Debug.Assert(IsBlockValid(DefaultBlockTemplateTable, DefaultNodeTemplateTable)); _Default = CreateDefaultTemplateSet(DefaultNodeTemplateTable, DefaultBlockTemplateTable); return(_Default); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= Items != null && Items.Count > 0; IsValid &= NodeTreeHelper.IsEnumProperty(nodeType, PropertyName) || NodeTreeHelper.IsBooleanProperty(nodeType, PropertyName); NodeTreeHelper.GetEnumRange(nodeType, PropertyName, out int Min, out int Max); IsValid &= Min == 0; IsValid &= Max + 1 == Items.Count; foreach (IFrameKeywordFrame Item in Items) { IsValid &= Item.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); } Debug.Assert(IsValid); return(IsValid); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { bool IsValid = true; IsValid &= base.IsValid(nodeType, nodeTemplateTable, ref commentFrameCount); IsValid &= Items.Count > 0; IsValid &= IsParentRoot; List <string> NameList = new List <string>(); int SelectionCommentFrameCount = -1; List <Dictionary <string, IFocusFrameSelectorList> > SelectorTableList = new List <Dictionary <string, IFocusFrameSelectorList> >(); Dictionary <string, IFocusFrameSelectorList> SelectorTable; foreach (IFocusSelectableFrame Item in Items) { int SelectableCommentFrameCount = 0; IsValid &= Item.IsValid(nodeType, nodeTemplateTable, ref SelectableCommentFrameCount); IsValid &= !NameList.Contains(Item.Name); // Use the count for the first frame as base count. if (SelectionCommentFrameCount < 0) { SelectionCommentFrameCount = SelectableCommentFrameCount; } // All selectable frames must have the same count. IsValid &= SelectionCommentFrameCount == SelectableCommentFrameCount; NameList.Add(Item.Name); SelectorTable = new Dictionary <string, IFocusFrameSelectorList>(); Item.CollectSelectors(SelectorTable); SelectorTableList.Add(SelectorTable); } // Use the common count of all selectable frames as the count of the selection frame. commentFrameCount += SelectionCommentFrameCount; // Check that all selectable have the same nested selectors. See FrameSelectorForProperty(). SelectorTable = new Dictionary <string, IFocusFrameSelectorList>(); CollectSelectors(SelectorTable); Debug.Assert(SelectorTable.Count == 0); List <string> PropertyNameList = new List <string>(); foreach (Dictionary <string, IFocusFrameSelectorList> Table in SelectorTableList) { foreach (KeyValuePair <string, IFocusFrameSelectorList> Entry in Table) { if (!PropertyNameList.Contains(Entry.Key)) { PropertyNameList.Add(Entry.Key); } } } foreach (string PropertyName in PropertyNameList) { List <IFocusFrameSelectorList> TableWithPropertyList = new List <IFocusFrameSelectorList>(); foreach (Dictionary <string, IFocusFrameSelectorList> Table in SelectorTableList) { if (Table.ContainsKey(PropertyName)) { TableWithPropertyList.Add(Table[PropertyName]); } } Debug.Assert(TableWithPropertyList.Count > 0); IFocusFrameSelectorList FirstItem = TableWithPropertyList[0]; CompareEqual Comparer = CompareEqual.New(canReturnFalse: true); for (int i = 1; i < TableWithPropertyList.Count; i++) { IsValid &= FirstItem.IsEqual(Comparer, TableWithPropertyList[i]); } } Debug.Assert(IsValid); return(IsValid); }
public bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount) { return(false); }
/// <summary> /// Creates a IxxxTemplateSet object. /// </summary> private protected override IFrameTemplateSet CreateDefaultTemplateSet(IFrameTemplateReadOnlyDictionary nodeTemplateTable, IFrameTemplateReadOnlyDictionary blockTemplateTable) { ControllerTools.AssertNoOverride(this, typeof(LayoutTemplateSet)); return(new LayoutTemplateSet((ILayoutTemplateReadOnlyDictionary)nodeTemplateTable, (ILayoutTemplateReadOnlyDictionary)blockTemplateTable)); }
/// <summary> /// Checks that a frame is correctly constructed. /// </summary> /// <param name="nodeType">Type of the node this frame can describe.</param> /// <param name="nodeTemplateTable">Table of templates with all frames.</param> /// <param name="commentFrameCount">Number of comment frames found so far.</param> public abstract override bool IsValid(Type nodeType, IFrameTemplateReadOnlyDictionary nodeTemplateTable, ref int commentFrameCount);