Browse Source

Merge pull request #3493 from MarchingCube/refactor-type-info-bulk

Remove TypeInfo usage from multiple projects.
pull/3507/head
Jumar Macato 7 years ago
committed by GitHub
parent
commit
a2307244ab
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      src/Avalonia.Interactivity/RoutedEvent.cs
  2. 4
      src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs
  3. 4
      src/Avalonia.Visuals/VisualTree/VisualLocator.cs
  4. 3
      src/Markup/Avalonia.Markup.Xaml/Templates/DataTemplate.cs
  5. 5
      src/Markup/Avalonia.Markup.Xaml/Templates/TreeDataTemplate.cs

3
src/Avalonia.Interactivity/RoutedEvent.cs

@ -3,7 +3,6 @@
using System; using System;
using System.Reactive.Subjects; using System.Reactive.Subjects;
using System.Reflection;
namespace Avalonia.Interactivity namespace Avalonia.Interactivity
{ {
@ -29,7 +28,7 @@ namespace Avalonia.Interactivity
Contract.Requires<ArgumentNullException>(name != null); Contract.Requires<ArgumentNullException>(name != null);
Contract.Requires<ArgumentNullException>(eventArgsType != null); Contract.Requires<ArgumentNullException>(eventArgsType != null);
Contract.Requires<ArgumentNullException>(ownerType != null); Contract.Requires<ArgumentNullException>(ownerType != null);
Contract.Requires<InvalidCastException>(typeof(RoutedEventArgs).GetTypeInfo().IsAssignableFrom(eventArgsType.GetTypeInfo())); Contract.Requires<InvalidCastException>(typeof(RoutedEventArgs).IsAssignableFrom(eventArgsType));
EventArgsType = eventArgsType; EventArgsType = eventArgsType;
Name = name; Name = name;

4
src/Avalonia.ReactiveUI/AvaloniaActivationForViewFetcher.cs

@ -2,9 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using System.Reflection;
using System.Reactive.Linq; using System.Reactive.Linq;
using Avalonia;
using Avalonia.VisualTree; using Avalonia.VisualTree;
using Avalonia.Controls; using Avalonia.Controls;
using ReactiveUI; using ReactiveUI;
@ -21,7 +19,7 @@ namespace Avalonia.ReactiveUI
/// </summary> /// </summary>
public int GetAffinityForView(Type view) public int GetAffinityForView(Type view)
{ {
return typeof(IVisual).GetTypeInfo().IsAssignableFrom(view.GetTypeInfo()) ? 10 : 0; return typeof(IVisual).IsAssignableFrom(view) ? 10 : 0;
} }
/// <summary> /// <summary>

4
src/Avalonia.Visuals/VisualTree/VisualLocator.cs

@ -1,7 +1,5 @@
using System; using System;
using System.Linq; using System.Linq;
using System.Reactive.Linq;
using System.Reflection;
using Avalonia.Reactive; using Avalonia.Reactive;
namespace Avalonia.VisualTree namespace Avalonia.VisualTree
@ -50,7 +48,7 @@ namespace Avalonia.VisualTree
if (_relativeTo.IsAttachedToVisualTree) if (_relativeTo.IsAttachedToVisualTree)
{ {
return _relativeTo.GetVisualAncestors() return _relativeTo.GetVisualAncestors()
.Where(x => _ancestorType?.GetTypeInfo().IsAssignableFrom(x.GetType().GetTypeInfo()) ?? true) .Where(x => _ancestorType?.IsAssignableFrom(x.GetType()) ?? true)
.ElementAtOrDefault(_ancestorLevel); .ElementAtOrDefault(_ancestorLevel);
} }
else else

3
src/Markup/Avalonia.Markup.Xaml/Templates/DataTemplate.cs

@ -2,7 +2,6 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using System.Reflection;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Templates; using Avalonia.Controls.Templates;
using Avalonia.Metadata; using Avalonia.Metadata;
@ -28,7 +27,7 @@ namespace Avalonia.Markup.Xaml.Templates
} }
else else
{ {
return DataType.GetTypeInfo().IsAssignableFrom(data.GetType().GetTypeInfo()); return DataType.IsInstanceOfType(data);
} }
} }

5
src/Markup/Avalonia.Markup.Xaml/Templates/TreeDataTemplate.cs

@ -2,12 +2,9 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information. // Licensed under the MIT license. See licence.md file in the project root for full license information.
using System; using System;
using System.Reflection;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Templates; using Avalonia.Controls.Templates;
using Avalonia.Data; using Avalonia.Data;
using Avalonia.Data.Core;
using Avalonia.Markup.Data;
using Avalonia.Markup.Parsers; using Avalonia.Markup.Parsers;
using Avalonia.Metadata; using Avalonia.Metadata;
@ -34,7 +31,7 @@ namespace Avalonia.Markup.Xaml.Templates
} }
else else
{ {
return DataType.GetTypeInfo().IsAssignableFrom(data.GetType().GetTypeInfo()); return DataType.IsInstanceOfType(data);
} }
} }

Loading…
Cancel
Save