예제 #1
0
 public ExtendedType(
     Type type,
     bool isNullable,
     ExtendedTypeKind kind)
     : this(type, isNullable, kind, Array.Empty <IExtendedType>())
 {
 }
예제 #2
0
        private ExtendedType(
            Type type,
            ExtendedTypeKind kind,
            IReadOnlyList <ExtendedType>?typeArguments = null,
            Type?source              = null,
            Type?definition          = null,
            ExtendedType?elementType = null,
            bool isList              = false,
            bool isNamedType         = false,
            bool isNullable          = false)
        {
            Type          = type;
            Kind          = kind;
            TypeArguments = typeArguments ?? Array.Empty <ExtendedType>();
            Source        = source ?? type;
            Definition    = definition;
            ElementType   = elementType;
            IsList        = isList;
            IsNamedType   = isNamedType;
            IsNullable    = isNullable;

            if (type.IsGenericType && definition is null)
            {
                Definition = type.GetGenericTypeDefinition();
            }

            Id = Helper.CreateIdentifier(this);
        }
 private static ExtendedTypeId CreateIdentifier(
     Type source,
     ExtendedTypeKind kind,
     ReadOnlySpan <bool> nullability)
 {
     return(new ExtendedTypeId(
                source,
                kind,
                CompactNullability(nullability)));
 }
예제 #4
0
        public ExtendedType(
            Type type,
            bool isNullable,
            ExtendedTypeKind kind,
            IReadOnlyList <IExtendedType> typeArguments)
        {
            Type          = type ?? throw new ArgumentNullException(nameof(type));
            IsNullable    = isNullable;
            Kind          = kind;
            TypeArguments = typeArguments ?? throw new ArgumentNullException(nameof(typeArguments));

            if (kind == ExtendedTypeKind.Unknown)
            {
                if (type.IsGenericType && typeArguments.Count == 0)
                {
                    Type[] arguments         = type.GetGenericArguments();
                    var    extendedArguments = new IExtendedType[arguments.Length];
                    for (int i = 0; i < extendedArguments.Length; i++)
                    {
                        extendedArguments[i] = FromType(arguments[i]);
                    }
                    TypeArguments = extendedArguments;
                }
                else if (type.IsArray)
                {
                    TypeArguments = new IExtendedType[]
                    {
                        FromType(type.GetElementType() !)
                    };
                }
            }

            if (type.IsGenericType)
            {
                Definition = type.GetGenericTypeDefinition();
            }
        }
예제 #5
0
 public ExtendedTypeId(Type type, ExtendedTypeKind kind, uint nullability)
 {
     Type        = type;
     Kind        = kind;
     Nullability = nullability;
 }