IntrospectionExtensions.cs 626 B

1234567891011121314151617181920
  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. namespace System.Reflection
  5. {
  6. public static class IntrospectionExtensions
  7. {
  8. public static TypeInfo GetTypeInfo(this Type type)
  9. {
  10. if (type == null)
  11. throw new ArgumentNullException(nameof(type));
  12. if (type is IReflectableType reflectableType)
  13. return reflectableType.GetTypeInfo();
  14. return new TypeDelegator(type);
  15. }
  16. }
  17. }