object IPropertyCollection.GetProperty(object key) { lock (this) { return(_properties.GetProperty(key)); } }
public void GetProperty_WhenCalledTwice_ReturnsSameProperty() { var propertyA = collection.GetProperty(StringADefinition); var propertyB = collection.GetProperty(StringADefinition); Assert.AreEqual(propertyA, propertyB); }
public object this[object key] { get { return(_properties.GetProperty(key)); } set { _properties.SetProperty(key, value); } }
static void TestRemove(ref PropertyCollection collection, int count) { for (int i = 0; i < count; i++) { collection.RemoveProperty(i); Assert.AreEqual(collection.GetProperty(i), null); } }
static void TestAdd(ref PropertyCollection collection, int count) { for (int i = 0; i < count; i++) { collection.SetProperty(i, i); Assert.AreEqual(collection.GetProperty(i), i); } }
public void Validate_WhenCollectionHasOptionalProperty_ReturnsTrue() { var schema = new PropertyCollectionSchemaBuilder() .Add(new PropertyCollectionSchemaEntryBuilder(SharedDefinition)) .Build(); var collection = new PropertyCollection(); collection.GetProperty(SharedDefinition); Assert.IsTrue(schema.Validate(collection)); }
public void PropertyCollectionTest() { var collection = new PropertyCollection(); for (int pass = 1; pass < 100; pass++) { collection.ClearProperties(); Assert.AreEqual(collection.Count, 0); int count = pass * 2; TestAdd(ref collection, count); Assert.AreEqual(collection.Count, count); TestRemove(ref collection, count); Assert.AreEqual(collection.Count, 0); TestAdd(ref collection, count); Assert.AreEqual(collection.Count, count); // delete every second property for (int i = 0; i < count; i += 2) { collection.RemoveProperty(i); Assert.AreEqual(collection.GetProperty(i), null); } Assert.AreEqual(collection.Count, count / 2); // test property replacement for (int i = 1; i < count; i += 2) { collection.SetProperty(i, i * 2); Assert.AreEqual(collection.GetProperty(i), i * 2); } Assert.AreEqual(collection.Count, count / 2); } }
public void PropertyCollectionTest() { var collection = new PropertyCollection(); for (int pass = 1; pass < 100; pass++) { collection.ClearProperties(); Assert.AreEqual(collection.Count, 0); int count = pass * 2; TestAdd(ref collection, count); Assert.AreEqual(collection.Count, count); TestRemove(ref collection, count); Assert.AreEqual(collection.Count, 0); TestAdd(ref collection, count); Assert.AreEqual(collection.Count, count); // delete every second property for (int i = 0; i < count; i+=2) { collection.RemoveProperty(i); Assert.AreEqual(collection.GetProperty(i), null); } Assert.AreEqual(collection.Count, count / 2); // test property replacement for (int i = 1; i < count; i += 2) { collection.SetProperty(i, i * 2); Assert.AreEqual(collection.GetProperty(i), i * 2); } Assert.AreEqual(collection.Count, count / 2); } }
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 CommandProperty(string parameters, Recipe recipe) : base(parameters, recipe) { Match match = pattern.Match(parameters); if (!match.Success) { throw new ArgumentException( $"Failed to initialise command {CommandName} with parameters {parameters.Trim()}!"); } Property = PropertyCollection.GetProperty(match.Groups["name"].Value, match.Groups["value"].Value); if (Property == null) { throw new ArgumentException($"Failed to initialise command {CommandName}'s property!"); } Name = match.Groups["name"].Value; }
public void Validate_WhenCollectionHasPropertyOfWrongType_ReturnsFalse() { var sharedName = "ConflictingProperty"; var existingDefinition = new PropertyDefinition <string>(sharedName); var schemaDefinition = new PropertyDefinition <int>(sharedName); var schema = new PropertyCollectionSchemaBuilder() .Add(new PropertyCollectionSchemaEntryBuilder(schemaDefinition)) .Build(); var collection = new PropertyCollection(); collection.GetProperty(existingDefinition); Assert.IsFalse(schema.Validate(collection)); }
public void SetPropertyCollection(PropertyCollection props) { Clear(); foreach (var type in _propsOrder) { var prop = props.GetProperty(type); if (prop == null) { continue; } var item = Instantiate(_propertyItemTemplate, _propertyItemTemplate.parent, false); item.gameObject.SetActive(true); var txtName = item.transform.Find("Name").GetComponent <Text>(); var txtValue = item.transform.Find("Value").GetComponent <Text>(); txtName.text = prop.Name; txtValue.text = prop.ToString(); } }
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 TestViewCreatedSetsNextHandlerOfTemplateCompletionHandler() { 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); var handler = (TemplateCompletionHandler)viewProperties.GetProperty(typeof(TemplateCompletionHandler)); viewAdapter.Received().AddCommandFilter(handler, out handler.NextHandler); }
private static Speech GetResponse(PropertyCollection properties) { string property = properties.GetProperty(PropertyId.SpeechServiceResponse_JsonResult); return(JsonConvert.DeserializeObject <Speech>(property)); }
public static void TestViewCreatedSetsNextHandlerOfTemplateCompletionHandler() { 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); var handler = (TemplateCompletionHandler)viewProperties.GetProperty(typeof(TemplateCompletionHandler)); viewAdapter.Received().AddCommandFilter(handler, out handler.NextHandler); }
public static T GetProperty <T>(this PropertyCollection collection) { return(collection.GetProperty <T>(typeof(T))); }
/// <summary> /// Gets the property value for the specified key. A list of standard keys are accessible from <see cref="MaterialKeys"/>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key">The key.</param> /// <returns>``0.</returns> public T GetProperty <T>(PropertyKey <T> key) { return(Properties.GetProperty(key)); }
public void Constructor_AddCommentOwnerToTextBufferProperties() { // then Assert.AreEqual(tagger, properties.GetProperty(PeerReviewConstants.COMMENT_OWNER)); }
public Property GetProperty(PropertyType type) => _props.GetProperty(type);