IntrospectionExtensions.cs 654 B

1234567891011121314151617181920212223
  1. // Licensed to the .NET Foundation under one or more agreements.
  2. // The .NET Foundation licenses this file to you under the MIT license.
  3. // See the LICENSE file in the project root for more information.
  4. using System.Diagnostics;
  5. namespace System.Reflection
  6. {
  7. public static class IntrospectionExtensions
  8. {
  9. public static TypeInfo GetTypeInfo(this Type type)
  10. {
  11. if (type == null)
  12. throw new ArgumentNullException(nameof(type));
  13. if (type is IReflectableType reflectableType)
  14. return reflectableType.GetTypeInfo();
  15. return new TypeDelegator(type);
  16. }
  17. }
  18. }