示例#1
0
        RoslynCodeDocument CreateDocument(ProjectId projectId, string nameNoExtension)
        {
            var options = new CodeEditorOptions();

            options.ContentTypeString = ContentType;
            var codeEditor = codeEditorProvider.Create(options);

            codeEditor.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategory);
            codeEditor.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, true);

            var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(projectId), nameNoExtension + FileExtension, null, SourceCodeKind.Regular, TextLoader.From(codeEditor.TextBuffer.AsTextContainer(), VersionStamp.Default));

            return(new RoslynCodeDocument(codeEditor, documentInfo, nameNoExtension));
        }
示例#2
0
        RoslynCodeDocument CreateDocument(ProjectId projectId, CompilerDocumentInfo doc)
        {
            var options = new CodeEditorOptions();

            options.ContentTypeString = ContentType;
            options.Roles.Add(PredefinedDsTextViewRoles.RoslynCodeEditor);
            options.Roles.Add(TextViewRole);
            var codeEditor = codeEditorProvider.Create(options);

            codeEditor.TextView.Options.SetOptionValue(DefaultWpfViewOptions.AppearanceCategory, AppearanceCategory);
            codeEditor.TextView.Options.SetOptionValue(DefaultTextViewHostOptions.GlyphMarginId, true);

            var textBuffer = codeEditor.TextView.TextBuffer;

            textBuffer.Replace(new Span(0, textBuffer.CurrentSnapshot.Length), doc.Code);

            var documentInfo = DocumentInfo.Create(DocumentId.CreateNewId(projectId), doc.Name, null, SourceCodeKind.Regular, TextLoader.From(codeEditor.TextBuffer.AsTextContainer(), VersionStamp.Create()));

            return(new RoslynCodeDocument(codeEditor, documentInfo));
        }