Exemplo n.º 1
0
        private static bool SearchForAnimationsInTriggers(DocumentCompositeNode elementNode, IPropertyId triggersProperty, DocumentNode pathNameNode)
        {
            bool      flag;
            IProperty property = elementNode.Context.TypeResolver.ResolveProperty(triggersProperty);

            if (property != null)
            {
                DocumentCompositeNode item = elementNode.Properties[property] as DocumentCompositeNode;
                if (item != null && item.Children != null)
                {
                    using (IEnumerator <DocumentNode> enumerator = item.FindPointAnimationDescendantNodes().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            if (!PathGeometrySerializationHelper.DoesAnimationTargetPath(pathNameNode, enumerator.Current))
                            {
                                continue;
                            }
                            flag = true;
                            return(flag);
                        }
                        return(false);
                    }
                    return(flag);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
        private static bool SearchForAnimationsInVisualStateGroups(DocumentCompositeNode elementNode, DocumentNode pathNameNode)
        {
            bool        flag;
            IPropertyId member   = (IPropertyId)ProjectNeutralTypes.VisualStateManager.GetMember(MemberType.AttachedProperty, "VisualStateGroups", MemberAccessTypes.Public);
            IProperty   property = elementNode.Context.TypeResolver.ResolveProperty(member);

            if (property != null)
            {
                DocumentCompositeNode item = elementNode.Properties[property] as DocumentCompositeNode;
                if (item != null && item.Children != null)
                {
                    using (IEnumerator <DocumentNode> enumerator = item.FindPointAnimationDescendantNodes().GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            if (!PathGeometrySerializationHelper.DoesAnimationTargetPath(pathNameNode, enumerator.Current))
                            {
                                continue;
                            }
                            flag = true;
                            return(flag);
                        }
                        return(false);
                    }
                    return(flag);
                }
            }
            return(false);
        }
Exemplo n.º 3
0
 private static bool SearchForAnimationsAtElement(DocumentCompositeNode currentElement, DocumentNode pathNameNode)
 {
     if (PlatformTypes.ControlTemplate.IsAssignableFrom(currentElement.Type))
     {
         if (PathGeometrySerializationHelper.SearchForAnimationsInResources(currentElement, pathNameNode))
         {
             return(true);
         }
         if (PathGeometrySerializationHelper.SearchForAnimationsInTriggers(currentElement, KnownProperties.ControlTemplateTriggersProperty, pathNameNode))
         {
             return(true);
         }
     }
     else if (PlatformTypes.FrameworkElement.IsAssignableFrom(currentElement.Type))
     {
         if (PathGeometrySerializationHelper.SearchForAnimationsInResources(currentElement, pathNameNode))
         {
             return(true);
         }
         if (PathGeometrySerializationHelper.SearchForAnimationsInTriggers(currentElement, KnownProperties.FrameworkElementTriggersProperty, pathNameNode))
         {
             return(true);
         }
         if (PathGeometrySerializationHelper.SearchForAnimationsInVisualStateGroups(currentElement, pathNameNode))
         {
             return(true);
         }
     }
     return(false);
 }
Exemplo n.º 4
0
 public static bool CanSerializeAsAttribute(DocumentCompositeNode compositeNode)
 {
     if (PathGeometrySerializationHelper.SerializeAsAttribute(compositeNode) == null)
     {
         return(false);
     }
     return(!PathGeometrySerializationHelper.HasAnimations(compositeNode));
 }
Exemplo n.º 5
0
        private static bool GetPathSegmentAsString(DocumentNode pathSegmentNode, StringBuilder stringBuilder)
        {
            DocumentCompositeNode documentCompositeNode = pathSegmentNode as DocumentCompositeNode;

            if (documentCompositeNode == null)
            {
                return(false);
            }
            if (pathSegmentNode.TypeResolver.ResolveProperty(PathMetadata.PathSegmentIsStrokedProperty) != null && PathGeometrySerializationHelper.IsCompositeOrNonDefaultValue <bool>(documentCompositeNode, PathMetadata.PathSegmentIsStrokedProperty, true))
            {
                return(false);
            }
            if (pathSegmentNode.TypeResolver.ResolveProperty(PathMetadata.PathSegmentIsSmoothJoinProperty) != null && PathGeometrySerializationHelper.IsCompositeOrNonDefaultValue <bool>(documentCompositeNode, PathMetadata.PathSegmentIsSmoothJoinProperty, false))
            {
                return(false);
            }
            if (PlatformTypes.ArcSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                return(PathGeometrySerializationHelper.GetArcSegmentAsString(documentCompositeNode, stringBuilder));
            }
            if (PlatformTypes.LineSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                IPropertyId[] lineSegmentPointProperty = new IPropertyId[] { PathMetadata.LineSegmentPointProperty };
                return(PathGeometrySerializationHelper.GetSimpleSegmentAsString(documentCompositeNode, stringBuilder, 'L', lineSegmentPointProperty));
            }
            if (PlatformTypes.QuadraticBezierSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                IPropertyId[] quadraticBezierSegmentPoint1Property = new IPropertyId[] { PathMetadata.QuadraticBezierSegmentPoint1Property, PathMetadata.QuadraticBezierSegmentPoint2Property };
                return(PathGeometrySerializationHelper.GetSimpleSegmentAsString(documentCompositeNode, stringBuilder, 'Q', quadraticBezierSegmentPoint1Property));
            }
            if (PlatformTypes.BezierSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                IPropertyId[] bezierSegmentPoint1Property = new IPropertyId[] { PathMetadata.BezierSegmentPoint1Property, PathMetadata.BezierSegmentPoint2Property, PathMetadata.BezierSegmentPoint3Property };
                return(PathGeometrySerializationHelper.GetSimpleSegmentAsString(documentCompositeNode, stringBuilder, 'C', bezierSegmentPoint1Property));
            }
            if (PlatformTypes.PolyLineSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                return(PathGeometrySerializationHelper.GetPolySegmentAsString(documentCompositeNode, stringBuilder, 'L', PathMetadata.PolyLineSegmentPointsProperty));
            }
            if (PlatformTypes.PolyQuadraticBezierSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                return(PathGeometrySerializationHelper.GetPolySegmentAsString(documentCompositeNode, stringBuilder, 'Q', PathMetadata.PolyQuadraticBezierSegmentPointsProperty));
            }
            if (!PlatformTypes.PolyBezierSegment.IsAssignableFrom(documentCompositeNode.Type))
            {
                return(false);
            }
            return(PathGeometrySerializationHelper.GetPolySegmentAsString(documentCompositeNode, stringBuilder, 'C', PathMetadata.PolyBezierSegmentPointsProperty));
        }
Exemplo n.º 6
0
 private static bool GetPathFigureCollectionAsString(DocumentCompositeNode pathFigureCollectionNode, StringBuilder stringBuilder)
 {
     for (int i = 0; i < pathFigureCollectionNode.Children.Count; i++)
     {
         if (i > 0)
         {
             stringBuilder.Append(' ');
         }
         if (!PathGeometrySerializationHelper.GetPathFigureAsString(pathFigureCollectionNode.Children[i], stringBuilder))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 7
0
        private static bool IsCompositeOrNonDefaultValue <T>(DocumentCompositeNode compositeNode, IPropertyId propertyKey, T defaultValue)
        {
            T t = defaultValue;

            PathGeometrySerializationHelper.PropertyValueKind primitiveValue = PathGeometrySerializationHelper.GetPrimitiveValue <T>(compositeNode, propertyKey, ref t);
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(true);
            }
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Primitive && !object.Equals(t, defaultValue))
            {
                return(true);
            }
            return(false);
        }
Exemplo n.º 8
0
 public static string SerializeAsAttribute(DocumentCompositeNode compositeNode)
 {
     if (PlatformTypes.PathGeometry.IsAssignableFrom(compositeNode.Type))
     {
         return(PathGeometrySerializationHelper.GetPathGeometryAsString(compositeNode));
     }
     if (PlatformTypes.PathFigureCollection.IsAssignableFrom(compositeNode.Type))
     {
         StringBuilder stringBuilder = new StringBuilder();
         if (compositeNode.TypeResolver.IsCapabilitySet(PlatformCapability.SupportsPathFigureTypeConverter) && PathGeometrySerializationHelper.GetPathFigureCollectionAsString(compositeNode, stringBuilder))
         {
             return(stringBuilder.ToString());
         }
     }
     return(null);
 }
Exemplo n.º 9
0
        public virtual string GetValueAsString(DocumentNode node)
        {
            ITypeId type       = node.Type;
            Type    targetType = node.TargetType;
            DocumentPrimitiveNode documentPrimitiveNode = node as DocumentPrimitiveNode;
            DocumentCompositeNode documentCompositeNode = node as DocumentCompositeNode;

            if (documentPrimitiveNode != null)
            {
                DocumentNodeStringValue value          = documentPrimitiveNode.Value as DocumentNodeStringValue;
                TypeConverter           valueConverter = documentPrimitiveNode.ValueConverter;
                if (value != null && valueConverter != null && valueConverter.CanConvertFrom(typeof(string)))
                {
                    if (typeof(Vector3DCollection) == targetType)
                    {
                        Vector3DCollection vector3DCollections = (Vector3DCollection)valueConverter.ConvertFromInvariantString(value.Value);
                        return(PointSerializationHelper.GetVector3DCollectionAsString(vector3DCollections));
                    }
                    if (typeof(Point3DCollection) == targetType)
                    {
                        Point3DCollection point3DCollections = (Point3DCollection)valueConverter.ConvertFromInvariantString(value.Value);
                        return(PointSerializationHelper.GetPoint3DCollectionAsString(point3DCollections));
                    }
                    if (typeof(PointCollection) == targetType)
                    {
                        PointCollection pointCollections = (PointCollection)valueConverter.ConvertFromInvariantString(value.Value);
                        return(PointSerializationHelper.GetPointCollectionAsString(pointCollections));
                    }
                }
            }
            else if (documentCompositeNode != null)
            {
                if (PlatformTypes.PathGeometry.IsAssignableFrom(type))
                {
                    return(PathGeometrySerializationHelper.SerializeAsAttribute(documentCompositeNode));
                }
                if (PlatformTypes.PathFigureCollection.IsAssignableFrom(type))
                {
                    return(PathGeometrySerializationHelper.SerializeAsAttribute(documentCompositeNode));
                }
                if (PlatformTypes.DoubleCollection.IsAssignableFrom(type))
                {
                    return(PointSerializationHelper.SerializeDoubleCollectionAsAttribute(documentCompositeNode));
                }
            }
            return(null);
        }
Exemplo n.º 10
0
        private static bool SearchForAnimations(DocumentCompositeNode pathElementNode)
        {
            DocumentNode item = pathElementNode.Properties[KnownProperties.FrameworkElementNameProperty];

            for (DocumentCompositeNode i = pathElementNode; i != null; i = i.Parent)
            {
                if (PathGeometrySerializationHelper.SearchForAnimationsAtElement(i, item))
                {
                    return(true);
                }
                if (PlatformTypes.FrameworkTemplate.IsAssignableFrom(i.Type) || PlatformTypes.Style.IsAssignableFrom(i.Type))
                {
                    break;
                }
            }
            return(false);
        }
Exemplo n.º 11
0
        private static bool SearchForAnimationsInResources(DocumentCompositeNode elementNode, DocumentNode pathNameNode)
        {
            bool flag;
            DocumentCompositeNode resources           = null;
            ISupportsResources    resourcesCollection = ResourceNodeHelper.GetResourcesCollection(elementNode);

            if (resourcesCollection != null)
            {
                resources = resourcesCollection.Resources;
            }
            if (resources != null)
            {
                using (IEnumerator <DocumentNode> enumerator = resources.ChildNodes.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        DocumentCompositeNode current = enumerator.Current as DocumentCompositeNode;
                        if (current == null)
                        {
                            continue;
                        }
                        DocumentNode item = current.Properties[KnownProperties.DictionaryEntryValueProperty];
                        if (item == null || !PlatformTypes.Storyboard.IsAssignableFrom(item.Type))
                        {
                            continue;
                        }
                        using (IEnumerator <DocumentNode> enumerator1 = item.FindPointAnimationDescendantNodes().GetEnumerator())
                        {
                            while (enumerator1.MoveNext())
                            {
                                if (!PathGeometrySerializationHelper.DoesAnimationTargetPath(pathNameNode, enumerator1.Current))
                                {
                                    continue;
                                }
                                flag = true;
                                return(flag);
                            }
                        }
                    }
                    return(false);
                }
                return(flag);
            }
            return(false);
        }
