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

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

            collection.RemoveProperty(key);
        }
Example #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);
        }
Example #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);
        }
Example #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)));
        }