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); }
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); }