Exemplo n.º 12
0
 private static bool GetSimpleSegmentAsString(DocumentCompositeNode simpleSegmentNode, StringBuilder stringBuilder, char symbol, params IPropertyId[] pointProperties)
 {
     stringBuilder.Append(' ');
     stringBuilder.Append(symbol);
     for (int i = 0; i < (int)pointProperties.Length; i++)
     {
         Point point = new Point();
         if (PathGeometrySerializationHelper.GetPrimitiveValue <Point>(simpleSegmentNode, pointProperties[i], ref point) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
         {
             return(false);
         }
         if (i > 0)
         {
             stringBuilder.Append(' ');
         }
         PointSerializationHelper.AppendPoint(stringBuilder, point);
     }
     return(true);
 }
Exemplo n.º 13
0
        public static bool HasAnimations(DocumentCompositeNode compositeNode)
        {
            DocumentPrimitiveNode documentPrimitiveNode;
            IPropertyId           sitePropertyKey;

            documentPrimitiveNode = (!PlatformTypes.PathFigureCollection.IsAssignableFrom(compositeNode.Type) || compositeNode.Parent == null ? compositeNode.Properties[DesignTimeProperties.IsAnimatedProperty] as DocumentPrimitiveNode : compositeNode.Parent.Properties[DesignTimeProperties.IsAnimatedProperty] as DocumentPrimitiveNode);
            if (documentPrimitiveNode != null && PlatformTypes.Boolean.IsAssignableFrom(documentPrimitiveNode.Type) && documentPrimitiveNode.GetValue <bool>())
            {
                return(true);
            }
            DocumentCompositeNode parent = null;

            if (PlatformTypes.PathGeometry.Equals(compositeNode.Type))
            {
                IPropertyId propertyId = compositeNode.SitePropertyKey;
                if (PathMetadata.DataProperty.Equals(propertyId) || PathMetadata.ClipProperty.Equals(propertyId))
                {
                    parent = compositeNode.Parent;
                }
            }
            else if (PlatformTypes.PathFigureCollection.Equals(compositeNode.Type))
            {
                if (compositeNode.Parent != null)
                {
                    sitePropertyKey = compositeNode.Parent.SitePropertyKey;
                }
                else
                {
                    sitePropertyKey = null;
                }
                IPropertyId propertyId1 = sitePropertyKey;
                if (PathMetadata.DataProperty.Equals(propertyId1) || PathMetadata.ClipProperty.Equals(propertyId1))
                {
                    parent = compositeNode.Parent.Parent;
                }
            }
            if (parent == null)
            {
                return(false);
            }
            return(PathGeometrySerializationHelper.SearchForAnimations(parent));
        }
Exemplo n.º 14
0
        private static bool GetArcSegmentAsString(DocumentCompositeNode arcSegmentNode, StringBuilder stringBuilder)
        {
            Size           size           = new Size();
            double         num            = 0;
            bool           flag           = false;
            SweepDirection sweepDirection = SweepDirection.Counterclockwise;
            Point          point          = new Point();

            if (PathGeometrySerializationHelper.GetPrimitiveValue <Size>(arcSegmentNode, PathMetadata.ArcSegmentSizeProperty, ref size) == PathGeometrySerializationHelper.PropertyValueKind.Composite || PathGeometrySerializationHelper.GetPrimitiveValue <double>(arcSegmentNode, PathMetadata.ArcSegmentRotationAngleProperty, ref num) == PathGeometrySerializationHelper.PropertyValueKind.Composite || PathGeometrySerializationHelper.GetPrimitiveValue <bool>(arcSegmentNode, PathMetadata.ArcSegmentIsLargeArcProperty, ref flag) == PathGeometrySerializationHelper.PropertyValueKind.Composite || PathGeometrySerializationHelper.GetPrimitiveValue <SweepDirection>(arcSegmentNode, PathMetadata.ArcSegmentSweepDirectionProperty, ref sweepDirection) == PathGeometrySerializationHelper.PropertyValueKind.Composite || PathGeometrySerializationHelper.GetPrimitiveValue <Point>(arcSegmentNode, PathMetadata.ArcSegmentPointProperty, ref point) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(false);
            }
            StringBuilder stringBuilder1 = stringBuilder;

            object[] width = new object[] { size.Width, size.Height, num, null, null };
            width[3] = (flag ? '1' : '0');
            width[4] = (sweepDirection == SweepDirection.Clockwise ? '1' : '0');
            stringBuilder1.AppendFormat(" A{0:G8},{1:G8},{2:G8},{3},{4},", width);
            PointSerializationHelper.AppendPoint(stringBuilder, point);
            return(true);
        }
Exemplo n.º 15
0
        private static string GetPathGeometryAsString(DocumentCompositeNode pathGeometryNode)
        {
            StringBuilder stringBuilder = new StringBuilder();
            Transform     transform     = null;

            PathGeometrySerializationHelper.PropertyValueKind primitiveValue = PathGeometrySerializationHelper.GetPrimitiveValue <Transform>(pathGeometryNode, PathMetadata.GeometryTransformProperty, ref transform);
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Composite || transform != null)
            {
                return(null);
            }
            FillRule fillRule = FillRule.EvenOdd;

            primitiveValue = PathGeometrySerializationHelper.GetPrimitiveValue <FillRule>(pathGeometryNode, PathMetadata.PathGeometryFillRuleProperty, ref fillRule);
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(null);
            }
            if (primitiveValue == PathGeometrySerializationHelper.PropertyValueKind.Primitive && fillRule != FillRule.EvenOdd)
            {
                stringBuilder.Append("F1 ");
            }
            DocumentNode item = pathGeometryNode.Properties[PathMetadata.PathGeometryFiguresProperty];

            if (item != null)
            {
                DocumentCompositeNode documentCompositeNode = item as DocumentCompositeNode;
                if (documentCompositeNode == null)
                {
                    return(null);
                }
                if (!PathGeometrySerializationHelper.GetPathFigureCollectionAsString(documentCompositeNode, stringBuilder))
                {
                    return(null);
                }
            }
            return(stringBuilder.ToString());
        }
