Skip to content

Commit

Permalink
Removed unused field.
Browse files Browse the repository at this point in the history
  • Loading branch information
grokys committed Jan 20, 2020
1 parent f7f9e41 commit 270f971
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
9 changes: 2 additions & 7 deletions src/Avalonia.Base/PropertyStore/PriorityValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,23 @@ namespace Avalonia.PropertyStore
{
internal class PriorityValue<T> : IValue<T>, IValueSink
{
private readonly IAvaloniaObject _owner;
private readonly IValueSink _sink;
private readonly List<IPriorityValueEntry<T>> _entries = new List<IPriorityValueEntry<T>>();
private Optional<T> _localValue;

public PriorityValue(
IAvaloniaObject owner,
StyledPropertyBase<T> property,
IValueSink sink)
{
_owner = owner;
Property = property;
_sink = sink;
}

public PriorityValue(
IAvaloniaObject owner,
StyledPropertyBase<T> property,
IValueSink sink,
IPriorityValueEntry<T> existing)
: this(owner, property, sink)
: this(property, sink)
{
existing.Reparent(this);
_entries.Add(existing);
Expand All @@ -41,11 +37,10 @@ public PriorityValue(
}

public PriorityValue(
IAvaloniaObject owner,
StyledPropertyBase<T> property,
IValueSink sink,
LocalValueEntry<T> existing)
: this(owner, property, sink)
: this(property, sink)
{
_localValue = existing.Value;
Value = _localValue;
Expand Down
8 changes: 4 additions & 4 deletions src/Avalonia.Base/ValueStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private void SetExisting<T>(
{
if (slot is IPriorityValueEntry<T> e)
{
var priorityValue = new PriorityValue<T>(_owner, property, this, e);
var priorityValue = new PriorityValue<T>(property, this, e);
_values.SetValue(property, priorityValue);
priorityValue.SetValue(value, priority);
}
Expand All @@ -192,7 +192,7 @@ private void SetExisting<T>(
}
else
{
var priorityValue = new PriorityValue<T>(_owner, property, this, l);
var priorityValue = new PriorityValue<T>(property, this, l);
_values.SetValue(property, priorityValue);
}
}
Expand All @@ -212,15 +212,15 @@ private IDisposable BindExisting<T>(

if (slot is IPriorityValueEntry<T> e)
{
priorityValue = new PriorityValue<T>(_owner, property, this, e);
priorityValue = new PriorityValue<T>(property, this, e);
}
else if (slot is PriorityValue<T> p)
{
priorityValue = p;
}
else if (slot is LocalValueEntry<T> l)
{
priorityValue = new PriorityValue<T>(_owner, property, this, l);
priorityValue = new PriorityValue<T>(property, this, l);
}
else
{
Expand Down
21 changes: 9 additions & 12 deletions tests/Avalonia.Base.UnitTests/PriorityValueTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public class PriorityValueTests
public void Constructor_Should_Set_Value_Based_On_Initial_Entry()
{
var target = new PriorityValue<string>(
Owner,
TestProperty,
NullSink,
new ConstantValueEntry<string>(TestProperty, "1", BindingPriority.StyleTrigger));
Expand All @@ -34,7 +33,6 @@ public void Constructor_Should_Set_Value_Based_On_Initial_Entry()
public void SetValue_LocalValue_Should_Not_Add_Entries()
{
var target = new PriorityValue<string>(
Owner,
TestProperty,
NullSink);

Expand All @@ -48,7 +46,6 @@ public void SetValue_LocalValue_Should_Not_Add_Entries()
public void SetValue_Non_LocalValue_Should_Add_Entries()
{
var target = new PriorityValue<string>(
Owner,
TestProperty,
NullSink);

Expand All @@ -66,7 +63,7 @@ public void SetValue_Non_LocalValue_Should_Add_Entries()
[Fact]
public void Binding_With_Same_Priority_Should_Be_Appended()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");
var source2 = new Source("2");

Expand All @@ -86,7 +83,7 @@ public void Binding_With_Same_Priority_Should_Be_Appended()
[Fact]
public void Binding_With_Higher_Priority_Should_Be_Appended()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");
var source2 = new Source("2");

Expand All @@ -106,7 +103,7 @@ public void Binding_With_Higher_Priority_Should_Be_Appended()
[Fact]
public void Binding_With_Lower_Priority_Should_Be_Prepended()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");
var source2 = new Source("2");

Expand All @@ -126,7 +123,7 @@ public void Binding_With_Lower_Priority_Should_Be_Prepended()
[Fact]
public void Second_Binding_With_Lower_Priority_Should_Be_Inserted_In_Middle()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");
var source2 = new Source("2");
var source3 = new Source("3");
Expand All @@ -148,7 +145,7 @@ public void Second_Binding_With_Lower_Priority_Should_Be_Inserted_In_Middle()
[Fact]
public void Competed_Binding_Should_Be_Removed()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");
var source2 = new Source("2");
var source3 = new Source("3");
Expand All @@ -171,7 +168,7 @@ public void Competed_Binding_Should_Be_Removed()
[Fact]
public void Value_Should_Come_From_Last_Entry()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");
var source2 = new Source("2");
var source3 = new Source("3");
Expand All @@ -186,7 +183,7 @@ public void Value_Should_Come_From_Last_Entry()
[Fact]
public void LocalValue_Should_Override_LocalValue_Binding()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");

target.AddBinding(source1, BindingPriority.LocalValue).Start();
Expand All @@ -198,7 +195,7 @@ public void LocalValue_Should_Override_LocalValue_Binding()
[Fact]
public void LocalValue_Should_Override_Style_Binding()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");

target.AddBinding(source1, BindingPriority.Style).Start();
Expand All @@ -210,7 +207,7 @@ public void LocalValue_Should_Override_Style_Binding()
[Fact]
public void LocalValue_Should_Not_Override_Animation_Binding()
{
var target = new PriorityValue<string>(Owner, TestProperty, NullSink);
var target = new PriorityValue<string>(TestProperty, NullSink);
var source1 = new Source("1");

target.AddBinding(source1, BindingPriority.Animation).Start();
Expand Down

0 comments on commit 270f971

Please sign in to comment.