Beispiel #1
0
        public DocumentNode EvaluateTemplateBinding(DocumentNodePath nodePath, DocumentCompositeNode templateBindingNode)
        {
            DocumentNode documentNode = null;
            DependencyPropertyReferenceStep member = null;
            DocumentPrimitiveNode           item   = templateBindingNode.Properties[KnownProperties.TemplateBindingPropertyProperty] as DocumentPrimitiveNode;

            if (item != null)
            {
                DocumentNodeMemberValue value = item.Value as DocumentNodeMemberValue;
                if (value != null)
                {
                    member = value.Member as DependencyPropertyReferenceStep;
                }
            }
            if (member != null)
            {
                DocumentNodePath containerOwnerPath = nodePath.GetContainerOwnerPath();
                if (containerOwnerPath != null)
                {
                    documentNode = this.EvaluateProperty(containerOwnerPath, member);
                    if (documentNode == null)
                    {
                        DocumentCompositeNode containerNode = nodePath.ContainerNode as DocumentCompositeNode;
                        documentNode = this.EvaluateProperty(nodePath.GetPathInContainer(containerNode), member);
                    }
                }
            }
            return(documentNode);
        }
Beispiel #2
0
        public DocumentPrimitiveNode CreateNode(ITypeId typeId, IDocumentNodeValue value)
        {
            typeId = (ITypeId)this.projectContext.ResolveType(typeId);
            DocumentNodeMemberValue documentNodeMemberValue = value as DocumentNodeMemberValue;

            if (documentNodeMemberValue != null)
            {
                IType       type       = documentNodeMemberValue.Member as IType;
                IPropertyId propertyId = documentNodeMemberValue.Member as IPropertyId;
                if (type != null)
                {
                    return(new DocumentPrimitiveNode((IDocumentContext)this, typeId, (IDocumentNodeValue) new DocumentNodeMemberValue((IMember)this.projectContext.ResolveType((ITypeId)type))));
                }
                if (propertyId != null)
                {
                    return(new DocumentPrimitiveNode((IDocumentContext)this, typeId, (IDocumentNodeValue) new DocumentNodeMemberValue((IMember)this.projectContext.ResolveProperty(propertyId))));
                }
            }
            return(new DocumentPrimitiveNode((IDocumentContext)this, typeId, value));
        }
Beispiel #3
0
        public static DocumentNode GetShadowPropertyNode(IInstanceBuilderContext context, ViewNode viewNode, IProperty propertyKey, DocumentNode valueNode)
        {
            IType valueAsType;
            DocumentNodeMemberValue value;
            ReferenceStep           member;

            if (!context.UseShadowProperties || propertyKey == null || !KnownProperties.SetterPropertyProperty.Equals(propertyKey))
            {
                return(null);
            }
            if (context.ContainerRoot == null || !PlatformTypes.Style.IsAssignableFrom(context.ContainerRoot.Type))
            {
                return(null);
            }
            DocumentCompositeNode documentNode = (DocumentCompositeNode)context.ContainerRoot.DocumentNode;
            DocumentPrimitiveNode item         = documentNode.Properties[KnownProperties.StyleTargetTypeProperty] as DocumentPrimitiveNode;

            if (item != null)
            {
                valueAsType = DocumentPrimitiveNode.GetValueAsType(item);
            }
            else
            {
                valueAsType = null;
            }
            IType type = valueAsType;

            if (type == null)
            {
                return(null);
            }
            DocumentPrimitiveNode documentPrimitiveNode = valueNode as DocumentPrimitiveNode;

            if (documentPrimitiveNode != null)
            {
                value = documentPrimitiveNode.Value as DocumentNodeMemberValue;
            }
            else
            {
                value = null;
            }
            DocumentNodeMemberValue documentNodeMemberValue = value;

            if (documentNodeMemberValue != null)
            {
                member = documentNodeMemberValue.Member as ReferenceStep;
            }
            else
            {
                member = null;
            }
            ReferenceStep referenceStep = member;

            if (referenceStep == null)
            {
                return(null);
            }
            if (context.RootTargetTypeReplacement != null)
            {
                ViewNode viewNode1 = StyleControlTemplateHelper.FindStyleTemplateOwningViewNode(viewNode);
                if (viewNode1 == null || viewNode1 == viewNode.ViewNodeManager.Root)
                {
                    IProperty replacementProperty = context.RootTargetTypeReplacement.GetReplacementProperty(referenceStep);
                    if (replacementProperty != null && replacementProperty != referenceStep)
                    {
                        return(context.DocumentContext.CreateNode(valueNode.Type, new DocumentNodeMemberValue(replacementProperty)));
                    }
                }
            }
            IProperty shadowProperty = DesignTimeProperties.GetShadowProperty(referenceStep, type);

            if (shadowProperty == null)
            {
                return(null);
            }
            if (!DesignTimeProperties.UseShadowPropertyForInstanceBuilding(context.DocumentContext.TypeResolver, shadowProperty))
            {
                return(null);
            }
            DocumentPrimitiveNode documentPrimitiveNode1 = context.DocumentContext.CreateNode(valueNode.Type, new DocumentNodeMemberValue(shadowProperty));

            return(documentPrimitiveNode1);
        }