Skip to content

ithanshui/SharpPlugs

 
 

Repository files navigation

SharpPlugs

.Net Core 鋒利扩展
中文文档

Build status NuGet NuGet

Current Features

  • DI
  • AutoMapper
  • ElasticSearch
  • WebAPiRoute
  • EntityFramework Repoistory

Get Started

First of all need to have a core project at asp.net Core, Here I've created a asp.net core MVC project

asp.net core Project

Now, install SharpPlugs Core packages

dotnet add package SharpPlug.Core

AddSharpPlugCore during Startup

 services.AddSharpPlugCore(opt=>{
      opt.DiAssembly.Add(Assembly.GetExecutingAssembly());
 });

asp.net core Project

Now we have the function of the dependency injection, I create a TestService classes with TestService interface

Automatic dependency injection is a naming rules, ends in Service or Repository is automatically injected by default

public class TestService : ITestService,IScopedDependency
{

    public string Hello()
    {
         return "Hello World";
    }
}

In the injected ITestService HomeController

public class HomeController : Controller
{
    private readonly ITestService _testService;
    public  HomeController(ITestService testService)
    {
        _testService = testService;
    }
    public IActionResult Index()
    {
        return View();
    }

    public IActionResult Hello()
    {
        return Json(_testService.Hello())   ;
    }
       
}

Now press F5 to debug,In your browser's address bar input /home/Hello,The request will be stay in the breakpoint

asp.net core Project

Now we press F5 to let it continue to run , We will see the Hello World output

asp.net core Project

Want to know more usage?Please see the advanced document

Nuget Packages

SharpPlugs is distributed as nuget packages.

Package Status
SharpPlug.Core NuGet version
SharpPlug.ElasticSearch NuGet version
SharpPlug.AutoMapper NuGet version
SharpPlug.WebApi NuGet version
SharpPlug.EntityFrameworkCore NuGet version

About

.Net Core 鋒利扩展

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • C# 100.0%