Giter VIP home page Giter VIP logo

judge0.dotnet's Introduction

Judj0 DotNet

Client for Judj0 API written in .NET Core.

Features

  • Authentication
  • Authorization
  • Submissions
  • Statuses and Languages
  • System and Configuration
  • Statistics
  • Health Check
  • Information

Installation

dotnet add package Judj0.DotNet

Usage

Configuration

Add in cofiguration Judje0 Section with the following parameters:

    "Judje0": {
        "BaseUrl": "", // Base URL of the Judj0 API
        "AuthorizationHeader": "X-Auth-Token", // Header for the Authorization Token
        "AuthorizationToken": "", // Token for the Authorization
        "AuthenticationHeader": "X-Auth-User", // Header for the Authentication Token
        "AuthenticationToken": "" // Token for the Authentication
    }

Register the Judj0 Dotnet dependency like this:

using Judj0.DotNet;

builder.Services.AddJudj0Client(Configuration);

Authentication

Resolve with dependency injection the IAuthenticationService and use the AuthenticateAsync method to Authenticate.

using Judj0.DotNet;

public class AuthenticationExample
{
    private readonly IAuthenticationService _authenticationService;

    public AuthenticationExample(IAuthenticationService authenticationService)
    {
        _authenticationService = authenticationService;
    }

    public async Task Authenticate()
    {
        var response = await _authenticationService.AuthenticateAsync();
    }
}

Authorization

Resolve with dependency injection the IAuthorizationService and use the AuthorizeAsync method to Authorize.

public class AuthorizationExample
{
    private readonly IAuthorizationService _authorizationService;

    public AuthorizationExample(IAuthorizationService authorizationService)
    {
        _authorizationService = authorizationService;
    }

    public async Task Authenticate()
    {
        var response = await _authorizationService.AuthorizeAsync();
    }
}

Submissions

Resolve with dependency injection the ISubmissionService

Create a Submission

Use the CreateAsync method to create a Submissions.

public class SubmissionExample
{
    private readonly ISubmissionService _submissionService;

    public SubmissionExample(ISubmissionService submissionService)
    {
        _submissionService = submissionService;
    }

    public async Task CreateSubmission()
    {
        var submission = new Submission(
            "#include <stdio.h>\n\nint main(void) {\n  char name[10];\n  scanf(\"%s\", name);\n  printf(\"hello, %s\n\", name);\n  return 0;\n}",
            50)
        {
            Stdin = "world"
        };
        
        var response = await _submissionService.CreateAsync(submission);
    }
}

Get a Submission

Use the GetAsync method to create a Submissions.

public class SubmissionExample
{
    private readonly ISubmissionService _submissionService;

    public SubmissionExample(ISubmissionService submissionService)
    {
        _submissionService = submissionService;
    }

    public async Task GetSubmission()
    {
        var response = await _submissionService.GetAsync("b16fcd66-79c3-4ba5-986d-8fc85ea24f04");
    }
}

Documentation in progress

judge0.dotnet's People

Contributors

lanz86 avatar

Watchers

 avatar  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.