Projekt | Opis | Technologia |
---|---|---|
Resources | Usługa do zarządzania pojazdami i osobami | WebApi |
Radio | Usługa do obsługi radionadajników | Middleware |
Navigation | Usługa do obsługi nawigacji | OWIN |
Messaging | Usługa do komunikacji między osobami | Signal-R |
Tracking | Usługa do śledzenia pojazdów | gRPC |
dotnet --list-sdks
- wyświetlenie listy zainstalowanych SDKdotnet new globaljson
- utworzenie pliku global.jsondotnet new globaljson --sdk-version {version}
- utworzenie pliku global.json i ustawienie wersji SDKdotnet new --list
- wyświetlenie listy dostępnych szablonówdotnet new {template}
- utworzenie nowego projektu na podstawie wybranego szablonudotnet new {template} -o {output}
- utworzenie nowego projektu w podanym katalogudotnet restore
- pobranie bibliotek nuget na podstawie pliku projektudotnet build
- kompilacja projektudotnet run
- uruchomienie projektudotnet run {app.dll}
- uruchomienie aplikacjidotnet test
- uruchomienie testów jednostkowychdotnet run watch
- uruchomienie projektu w trybie śledzenia zmiandotnet test
- uruchomienie testów jednostkowych w trybie śledzenia zmiandotnet add {project.csproj} reference {library.csproj}
- dodanie odwołania do bibliotekidotnet remove {project.csproj} reference {library.csproj}
- usunięcie odwołania do bibliotekidotnet new sln
- utworzenie nowego rozwiązaniadotnet sln {solution.sln} add {project.csproj}
- dodanie projektu do rozwiązaniadotnet sln {solution.sln} remove {project.csproj}
- usunięcie projektu z rozwiązaniadotnet publish -c Release -r {platform}
- publikacja aplikacjidotnet publish -c Release -r win10-x64
- publikacja aplikacji dla Windowsdotnet publish -c Release -r linux-x64
- publikacja aplikacji dla Linuxdotnet publish -c Release -r osx-x64
- publikacja aplikacji dla MacOSdotnet add package {package-name}
- dodanie pakietu nuget do projektudotnet remove package {package-name}
- usunięcie pakietu nuget do projektu
request:
GET /customers/index.html HTTP/1.1
host: www.sulmar.pl
accept: text/html
{blank-line}
response:
200 OK
content-type: text/html
<html>...</html>
request:
GET api/customers HTTP/1.1
host: www.sulmar.pl
accept: application/json
{blank-line}
response:
content-type: application/json
{json}
request:
POST api/customers HTTP/1.1
host: www.sulmar.pl
content-type: application/xml
<xml><customer>...</customer></xml>
{blank-line}
response:
201 Created
Akcja | Opis |
---|---|
GET | Pobierz |
POST | Utwórz |
PUT | Zamień |
PATCH | Zmień częściowo |
DELETE | Usuń |
HEAD | Czy zasób istnieje |
public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((hostingContext, config) =>
{
config.AddXmlFile("appsettings.xml", optional: true, reloadOnChange: true);
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
config.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", optional: true, reloadOnChange: true);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});
}
public class VehicleOptions
{
public int Quantity { get; set; }
}
- Plik konfiguracyjny appsettings.json
{
"VehicleOptions": {
"Quantity": 40
},
- Instalacja biblioteki
dotnet add package Microsoft.Extensions.Options
- Wstrzykiwanie opcji
public class FakeVehicleService
{
private readonly VehicleOptions options;
public FakeCustomersService(IOptions<VehicleOptions> options)
{
this.options = options.Value;
}
}
public void ConfigureServices(IServiceCollection services)
{
services.Configure<VehicleOptions>(Configuration.GetSection("VehicleOptions"));
}
}
public void ConfigureServices(IServiceCollection services)
{
var vehicleOptions = new VehicleOptions();
Configuration.GetSection("VehicleOptions").Bind(vehicleOptions);
services.AddSingleton(vehicleOptions);
services.Configure<VehicleOptions>(Configuration.GetSection("VehicleOptions"));
}
public class FakeVehicleService
{
private readonly VehicleOptions options;
public FakeCustomersService(VehicleOptions options)
{
this.options = options;
}
}
public void ConfigureServices(IServiceCollection services)
{
services
.AddMvc(options => options.RespectBrowserAcceptHeader = true)
.AddXmlSerializerFormatters();
}
// GET api/customers/10
// GET api/customers/10.json
// GET api/customers/10.xml
[Route("api/[controller]")]
public class CustomersController : ControllerBase
{
[FormatFilter]
[HttpGet("{id:int}.{format?}")]
public IActionResult GetById(int id)
{
if (!customerRepository.IsExists(id))
return NotFound();
var customer = customerRepository.Get(id);
return Ok(customer);
}
}
- Mapping Generator https://github.com/cezarypiatek/MappingGenerator