Exemplo n.º 16
0
        private SerializedFormat ShouldSerializeProperty(XamlSerializerContext serializerContext, DocumentCompositeNode parentNode, IPropertyId propertyKey, DocumentNode valueNode, out bool useElementForOuterMostMarkupExtension)
        {
            bool             flag;
            SerializedFormat serializedFormat;

            useElementForOuterMostMarkupExtension = false;
            DocumentCompositeNode documentCompositeNode = valueNode as DocumentCompositeNode;
            DocumentPrimitiveNode documentPrimitiveNode = valueNode as DocumentPrimitiveNode;
            IProperty             valueProperty         = valueNode.GetValueProperty();

            if (valueProperty != null)
            {
                if (valueProperty.MemberType != MemberType.DesignTimeProperty && !this.ShouldSerialize(serializerContext, valueNode))
                {
                    return(SerializedFormat.DoNotSerialize);
                }
                if (valueProperty.MemberType == MemberType.DesignTimeProperty)
                {
                    bool flag1 = true;
                    if (!valueProperty.ShouldSerialize)
                    {
                        flag1 = this.ShouldSerializeDesignTimeProperty(valueProperty);
                    }
                    if (!flag1)
                    {
                        return(SerializedFormat.DoNotSerialize);
                    }
                }
                if (!KnownProperties.SetterTargetNameProperty.Equals(valueProperty))
                {
                    if (parentNode.Type.Metadata.IsNameProperty(valueProperty))
                    {
                        string valueAsString = DocumentPrimitiveNode.GetValueAsString(valueNode);
                        if (valueAsString != null)
                        {
                            if (valueAsString.StartsWith("~", StringComparison.Ordinal) && serializerContext.InStyleOrTemplate)
                            {
                                return(SerializedFormat.DoNotSerialize);
                            }
                            if (valueAsString.Length == 0)
                            {
                                return(SerializedFormat.DoNotSerialize);
                            }
                        }
                        return(SerializedFormat.ComplexString);
                    }
                    if (DesignTimeProperties.UidProperty.Equals(valueProperty))
                    {
                        return(SerializedFormat.ComplexString);
                    }
                    if (KnownProperties.FrameworkContentElementResourcesProperty.Equals(valueProperty))
                    {
                        if (documentCompositeNode != null && PlatformTypes.ResourceDictionary.IsAssignableFrom(documentCompositeNode.Type) && documentCompositeNode.SupportsChildren && documentCompositeNode.Children.Count == 0)
                        {
                            return(SerializedFormat.DoNotSerialize);
                        }
                    }
                    else if (!PlatformTypes.Style.IsAssignableFrom(valueProperty.PropertyType))
                    {
                        DependencyPropertyReferenceStep dependencyPropertyReferenceStep = valueProperty as DependencyPropertyReferenceStep;
                        if (dependencyPropertyReferenceStep != null && dependencyPropertyReferenceStep.IsAttachable && !DefaultXamlSerializerFilter.IsTypeSerializable(serializerContext.TypeResolver, valueProperty.DeclaringType) && dependencyPropertyReferenceStep.MemberType != MemberType.DesignTimeProperty)
                        {
                            return(SerializedFormat.DoNotSerialize);
                        }
                    }
                    else if (documentCompositeNode != null)
                    {
                        if (documentCompositeNode.GetValue <bool>(DesignTimeProperties.IsDefaultStyleProperty))
                        {
                            return(SerializedFormat.DoNotSerialize);
                        }
                    }
                    else if (documentPrimitiveNode != null && documentPrimitiveNode.Value is DocumentNodeReferenceValue)
                    {
                        return(SerializedFormat.DoNotSerialize);
                    }
                }
                else
                {
                    string str = DocumentPrimitiveNode.GetValueAsString(valueNode);
                    if (str != null && str == "~Self")
                    {
                        return(SerializedFormat.DoNotSerialize);
                    }
                }
            }
            IType type = valueNode.Type;

            if (PlatformTypes.XData.Equals(type))
            {
                return(SerializedFormat.Element);
            }
            if (PlatformTypes.StaticResource.IsAssignableFrom(type) && documentCompositeNode != null && ResourceNodeHelper.GetResourceKey(documentCompositeNode) != null)
            {
                DocumentCompositeNode parent = documentCompositeNode.Parent;
                while (parent != null && parent.Type.IsExpression)
                {
                    parent = parent.Parent;
                }
                if (parent != null)
                {
                    IPropertyId resourcesProperty = parent.Type.Metadata.ResourcesProperty;
                    if (resourcesProperty != null)
                    {
                        DocumentCompositeNode item = parent.Properties[resourcesProperty] as DocumentCompositeNode;
                        if (item != null && PlatformTypes.ResourceDictionary.IsAssignableFrom(item.Type))
                        {
                            useElementForOuterMostMarkupExtension = true;
                            return(SerializedFormat.ComplexString);
                        }
                    }
                }
            }
            if (type.IsExpression)
            {
                if (documentCompositeNode != null)
                {
                    using (IEnumerator <KeyValuePair <IProperty, DocumentNode> > enumerator = documentCompositeNode.Properties.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            KeyValuePair <IProperty, DocumentNode> current = enumerator.Current;
                            switch (this.ShouldSerializeProperty(serializerContext, documentCompositeNode, current.Key, current.Value, out flag))
                            {
                            case SerializedFormat.SimpleString:
                            {
                                continue;
                            }

                            case SerializedFormat.ComplexString:
                            {
                                if (current.Value.Type.IsExpression)
                                {
                                    if (!flag)
                                    {
                                        continue;
                                    }
                                    useElementForOuterMostMarkupExtension = true;
                                    continue;
                                }
                                else
                                {
                                    serializedFormat = SerializedFormat.Element;
                                    return(serializedFormat);
                                }
                            }
                            }
                            serializedFormat = SerializedFormat.Element;
                            return(serializedFormat);
                        }
                        return(SerializedFormat.ComplexString);
                    }
                    return(serializedFormat);
                }
                return(SerializedFormat.ComplexString);
            }
            if (this.PropertyValueRequiresElement(valueProperty, valueNode.Type))
            {
                return(SerializedFormat.Element);
            }
            if (PlatformTypes.Uri.IsAssignableFrom(type))
            {
                return(SerializedFormat.ComplexString);
            }
            if (PlatformTypes.PropertyPath.IsAssignableFrom(type))
            {
                if (documentCompositeNode != null)
                {
                    if (DocumentPrimitiveNode.GetValueAsString(documentCompositeNode.Properties[KnownProperties.PropertyPathPathProperty]) != null)
                    {
                        return(SerializedFormat.SimpleString);
                    }
                    return(SerializedFormat.Element);
                }
            }
            else if (PlatformTypes.SolidColorBrush.IsAssignableFrom(type))
            {
                if (documentCompositeNode != null)
                {
                    if (documentCompositeNode.Properties.Count == 0)
                    {
                        return(SerializedFormat.SimpleString);
                    }
                    if (documentCompositeNode.Properties.Count == 1)
                    {
                        DocumentPrimitiveNode item1 = documentCompositeNode.Properties[KnownProperties.SolidColorBrushColorProperty] as DocumentPrimitiveNode;
                        if (item1 != null && PlatformTypes.Color.Equals(item1.Type))
                        {
                            return(SerializedFormat.SimpleString);
                        }
                    }
                    return(SerializedFormat.Element);
                }
            }
            else if (!PlatformTypes.Color.IsAssignableFrom(type))
            {
                if (PlatformTypes.PathGeometry.IsAssignableFrom(type))
                {
                    if (valueProperty == null || PlatformTypes.PathGeometry.IsAssignableFrom(valueProperty.PropertyType))
                    {
                        return(SerializedFormat.Element);
                    }
                    if (documentCompositeNode != null && !PathGeometrySerializationHelper.CanSerializeAsAttribute(documentCompositeNode))
                    {
                        return(SerializedFormat.Element);
                    }
                    return(SerializedFormat.ComplexString);
                }
                if (PlatformTypes.PathFigureCollection.IsAssignableFrom(type))
                {
                    if (documentCompositeNode != null && !PathGeometrySerializationHelper.CanSerializeAsAttribute(documentCompositeNode))
                    {
                        return(SerializedFormat.Element);
                    }
                    return(SerializedFormat.ComplexString);
                }
                if (PlatformTypes.DoubleCollection.IsAssignableFrom(type))
                {
                    if (documentCompositeNode != null && PointSerializationHelper.SerializeDoubleCollectionAsAttribute(documentCompositeNode) == null)
                    {
                        return(SerializedFormat.Element);
                    }
                    return(SerializedFormat.ComplexString);
                }
            }
            else if (documentCompositeNode == null && valueNode.Parent != null && valueNode.IsProperty)
            {
                return(SerializedFormat.SimpleString);
            }
            if (documentPrimitiveNode != null && documentPrimitiveNode.Value == null)
            {
                return(SerializedFormat.SimpleString);
            }
            if (XamlSerializerContext.IsXmlElement(valueNode))
            {
                return(SerializedFormat.Element);
            }
            if (documentPrimitiveNode != null)
            {
                if (documentPrimitiveNode.Value is DocumentNodeStringValue)
                {
                    return(SerializedFormat.SimpleString);
                }
                if (documentPrimitiveNode.Value is DocumentNodeMemberValue)
                {
                    return(SerializedFormat.SimpleString);
                }
            }
            if (documentCompositeNode == null)
            {
                return(SerializedFormat.ComplexString);
            }
            return(SerializedFormat.Element);
        }
