/// <summary>
        /// Checks that templates are valid for nodes.
        /// </summary>
        /// <param name="nodeTemplateTable">Table of templates.</param>
        public virtual bool IsValid(FrameTemplateReadOnlyDictionary nodeTemplateTable)
        {
            Contract.RequireNotNull(nodeTemplateTable, out FrameTemplateReadOnlyDictionary NodeTemplateTable);

            FrameTemplateDictionary 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>
        /// Template that will be used to describe the given node.
        /// </summary>
        /// <param name="nodeType">Type of the node for which a template is requested.</param>
        public virtual IFrameNodeTemplate NodeTypeToTemplate(Type nodeType)
        {
            Contract.RequireNotNull(nodeType, out Type NodeType);
            Debug.Assert(NodeTemplateTable.ContainsKey(NodeType));

            return(NodeTemplateTable[NodeType] as IFrameNodeTemplate);
        }
Пример #3
0
        /// <summary>
        /// Template that will be used to describe the given node.
        /// </summary>
        /// <param name="nodeType">Type of the node for which a template is requested.</param>
        public virtual IFrameNodeTemplate NodeTypeToTemplate(Type nodeType)
        {
            Debug.Assert(nodeType != null);
            Debug.Assert(NodeTemplateTable.ContainsKey(nodeType));

            return(NodeTemplateTable[nodeType] as IFrameNodeTemplate);
        }