public void AddTypedProperty1() { var col = new PropertyCollection(); col.AddTypedProperty("foo"); Assert.AreEqual(1, col.PropertyList.Count); Assert.IsTrue(col.ContainsProperty(typeof(string))); }
public static void RemovePropertySafe(this PropertyCollection collection, string key) { if (key.IsNullOrWhiteSpace() || !collection.ContainsProperty(key)) { return; } collection.RemoveProperty(key); }
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); }
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); }
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))); }