От: | Serginio1 | https://habrahabr.ru/users/serginio1/topics/ | |
Дата: | 02.08.19 10:39 | ||
Оценка: |
IB>Применяется к
IB>.NET Core
IB>3.0 Preview 7 2.2 2.1 2.0 1.1 1.0
IB>.NET Standard
IB>2.1 Preview 2.0 1.6 1.5 1.4 1.3 1.2 1.1 1.0
public ИнформацияОТипеПараметра(Type type)
{
var TI = type.GetTypeInfo();
IsByRef = TI.IsByRef;
IsGenericType = (TI.IsGenericType && TI.IsGenericTypeDefinition) || TI.ContainsGenericParameters;
if (IsByRef)
{
Тип = type.GetElementType();
TI = Тип.GetTypeInfo();
}
else
Тип = type;
IsValue = TI.IsValueType;
if (IsValue)
{
УровеньИерархии = 0;
if (TI.IsGenericType && TI.GetGenericTypeDefinition() == typeof(Nullable<>))
{
IsNullable = true;
Тип = TI.GenericTypeArguments[0];
}
}
else
УровеньИерархии = НайтиУровень(0, Тип);
}