Beispiel #1
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);
    }