public Type GetType()

in lang/csharp/src/apache/main/Specific/ObjectCreator.cs [202:289]


        public Type GetType(Schema schema)
        {
            switch(schema.Tag) {
            case Schema.Type.Null:
                break;
            case Schema.Type.Boolean:
                return typeof(bool);
            case Schema.Type.Int:
                return typeof(int);
            case Schema.Type.Long:
                return typeof(long);
            case Schema.Type.Float:
                return typeof(float);
            case Schema.Type.Double:
                return typeof(double);
            case Schema.Type.Bytes:
                return typeof(byte[]);
            case Schema.Type.String:
                return typeof(string);
            case Schema.Type.Union:
                {
                    if (schema is UnionSchema unSchema && unSchema.Count == 2)
                    {
                        Schema s1 = unSchema.Schemas[0];
                        Schema s2 = unSchema.Schemas[1];

                        // Nullable ?
                        Type itemType = null;
                        if (s1.Tag == Schema.Type.Null)
                        {
                            itemType = GetType(s2);
                        }
                        else if (s2.Tag == Schema.Type.Null)
                        {
                            itemType = GetType(s1);
                        }

                        if (itemType != null)
                        {
                            if (itemType.IsValueType && !itemType.IsEnum)
                            {
                                try
                                {
                                    return GenericNullableType.MakeGenericType(itemType);
                                }
                                catch
                                {
                                }
                            }

                            return itemType;
                        }
                    }

                    return typeof(object);
                }
            case Schema.Type.Array:
                {
                    ArraySchema arrSchema = schema as ArraySchema;
                    Type itemSchema = GetType(arrSchema.ItemSchema);

                    return GenericListType.MakeGenericType(itemSchema);
                }
            case Schema.Type.Map:
                {
                    MapSchema mapSchema = schema as MapSchema;
                    Type itemSchema = GetType(mapSchema.ValueSchema);

                    return GenericMapType.MakeGenericType(typeof(string), itemSchema );
                }
            case Schema.Type.Enumeration:
            case Schema.Type.Record:
            case Schema.Type.Fixed:
            case Schema.Type.Error:
                {
                    // Should all be named types
                    if (schema is NamedSchema named)
                    {
                        return FindType(named.Fullname);
                    }

                    break;
                }
            }

            // Fallback
            return FindType(schema.Name);
        }