Exemple #1
0
        protected EditorViewModel(IEditorDocument document, IEditorBuffer viewBuffer = null)
        {
            Check.ArgumentNull(nameof(document), document);

            DiskBuffer = document.EditorBuffer;
            DiskBuffer.AddService(this);

            ViewBuffer = viewBuffer ?? DiskBuffer;
            if (viewBuffer != null)
            {
                ViewBuffer.AddService(this);
            }

            _document = document;
        }
Exemple #2
0
        public ProjectionBufferManager(ITextBuffer diskBuffer, IServiceContainer services, string topLevelContentTypeName, string secondaryContentTypeName)
        {
            DiskBuffer = diskBuffer;

            var projectionBufferFactoryService = services.GetService <IProjectionBufferFactoryService>();
            var contentTypeRegistryService     = services.GetService <IContentTypeRegistryService>();

            var contentType = contentTypeRegistryService.GetContentType(topLevelContentTypeName);

            ViewBuffer = projectionBufferFactoryService.CreateProjectionBuffer(null, new List <object>(0), ProjectionBufferOptions.None, contentType);
            EditorBuffer.Create(ViewBuffer, services.GetService <ITextDocumentFactoryService>());

            contentType             = contentTypeRegistryService.GetContentType(secondaryContentTypeName);
            ContainedLanguageBuffer = projectionBufferFactoryService.CreateProjectionBuffer(null, new List <object>(0), ProjectionBufferOptions.WritableLiteralSpans, contentType);

            DiskBuffer.AddService(this);
            ViewBuffer.AddService(this);
        }