public static IType GetStyleOrTemplateTypeAndTargetType(DocumentNode node, out IType styleOrTemplateType) { IPlatformMetadata platformMetadata = node.TypeResolver.PlatformMetadata; ITargetTypeMetadata targetTypeMetadata = node.Type.Metadata as ITargetTypeMetadata; if (platformMetadata.KnownTypes.Style.IsAssignableFrom((ITypeId)node.Type)) { styleOrTemplateType = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.Style); IType type1 = DocumentNodeHelper.GetValueAsMember(node as DocumentCompositeNode, targetTypeMetadata.TargetTypeProperty) as IType; if (type1 == null) { IType type2 = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.IFrameworkInputElement); type1 = !platformMetadata.IsNullType((ITypeId)type2) ? type2 : (IType)null; } return(type1); } if (platformMetadata.KnownTypes.DataTemplate.IsAssignableFrom((ITypeId)node.Type)) { styleOrTemplateType = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.DataTemplate); return(node.TypeResolver.ResolveType(platformMetadata.KnownTypes.ContentPresenter)); } if (platformMetadata.KnownTypes.ControlTemplate.IsAssignableFrom((ITypeId)node.Type)) { styleOrTemplateType = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.ControlTemplate); return(DocumentNodeHelper.GetValueAsMember(node as DocumentCompositeNode, targetTypeMetadata.TargetTypeProperty) as IType ?? node.TypeResolver.ResolveType(platformMetadata.KnownTypes.Control)); } if (platformMetadata.KnownTypes.FrameworkTemplate.IsAssignableFrom((ITypeId)node.Type)) { styleOrTemplateType = node.TypeResolver.ResolveType(platformMetadata.KnownTypes.FrameworkTemplate); return(node.TypeResolver.ResolveType(platformMetadata.KnownTypes.FrameworkElement)); } styleOrTemplateType = (IType)null; return((IType)null); }
internal static void PreserveFormatting(IDocumentRoot documentRoot, DocumentNode node) { if (node.SourceContext != null) { documentRoot.SetSourceContext(node, node.SourceContext.FreezeText(false)); } if (node.ContainerSourceContext != null) { documentRoot.SetContainerSourceContext(node, node.ContainerSourceContext.FreezeText(false)); } foreach (DocumentNode node1 in node.ChildNodes) { DocumentNodeHelper.PreserveFormatting(documentRoot, node1); } }
public static IType GetStyleOrTemplateTargetType(DocumentNode node) { IType styleOrTemplateType; return(DocumentNodeHelper.GetStyleOrTemplateTypeAndTargetType(node, out styleOrTemplateType)); }
public static void PreserveFormatting(DocumentNode node) { DocumentNodeHelper.PreserveFormatting(node.DocumentRoot, node); }