Example #1
0
        public override void Repair(DocumentNode node)
        {
            DocumentCompositeNode compositeNode = node as DocumentCompositeNode;
            IType codeBehindClass = this.stateNameChangeModel.ChangedNode.ViewModel.XamlDocument.CodeBehindClass;

            if (compositeNode == null)
            {
                return;
            }
            string       valueAsString = compositeNode.GetValueAsString(this.referentialProperty);
            DocumentNode targetElement = GoToStateActionNode.FindTargetElement(node, false);

            if (targetElement == null || !(this.stateNameChangeModel.OldReferenceValue == valueAsString))
            {
                return;
            }
            if (targetElement.DocumentRoot.CodeBehindClass == null && codeBehindClass == null || targetElement.DocumentRoot.CodeBehindClass.Equals((object)codeBehindClass) && targetElement.DocumentRoot.RootNode == this.stateNameChangeModel.ChangedNode.DocumentNode.DocumentRoot.RootNode)
            {
                this.stateNameChangeModel.NodesForLocalUpdate.Add((ChangedNodeInfo) new ChangedStateNameNodeInfo(compositeNode, this.referentialProperty));
            }
            else
            {
                if (codeBehindClass == null || !targetElement.Type.IsAssignableFrom((ITypeId)codeBehindClass))
                {
                    return;
                }
                this.stateNameChangeModel.NodesForExternalUpdate.Add((ChangedNodeInfo) new ChangedStateNameNodeInfo(compositeNode, this.referentialProperty));
            }
        }
Example #2
0
        public override bool Verify(DocumentNode node)
        {
            DocumentCompositeNode compositeNode = node as DocumentCompositeNode;

            if (this.builder == null)
            {
                this.builder = new StateNameBuilder(this.designerContext);
                this.builder.Begin();
            }
            if (compositeNode != null)
            {
                string        referentialPropertyValue = this.GetReferentialPropertyValue(compositeNode);
                DocumentNode  targetElement            = GoToStateActionNode.FindTargetElement(node, true);
                List <string> results;
                if (targetElement != null && (DocumentNodeUtilities.IsBinding(targetElement) && !GoToStateActionNode.CanResolveTargetFromBinding(targetElement) || Enumerable.Contains <string>(this.builder.GetStateNamesForNode(targetElement), referentialPropertyValue) || PlatformNeutralAttributeHelper.TryGetAttributeValues <string>((IEnumerable)TypeUtilities.GetAttributes(targetElement.TargetType), ProjectNeutralTypes.TemplateVisualStateAttribute, "Name", out results) && results.Contains(referentialPropertyValue)))
                {
                    return(true);
                }
            }
            return(false);
        }