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