Exemplo n.º 17
0
        private static bool GetPathFigureAsString(DocumentNode pathFigureNode, StringBuilder stringBuilder)
        {
            bool                  flag;
            bool                  flag1;
            StringBuilder         stringBuilder1;
            DocumentCompositeNode documentCompositeNode = pathFigureNode as DocumentCompositeNode;

            if (documentCompositeNode == null)
            {
                return(false);
            }
            if (PathGeometrySerializationHelper.IsCompositeOrNonDefaultValue <bool>(documentCompositeNode, PathMetadata.PathFigureIsFilledProperty, true))
            {
                return(false);
            }
            Point point = new Point();

            if (PathGeometrySerializationHelper.GetPrimitiveValue <Point>(documentCompositeNode, PathMetadata.PathFigureStartPointProperty, ref point) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(false);
            }
            stringBuilder.Append('M');
            PointSerializationHelper.AppendPoint(stringBuilder, point);
            DocumentNode item = documentCompositeNode.Properties[PathMetadata.PathFigureSegmentsProperty];

            if (item != null)
            {
                DocumentCompositeNode documentCompositeNode1 = item as DocumentCompositeNode;
                if (documentCompositeNode1 == null)
                {
                    return(false);
                }
                using (IEnumerator <DocumentNode> enumerator = documentCompositeNode1.Children.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        if (PathGeometrySerializationHelper.GetPathSegmentAsString(enumerator.Current, stringBuilder))
                        {
                            continue;
                        }
                        flag1 = false;
                        return(flag1);
                    }
                    flag = false;
                    if (PathGeometrySerializationHelper.GetPrimitiveValue <bool>(documentCompositeNode, PathMetadata.PathFigureIsClosedProperty, ref flag) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
                    {
                        return(false);
                    }
                    if (flag)
                    {
                        stringBuilder1 = stringBuilder.Append(" z");
                    }
                    return(true);
                }
                return(flag1);
            }
            flag = false;
            if (PathGeometrySerializationHelper.GetPrimitiveValue <bool>(documentCompositeNode, PathMetadata.PathFigureIsClosedProperty, ref flag) == PathGeometrySerializationHelper.PropertyValueKind.Composite)
            {
                return(false);
            }
            if (flag)
            {
                stringBuilder1 = stringBuilder.Append(" z");
            }
            return(true);
        }