Welcome to mirror list, hosted at ThFree Co, Russian Federation.

WhitespaceManagerFactory.cs « TextModel « Impl « Text « Editor « src - github.com/microsoft/vs-editor-api.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 86cfc24540183c01ceb3443791bfa2576247378d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Primitives;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.VisualStudio.Text.Document;

namespace Microsoft.VisualStudio.Text.Implementation
{
    [Export(typeof(IWhitespaceManagerFactory))]
    internal class WhitespaceManagerFactory : IWhitespaceManagerFactory
    {
        public IWhitespaceManager GetOrCreateWhitespaceManager(
            ITextBuffer buffer,
            NewlineState initialNewlineState,
            LeadingWhitespaceState initialLeadingWhitespaceState)
        {
            return buffer.Properties.GetOrCreateSingletonProperty(
                typeof(IWhitespaceManager),
                () => new WhitespaceManager(buffer, initialNewlineState, initialLeadingWhitespaceState));
        }

        public bool TryGetExistingWhitespaceManager(ITextBuffer buffer, out IWhitespaceManager manager)
        {
            return buffer.Properties.TryGetProperty(typeof(IWhitespaceManager), out manager);
        }
    }
}