Esempio n. 1
0
    public BaseSchemaModel ToSchemaModel(Schema schema)
    {
        if (EnumSchemaModel.TryCreate(schema, this, out var enumModel))
        {
            return(enumModel);
        }

        throw new NotImplementedException();
    }
Esempio n. 2
0
    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);
    }
Esempio n. 3
0
    public RootModel ToRootModel()
    {
        RootModel model = new RootModel(this.AdvancedFeatures);

        foreach (var @enum in this.Enums)
        {
            if (EnumSchemaModel.TryCreate(this, @enum, out var enumModel))
            {
                model.AddElement(enumModel);
            }
            else if (UnionSchemaModel.TryCreate(this, @enum, out var unionModel))
            {
                model.AddElement(unionModel);
            }
        }

        foreach (var obj in this.Objects)
        {
            if (TableSchemaModel.TryCreate(this, obj, out var tableModel))
            {
                model.AddElement(tableModel);
            }
            else if (ReferenceStructSchemaModel.TryCreate(this, obj, out var refStructModel))
            {
                model.AddElement(refStructModel);
            }
            else if (ValueStructSchemaModel.TryCreate(this, obj, out var valueStructModel))
            {
                model.AddElement(valueStructModel);
            }
        }

        if (this.Services is not null)
        {
            foreach (var service in this.Services)
            {
                model.AddElement(new RpcServiceSchemaModel(this, service));
            }
        }

        return(model);
    }