Ejemplo n.º 1
0
        public static DocumentReference GetDocumentReference(IDocumentContext documentContext)
        {
            DocumentContext documentContext1 = documentContext as DocumentContext;

            if (documentContext1 != null)
            {
                return(DocumentReferenceLocator.GetDocumentReference(documentContext1.DocumentLocator));
            }
            return(DocumentReference.Create(documentContext.DocumentUrl));
        }
Ejemplo n.º 2
0
        public override bool ReferencesDocument(DocumentReference documentReference)
        {
            bool             flag     = false;
            DocumentNode     rootNode = this.DocumentRoot.RootNode;
            IProjectDocument document = this.ProjectContext.GetDocument(DocumentReferenceLocator.GetDocumentLocator(documentReference));

            if (rootNode != null && document != null && document.DocumentType == ProjectDocumentType.ResourceDictionary)
            {
                foreach (DocumentNode node in rootNode.DescendantNodes)
                {
                    if (this.DoesNodeReferenceUrl(node, documentReference.Path))
                    {
                        flag = true;
                        break;
                    }
                }
            }
            return(flag);
        }
Ejemplo n.º 3
0
        public static DocumentReference GetDocumentReference(IDocumentLocator documentLocator)
        {
            if (documentLocator == null)
            {
                return((DocumentReference)null);
            }
            DocumentReferenceLocator referenceLocator = documentLocator as DocumentReferenceLocator;

            if (referenceLocator != null)
            {
                return(referenceLocator.DocumentReference);
            }
            IDocument document = documentLocator as IDocument;

            if (document != null)
            {
                return(document.DocumentReference);
            }
            return(DocumentReference.Create(documentLocator.Path));
        }
Ejemplo n.º 4
0
        public static DocumentNode GetParsedOrSniffedRootNode(IProjectItem projectItem, IProjectContext projectContext)
        {
            if (projectItem.Document != null)
            {
                SceneDocument sceneDocument = projectItem.Document as SceneDocument;
                if (sceneDocument != null && sceneDocument.DocumentRoot != null)
                {
                    return(sceneDocument.DocumentRoot.RootNode);
                }
            }
            DocumentContext documentContext = DocumentContextHelper.CreateDocumentContext((IProject)projectContext.GetService(typeof(IProject)), projectContext, DocumentReferenceLocator.GetDocumentLocator(projectItem.DocumentReference));
            IType           type            = DocumentContextHelper.SniffRootNodeType(projectItem, documentContext);

            if (type != null && type.RuntimeType != (Type)null)
            {
                return((DocumentNode)documentContext.CreateNode((ITypeId)type));
            }
            return((DocumentNode)null);
        }
Ejemplo n.º 5
0
        internal SceneDocument CreateDocument(IProject project, IProjectItem projectItem, ITextBuffer textBuffer, bool isReadOnly, Encoding encoding)
        {
            IProjectContext   projectContext    = (IProjectContext)ProjectXamlContext.GetProjectContext(project);
            DocumentReference documentReference = projectItem.DocumentReference;
            DocumentContext   documentContext   = DocumentContextHelper.CreateDocumentContext(project, projectContext, DocumentReferenceLocator.GetDocumentLocator(documentReference), projectItem.Properties["BuildAction"] == "Content");
            SceneXamlDocument xamlDocument      = new SceneXamlDocument((IDocumentContext)documentContext, (IUndoService) new UndoService(), PlatformTypes.Object, textBuffer, encoding);

            if (xamlDocument.ParseErrorsCount > 0)
            {
                IErrorService errorManager = this.designerContext.ErrorManager;
                if (errorManager != null)
                {
                    errorManager.DisplayErrors();
                }
            }
            SceneDocument sceneDocument = this.CreateSceneDocument(documentReference, xamlDocument, isReadOnly, this.designerContext);

            documentContext.DocumentLocator = (IDocumentLocator)sceneDocument;
            return(sceneDocument);
        }