How to determine if a object type is a built in system type

前端 未结 8 980
醉酒成梦
醉酒成梦 2020-12-14 00:20

I am writing a simple List to CSV converter. My converter checks the all the t\'s in List and grabs all public properties and places them

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-14 01:00

    Given the caveats surrounding the existing answers, I am going to suggest a Windows only solution:

    public static class TypeExt {
        public static bool IsBuiltin(this Type aType) => new[] { "/dotnet/shared/microsoft", "/windows/microsoft.net" }.Any(p => aType.Assembly.CodeBase.ToLowerInvariant().Contains(p));
    }
    

    Presumably there is a similar path on other supported operating systems.

提交回复
热议问题