Skip to content

Commit

Permalink
Add PropertyCollection indexer property
Browse files Browse the repository at this point in the history
  • Loading branch information
Exanite committed Jul 11, 2024
1 parent 6b6b12d commit 757454e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Properties/PropertyCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,20 @@ public class PropertyCollection

public event EventHandler<PropertyCollection, PropertyValueChangedEventArgs<object>>? PropertyValueChanged;

public object? this[PropertyDefinition definition]
{
get
{
var property = GetOrAddProperty(definition);
return property.UntypedValue;
}
set
{
var property = GetOrAddProperty(definition);
property.UntypedValue = value;
}
}

public T? GetPropertyValue<T>(PropertyDefinition<T> definition, bool addIfDoesNotExist = false)
{
var property = addIfDoesNotExist ? GetOrAddProperty(definition) : GetProperty(definition);
Expand Down

0 comments on commit 757454e

Please sign in to comment.