public static bool TryCreate(Schema.Schema schema, FlatBufferEnum @enum, [NotNullWhen(true)] out EnumSchemaModel?model) { model = null; if (@enum.IsUnion || [email protected]()) { return(false); } model = new EnumSchemaModel(schema, @enum); return(true); }
public static bool TryCreate(Schema.Schema schema, FlatBufferEnum union, [NotNullWhen(true)] out UnionSchemaModel?model) { if (union.UnderlyingType.BaseType != BaseType.UType) { model = null; return(false); } model = new UnionSchemaModel(schema, union); return(true); }
private EnumSchemaModel(Schema.Schema schema, FlatBufferEnum @enum) : base(schema, @enum.Name, new FlatSharpAttributes(@enum.Attributes)) { FlatSharpInternal.Assert([email protected], "Not expecting union"); FlatSharpInternal.Assert(@enum.UnderlyingType.BaseType.IsInteger(), "Expected scalar base type"); FlatSharpInternal.Assert(@enum.UnderlyingType.BaseType.TryGetBuiltInTypeName(out this.underlyingType !), "Couldn't get type name string"); this.isFlags = @enum.Attributes?.ContainsKey(MetadataKeys.BitFlags) == true; this.nameValueMap = @enum.Values.ToDictionary(x => x.Value.Key, x => x.Value); this.DeclaringFile = @enum.DeclarationFile; this.documentation = @enum.Documentation; }
private UnionSchemaModel(Schema.Schema schema, FlatBufferEnum union) : base(schema, union.Name, new FlatSharpAttributes(union.Attributes)) { FlatSharpInternal.Assert(union.UnderlyingType.BaseType == BaseType.UType, "Expecting utype"); this.union = union; }