Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions src/Controls/src/Core/BindableObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,51 @@ public object GetValue(BindableProperty property)
return context == null ? property.DefaultValue : context.Values.GetValue();
}

// Used by Visual Studio Live Property Explorer via reflection; do not remove without coordinating with VS.
internal LocalValueEnumerator GetLocalValueEnumerator() => new LocalValueEnumerator(this);

internal sealed class LocalValueEnumerator : IEnumerator<LocalValueEntry>
{
Dictionary<int, BindablePropertyContext>.ValueCollection.Enumerator _propertiesEnumerator;
internal LocalValueEnumerator(BindableObject bindableObject) => _propertiesEnumerator = bindableObject._properties.Values.GetEnumerator();

object IEnumerator.Current => Current;
public LocalValueEntry Current { get; private set; }

public bool MoveNext()
{
if (_propertiesEnumerator.MoveNext())
{
var context = _propertiesEnumerator.Current;
Current = new LocalValueEntry(context.Property, context.Values.GetValue(), context.Attributes);
return true;
}
return false;
}

public void Dispose() => _propertiesEnumerator.Dispose();

void IEnumerator.Reset()
{
((IEnumerator)_propertiesEnumerator).Reset();
Current = null;
}
}

internal sealed class LocalValueEntry
{
internal LocalValueEntry(BindableProperty property, object value, BindableContextAttributes attributes)
{
Property = property;
Value = value;
Attributes = attributes;
}

public BindableProperty Property { get; }
public object Value { get; }
public BindableContextAttributes Attributes { get; }
}

internal (bool IsSet, T Value)[] GetValues<T>(BindableProperty[] propArray)
{
var properties = _properties;
Expand Down
Loading