コード例 #1
0
        TypeData MakeGenericTypeData(IReadOnlyList <TypeData> parameters)
        {
            if (!IsSupported)
            {
                return(this);
            }

            if (IsGenericParameter)
            {
                return(parameters[this.GenericParameterIndex]);
            }

            if (!IsGeneric)
            {
                return(this);
            }

            var result = new TypeData()
            {
                IsSupported             = true,
                Kind                    = Kind,
                IsSealed                = IsSealed,
                IsReference             = IsReference,
                IsEnum                  = IsEnum,
                IsInterface             = IsInterface,
                HasConverter            = HasConverter,
                IsISerializable         = IsISerializable,
                IsGeneric               = true,
                IsGenericTypeDefinition = false,
                IsNullable              = IsNullable,
                Element                 = this,
                GenericParameters       = GenericParameters.Select(x => x.MakeGenericTypeData(parameters)).ToList().AsReadOnly(),
            };

            result.BaseType  = BaseType?.MakeGenericTypeData(parameters);
            result.Surrogate = Surrogate?.MakeGenericTypeData(parameters);

            if (Surrogate == null &&
                !IsInterface &&
                !IsArray && !IsEnum &&
                !IsGenericParameter)
            {
                foreach (var m in Members)
                {
                    var rm = new Member(result);
                    rm.Name = m.Name;
                    rm.Type = m.Type.MakeGenericTypeData(parameters);
                    result.Members.Add(rm);
                }
                result.CollectionType = CollectionType;
                result.Collection1    = Collection1?.MakeGenericTypeData(parameters);
                result.Collection2    = Collection2?.MakeGenericTypeData(parameters);
            }
            return(result);
        }