Browse Source

remove duplicate condition

pull/5038/head
Andrey Kunchev 5 years ago
parent
commit
979a659b49
  1. 33
      src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs

33
src/Markup/Avalonia.Markup.Xaml.Loader/CompilerExtensions/XamlIlBindingPathHelper.cs

@ -198,24 +198,21 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
case BindingExpressionGrammar.AncestorNode ancestor:
if (ancestor.Namespace is null && ancestor.TypeName is null)
{
if (ancestor.Namespace is null && ancestor.TypeName is null)
var styledElementType = context.GetAvaloniaTypes().StyledElement;
var ancestorType = context
.ParentNodes()
.OfType<XamlAstConstructableObjectNode>()
.Where(x => styledElementType.IsAssignableFrom(x.Type.GetClrType()))
.Skip(1)
.ElementAtOrDefault(ancestor.Level)
?.Type.GetClrType();
if (ancestorType is null)
{
var styledElementType = context.GetAvaloniaTypes().StyledElement;
var ancestorType = context
.ParentNodes()
.OfType<XamlAstConstructableObjectNode>()
.Where(x => styledElementType.IsAssignableFrom(x.Type.GetClrType()))
.Skip(1)
.ElementAtOrDefault(ancestor.Level)
?.Type.GetClrType();
if (ancestorType is null)
{
throw new XamlX.XamlParseException("Unable to resolve implicit ancestor type based on XAML tree.", lineInfo);
}
nodes.Add(new FindAncestorPathElementNode(ancestorType, ancestor.Level));
throw new XamlX.XamlParseException("Unable to resolve implicit ancestor type based on XAML tree.", lineInfo);
}
nodes.Add(new FindAncestorPathElementNode(ancestorType, ancestor.Level));
}
else
{
@ -622,10 +619,10 @@ namespace Avalonia.Markup.Xaml.XamlIl.CompilerExtensions
private readonly IXamlAstValueNode _rawSource;
public RawSourcePathElementNode(IXamlAstValueNode rawSource)
:base(rawSource)
: base(rawSource)
{
_rawSource = rawSource;
}
public IXamlType Type => _rawSource.Type.GetClrType();

Loading…
Cancel
Save