コード例 #1
0
        private IProperty ConvertPropertyKey(IProperty propertyKey, IPlatformMetadata targetPlatformMetadata)
        {
            ITypeId typeId = (ITypeId)propertyKey.DeclaringType;

            if (typeId.Equals((object)PlatformTypes.TextElement))
            {
                typeId = PlatformTypes.Inline;
            }
            ITypeId   type      = (ITypeId)PlatformTypeHelper.ConvertTypeId(typeId, targetPlatformMetadata);
            IProperty property1 = type.GetMember(propertyKey.MemberType, propertyKey.Name, (MemberAccessTypes)(propertyKey.ReadAccess | propertyKey.WriteAccess)) as IProperty;

            if (property1 == null && targetPlatformMetadata.IsCapabilitySet(PlatformCapability.SupportsProxyProperties))
            {
                IEnumerable <IProperty> proxyProperties = targetPlatformMetadata.GetProxyProperties(this.StandaloneWpfDocumentContext.TypeResolver);
                if (proxyProperties != null)
                {
                    string name = propertyKey.Name;
                    foreach (IProperty property2 in proxyProperties)
                    {
                        if (name == property2.Name && property2.DeclaringType.IsAssignableFrom(type))
                        {
                            property1 = property2;
                            break;
                        }
                    }
                }
            }
            return(property1);
        }
コード例 #2
0
        public object ConvertToWpf(IDocumentContext sourceDocumentContext, object obj)
        {
            if (PlatformConverter.IsPlatformValue(obj, this.StandaloneWpfDocumentContext))
            {
                return(obj);
            }
            if (obj != null)
            {
                ITypeId typeId = (ITypeId)sourceDocumentContext.TypeResolver.GetType(obj.GetType());
                if (PlatformTypes.Style.IsAssignableFrom(typeId) || PlatformTypes.FrameworkTemplate.IsAssignableFrom(typeId))
                {
                    return(Activator.CreateInstance(PlatformTypeHelper.ConvertTypeId(typeId, this.StandaloneWpfDocumentContext.TypeResolver.PlatformMetadata).RuntimeType));
                }
                if (PlatformTypes.CompositeTransform.IsAssignableFrom(typeId))
                {
                    IPlatform platform = PlatformConverter.GetPlatform(sourceDocumentContext);
                    if (platform != null)
                    {
                        Transform transform = (Transform)platform.GeometryHelper.ConvertTransformToWpf(obj);
                        if (transform != null)
                        {
                            return((object)transform);
                        }
                    }
                }
            }
            object     obj1       = this.ConvertInternal(obj, sourceDocumentContext, this.StandaloneWpfDocumentContext, PlatformConverter.ConvertToType.InstanceValue);
            FontFamily fontFamily = obj1 as FontFamily;

            if (fontFamily != null && fontFamily.Source == PlatformConverter.portableUserInterfaceString)
            {
                return((object)PlatformConverter.PortableUserInterfaceFont);
            }
            return(obj1);
        }
コード例 #3
0
        private DocumentNode ConvertSubtree(DocumentNode node, IDocumentContext sourcePlatformDocumentContext, IDocumentContext targetPlatformDocumentContext)
        {
            DocumentPrimitiveNode documentPrimitiveNode = node as DocumentPrimitiveNode;
            DocumentCompositeNode documentCompositeNode = node as DocumentCompositeNode;

            if (documentPrimitiveNode != null)
            {
                ITypeId typeId        = (ITypeId)PlatformTypeHelper.ConvertTypeId((ITypeId)documentPrimitiveNode.Type, targetPlatformDocumentContext.TypeResolver.PlatformMetadata);
                object  valueAsObject = DocumentPrimitiveNode.GetValueAsObject((DocumentNode)documentPrimitiveNode);
                if (valueAsObject != null)
                {
                    return((DocumentNode) new DocumentPrimitiveNode(targetPlatformDocumentContext, typeId, this.ConvertInternal(valueAsObject, sourcePlatformDocumentContext, targetPlatformDocumentContext, PlatformConverter.ConvertToType.InstanceValue)));
                }
                IDocumentNodeValue documentNodeValue = DocumentPrimitiveNode.GetValueAsMember((DocumentNode)documentPrimitiveNode) != null || documentPrimitiveNode.Value == null ? (IDocumentNodeValue)null : documentPrimitiveNode.Value.Clone(targetPlatformDocumentContext);
                return((DocumentNode) new DocumentPrimitiveNode(targetPlatformDocumentContext, typeId, documentNodeValue));
            }
            if (documentCompositeNode != null)
            {
                if (PlatformTypes.CompositeTransform.IsAssignableFrom((ITypeId)documentCompositeNode.Type))
                {
                    IPlatform platform = PlatformConverter.GetPlatform(sourcePlatformDocumentContext);
                    if (platform != null)
                    {
                        TransformGroup transformGroup = platform.GeometryHelper.ConvertTransformToWpf((object)documentCompositeNode);
                        if (PlatformConverter.IsPlatformValue((object)transformGroup, targetPlatformDocumentContext))
                        {
                            return(targetPlatformDocumentContext.CreateNode(typeof(TransformGroup), (object)transformGroup));
                        }
                    }
                }
                ITypeId typeId = (ITypeId)PlatformTypeHelper.ConvertTypeId((ITypeId)documentCompositeNode.Type, targetPlatformDocumentContext.TypeResolver.PlatformMetadata);
                if (!documentCompositeNode.TypeResolver.PlatformMetadata.IsNullType(typeId))
                {
                    DocumentCompositeNode node1 = targetPlatformDocumentContext.CreateNode(typeId);
                    foreach (KeyValuePair <IProperty, DocumentNode> keyValuePair in (IEnumerable <KeyValuePair <IProperty, DocumentNode> >)documentCompositeNode.Properties)
                    {
                        IProperty property = this.ConvertPropertyKey(keyValuePair.Key, targetPlatformDocumentContext.TypeResolver.PlatformMetadata);
                        if (property != null)
                        {
                            DocumentNode node2 = keyValuePair.Value;
                            if (!PlatformTypes.FrameworkTemplate.IsAssignableFrom((ITypeId)node2.Type) && !PlatformTypes.Style.IsAssignableFrom((ITypeId)node2.Type))
                            {
                                DocumentNode node3 = this.ConvertSubtree(node2, sourcePlatformDocumentContext, targetPlatformDocumentContext);
                                if (node3 != null && (PlatformTypeHelper.GetPropertyType(property).IsAssignableFrom(node3.TargetType) || DocumentNodeUtilities.IsMarkupExtension(node3)))
                                {
                                    node1.Properties[(IPropertyId)property] = node3;
                                }
                            }
                        }
                    }
                    if (documentCompositeNode.SupportsChildren)
                    {
                        for (int index = 0; index < documentCompositeNode.Children.Count; ++index)
                        {
                            DocumentNode node2 = documentCompositeNode.Children[index];
                            node1.Children.Add(this.ConvertSubtree(node2, sourcePlatformDocumentContext, targetPlatformDocumentContext));
                        }
                    }
                    return((DocumentNode)node1);
                }
            }
            return((DocumentNode)null);
        }