Browse Source

Merge branch 'master' into refactor-styling-type-info

pull/3486/head
Steven Kirk 6 years ago
committed by GitHub
parent
commit
ce4acf3705
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/Avalonia.Controls/Templates/FuncDataTemplate.cs
  2. 3
      src/Avalonia.Controls/Templates/FuncTreeDataTemplate.cs
  3. 10
      src/Avalonia.Controls/Utils/AncestorFinder.cs

3
src/Avalonia.Controls/Templates/FuncDataTemplate.cs

@ -3,7 +3,6 @@
using System;
using System.Reactive.Linq;
using System.Reflection;
namespace Avalonia.Controls.Templates
{
@ -102,7 +101,7 @@ namespace Avalonia.Controls.Templates
/// </returns>
private static bool IsInstance(object o, Type t)
{
return (o != null) && t.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo());
return t.IsInstanceOfType(o);
}
}
}

3
src/Avalonia.Controls/Templates/FuncTreeDataTemplate.cs

@ -3,7 +3,6 @@
using System;
using System.Collections;
using System.Reflection;
using Avalonia.Data;
namespace Avalonia.Controls.Templates
@ -75,7 +74,7 @@ namespace Avalonia.Controls.Templates
/// </returns>
private static bool IsInstance(object o, Type t)
{
return (o != null) && t.GetTypeInfo().IsAssignableFrom(o.GetType().GetTypeInfo());
return t.IsInstanceOfType(o);
}
}
}

10
src/Avalonia.Controls/Utils/AncestorFinder.cs

@ -1,10 +1,8 @@
using System;
using System.Linq;
using System.Reactive;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reflection;
namespace Avalonia.Controls.Utils
{
@ -13,14 +11,14 @@ namespace Avalonia.Controls.Utils
class FinderNode : IDisposable
{
private readonly IStyledElement _control;
private readonly TypeInfo _ancestorType;
private readonly Type _ancestorType;
public IObservable<IStyledElement> Observable => _subject;
private readonly Subject<IStyledElement> _subject = new Subject<IStyledElement>();
private FinderNode _child;
private IDisposable _disposable;
public FinderNode(IStyledElement control, TypeInfo ancestorType)
public FinderNode(IStyledElement control, Type ancestorType)
{
_control = control;
_ancestorType = ancestorType;
@ -33,7 +31,7 @@ namespace Avalonia.Controls.Utils
private void OnValueChanged(IStyledElement next)
{
if (next == null || _ancestorType.IsAssignableFrom(next.GetType().GetTypeInfo()))
if (next == null || _ancestorType.IsAssignableFrom(next.GetType()))
_subject.OnNext(next);
else
{
@ -63,7 +61,7 @@ namespace Avalonia.Controls.Utils
{
return new AnonymousObservable<IStyledElement>(observer =>
{
var finder = new FinderNode(control, ancestorType.GetTypeInfo());
var finder = new FinderNode(control, ancestorType);
var subscription = finder.Observable.Subscribe(observer);
finder.Init();

Loading…
Cancel
Save