Example #1
0
        private static SchemaOptions GetTypeFlags(Type type, SchemaOptions options)
        {
            if (type.IsValueType)
            {
                options = options.AsValueType(true);
            }

            if (type.IsSealed)
            {
                options = options.AsSealed(true);
            }

            foreach (var attribute in type.GetCustomAttributes())
            {
                switch (attribute)
                {
                case ImmutableAttribute _:
                    options = options.AsImmutable(true);
                    if (type.IsClass)
                    {
                        options = options.PreserveObjectReferences(true);
                    }
                    break;
                }
            }

            return(options);
        }
Example #2
0
 public SchemaDef(Type type, SchemaOptions options, ImmutableSortedSet <FieldDef> fields)
 {
     Options = options;
     Type    = type;
     Fields  = fields;
 }