Giter Site home page Giter Site logo

silvera-csharp-gen's Introduction

silvera-csharp-gen

This C# generator plug-in for silvera is not yet on the Python Package Index (PyPi), but it can be installed from the GitHub repository with the following command:

$ pip install git+https://github.com/albertmakan/silvera-csharp-gen.git

This command will also install silvera if it is not already installed. Successful installation of silvera and the plug-in can be confirmed with the following command:

$ silvera list-generators
java-17 -> Java 17 code generator
csharp-10 -> C# 10 code generator

If the list includes java-17 and csharp-10, then silvera has successfully detected the plug-in.

A silvera project is a folder containing a silvera.project file and other .si files. Below is an example definition of a microservice. To result the microservice in a C# project, it is necessary to specify lang="csharp" in the deployment block.

import "user.si"

service SciPaper {
  deployment {
    lang="csharp"
  }

  api {
    @crud
    typedef Paper [
      @required str title
      str author
      str authorId
      @required list<Section> sections
    ]
    typedef Section [
      @required str name
      @required str content
    ]

    @rest(method=GET, mapping="by-author/{authorId}")
    list<Paper> getAllByAuthor(str authorId)

    @rest(method=POST)
    @producer(MsgGroup.PaperPublished -> Broker.PUBLISH_PAPER)
    void publish(str paperId, str authorId)
  }
}

dependency SciPaper -> User {
  getName[fail_silent]
}

The model is compiled with the following command:

$ silvera compile <project_dir> -o <output_dir>

If the model is successfully compiled, the generated code is located in the output_dir folder. To run the code, .NET 6 is required. In addition, a MongoDB instance needs to be running, and if the application uses messages, then Zookeeper and Kafka.

The program is started with the following command:

$ cd <output_dir>
$ dotnet run

CRUD methods will work, but calling additional functions will return status code 501 (Not Implemented). These functions need to be manually implemented.

silvera-csharp-gen's People

Contributors

albertmakan avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.