Browse Source
Match selectors from left-to-right, as before we were checking things like property equality (and creating a `PropertyEqualsActivator`) before checking that the control is of the correct type. Also hopefully makes the selector matching logic more readable.pull/3636/head
6 changed files with 171 additions and 66 deletions
@ -0,0 +1,36 @@ |
|||||
|
#nullable enable |
||||
|
|
||||
|
namespace Avalonia.Styling.Activators |
||||
|
{ |
||||
|
internal struct AndActivatorBuilder |
||||
|
{ |
||||
|
private IStyleActivator? _single; |
||||
|
private AndActivator? _multiple; |
||||
|
|
||||
|
public void Add(IStyleActivator? activator) |
||||
|
{ |
||||
|
if (activator == null) |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
if (_single is null && _multiple is null) |
||||
|
{ |
||||
|
_single = activator; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (_multiple is null) |
||||
|
{ |
||||
|
_multiple = new AndActivator(); |
||||
|
_multiple.Add(_single!); |
||||
|
_single = null; |
||||
|
} |
||||
|
|
||||
|
_multiple.Add(activator); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public IStyleActivator Get() => _single ?? _multiple!; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue