Esempio n. 1
0
        /// <summary>
        /// Checks that a frame selector is correctly constructed.
        /// </summary>
        /// <param name="nodeType">Type of the node this frame selector can describe.</param>
        /// <param name="nodeTemplateTable">Table of templates with all frames.</param>
        /// <param name="propertyName">The property for which frames can be selected.</param>
        public virtual bool IsValid(Type nodeType, FocusTemplateReadOnlyDictionary nodeTemplateTable, string propertyName)
        {
            bool IsValid = true;

            IsValid &= SelectorType != Type.Missing;
            IsValid &= !string.IsNullOrEmpty(SelectorName);

            Type ChildInterfaceType, ChildNodeType;

            IsValid &= NodeTreeHelperChild.IsChildNodeProperty(nodeType, propertyName, out ChildInterfaceType) ||
                       NodeTreeHelperOptional.IsOptionalChildNodeProperty(nodeType, propertyName, out ChildInterfaceType) ||
                       NodeTreeHelperList.IsNodeListProperty(nodeType, propertyName, out ChildInterfaceType) ||
                       NodeTreeHelperBlockList.IsBlockListProperty(nodeType, propertyName, /*out ChildInterfaceType,*/ out ChildNodeType) ||
                       (NodeTreeHelper.IsBlockType(nodeType) && propertyName == nameof(BaseNode.IBlock.NodeList));

            IsValid &= nodeTemplateTable.ContainsKey(SelectorType);

            IFocusNodeTemplate Template = nodeTemplateTable[SelectorType] as IFocusNodeTemplate;

            Debug.Assert(Template != null);

            IFocusSelectionFrame AsSelectionFrame = Template.Root as IFocusSelectionFrame;

            IsValid &= AsSelectionFrame != null;

            if (IsValid)
            {
                IFocusSelectableFrame SelectedItem = null;
                foreach (IFocusSelectableFrame Item in AsSelectionFrame.Items)
                {
                    if (Item.Name == SelectorName)
                    {
                        SelectedItem = Item;
                        break;
                    }
                }

                IsValid &= SelectedItem != null;
            }

            Debug.Assert(IsValid);
            return(IsValid);
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FocusTemplateSet"/> class.
 /// </summary>
 /// <param name="nodeTemplateTable">Templates for nodes by their type.</param>
 /// <param name="blockTemplateTable">Templates for blocks of nodes.</param>
 public FocusTemplateSet(FocusTemplateReadOnlyDictionary nodeTemplateTable, FocusTemplateReadOnlyDictionary blockTemplateTable)
     : base(nodeTemplateTable, blockTemplateTable)
 {
 }