示例#1
0
 public void AddTypedProperty1()
 {
     var col = new PropertyCollection();
     col.AddTypedProperty("foo");
     Assert.AreEqual(1, col.PropertyList.Count);
     Assert.IsTrue(col.ContainsProperty(typeof(string)));
 }
示例#2
0
        public void AddTypedProperty1()
        {
            var col = new PropertyCollection();

            col.AddTypedProperty("foo");
            Assert.AreEqual(1, col.PropertyList.Count);
            Assert.IsTrue(col.ContainsProperty(typeof(string)));
        }
示例#3
0
        public static void RemovePropertySafe(this PropertyCollection collection, string key)
        {
            if (key.IsNullOrWhiteSpace() || !collection.ContainsProperty(key))
            {
                return;
            }

            collection.RemoveProperty(key);
        }
示例#4
0
        public static bool TryDisposeListProperty(this PropertyCollection collection, string key, bool removeProperty = true)
        {
            if (!collection.ContainsProperty(key))
            {
                return(false);
            }

            collection.GetProperty <List <IDisposable> >(key)?.DisposeAll();
            if (removeProperty)
            {
                collection.RemoveProperty(key);
            }

            return(true);
        }
示例#5
0
        public static bool TryDisposeProperty <T>(this PropertyCollection collection, string key, bool removeProperty = true)
            where T : IDisposable
        {
            if (!collection.ContainsProperty(key))
            {
                return(false);
            }

            var property = collection.GetProperty <T>(key);

            property?.Dispose();
            ;
            if (removeProperty)
            {
                collection.RemoveProperty(key);
            }

            return(true);
        }
示例#6
0
        public static void TextViewCreatedCreatesTemplateCompletionHandlerWhenViewAdapterHasTextView()
        {
            var viewProperties = new PropertyCollection();

            var view = Substitute.For <IWpfTextView>();

            view.Properties.Returns(viewProperties);

            var viewAdapter = Substitute.For <IVsTextView>();

            var adapterFactory = Substitute.For <IVsEditorAdaptersFactoryService>();

            adapterFactory.GetWpfTextView(viewAdapter).Returns(view);

            ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true);

            var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For <SVsServiceProvider>(), Substitute.For <ICompletionBroker>());

            provider.VsTextViewCreated(viewAdapter);

            Assert.True(viewProperties.ContainsProperty(typeof(TemplateCompletionHandler)));
        }
        public static void TextViewCreatedCreatesTemplateCompletionHandlerWhenViewAdapterHasTextView()
        {
            var viewProperties = new PropertyCollection();
            
            var view = Substitute.For<IWpfTextView>();
            view.Properties.Returns(viewProperties);

            var viewAdapter = Substitute.For<IVsTextView>();

            var adapterFactory = Substitute.For<IVsEditorAdaptersFactoryService>();
            adapterFactory.GetWpfTextView(viewAdapter).Returns(view);

            ITemplateEditorOptions options = OptionsWithCompletionListsEnabled(true);

            var provider = new TemplateCompletionHandlerProvider(options, adapterFactory, Substitute.For<SVsServiceProvider>(), Substitute.For<ICompletionBroker>());

            provider.VsTextViewCreated(viewAdapter);

            Assert.True(viewProperties.ContainsProperty(typeof(TemplateCompletionHandler)));
        }