Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
        public static IType GetStyleOrTemplateTargetType(DocumentNode node)
        {
            IType styleOrTemplateType;

            return(DocumentNodeHelper.GetStyleOrTemplateTypeAndTargetType(node, out styleOrTemplateType));
        }
Ejemplo n.º 4
0
 public static void PreserveFormatting(DocumentNode node)
 {
     DocumentNodeHelper.PreserveFormatting(node.DocumentRoot, node);
 }