Skip to content

Commit 6ad01b3

Browse files
committed
Version 1.0
1 parent 17850f0 commit 6ad01b3

20 files changed

Lines changed: 121 additions & 49 deletions

ProjectTemplates/How to create new template.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ After making any changes do:
55
1. Select Release configuration for a solution
66
1. Select ReferenceProject in "Solution Explorer" and click "Project/Export Template..." menu item from the VS main menu
77
1. In the appeared dialog box select "Project template" option and "ReferenceProject" in the combobox below and click Next
8-
1. Set the value "ASP.Net WebAPI Application with OWIN" as a template name
8+
1. Set the value "ASP.Net Core RESTful Service" as a template name and the "Project template to create production-ready RESTful service based on ASP.Net Core. It contains preconfigured DI-container, logging, CORS, some boilerplate code and other features" as a description
99
1. Clear checkbox "Automatically import the template into Visual Studio" if you don't want immediately import it and click Finish button
1010
1. Extract all files from the created zip-archive to any folder as you want. Typically, the file can be found in "C:\Users\<YOU>\Documents\Visual Studio 2017\My Exported Templates" folder
11-
1. Open ReferenceProject.csproj file in any text editor and find "DocumentationFile" tag
12-
1. Replace string "%24safeprojectname%24" to "$safeprojectname$" inside it and save the file
13-
1. Replace a file "MyTemplate.vstemplate" with the one from the project folder with the same name
14-
1. Add all files from the folder to zip-archive with a name "ASP.Net WebAPI Application with OWIN.zip"
15-
1. Copy this file to "ProjectTemplates\AspNet.WebApi\ReferenceProject\ReferenceProjectVSIX\ProjectTemplates\CSharp\Web" folder and replace an existing one
11+
1. Open a file "MyTemplate.vstemplate"
12+
1. Replace content of the tag `DefaultName` in the section `TemplateData` to "ASPNetCore.Service" (without quotation)
13+
1. Add tag `NumberOfParentCategoriesToRollUp` to the same section with value '1': `<NumberOfParentCategoriesToRollUp>1</NumberOfParentCategoriesToRollUp>`
14+
1. Add all files from the folder to zip-archive with a name "ASP.Net Core RESTful Service.zip". All added files must be in the root of the archive
15+
1. Copy this file to "ProjectTemplates\ReferenceProjectVSIX\ProjectTemplates\CSharp\.NET Core" folder and replace an existing one
1616
1. Go to VS, expand a ReferenceProjectVSIX project and double click on source.extension.vsixmanifest file
1717
1. Increase minor version number on the tab "Metadata" in the top right corner
18-
1. Rebuild the ReferenceProjectVSIX project and get "ASP.Net WebAPI Application Project Template.vsix"
18+
1. Rebuild the ReferenceProjectVSIX project and get "ASP.Net Core RESTful Service Template.vsix"
1919

20-
That's all. "ASP.Net WebAPI Application Project Template.vsix" can be uploaded to VS Marketplace or installed in VS.
20+
That's all. "ASP.Net Core RESTful Service Template.vsix" can be uploaded to VS Marketplace or installed in VS.

ProjectTemplates/ReferenceProject/Configuration/AutoMapperProfiles/DefaultProfile.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace ReferenceProject.Profiles
44
{
5+
/// <summary>
6+
/// Default profile for AutoMapper
7+
/// </summary>
8+
/// <remarks>See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#automapper</remarks>
59
public class DefaultProfile: Profile
610
{
711
public DefaultProfile()

ProjectTemplates/ReferenceProject/Configuration/AutofacModules/DefaultModule.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
namespace ReferenceProject.Modules
44
{
5+
/// <summary>
6+
/// Default module for Autofac
7+
/// </summary>
8+
/// <remarks>
9+
/// See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#dependency-injection
10+
/// </remarks>
511
public class DefaultModule: Module
612
{
713
protected override void Load(ContainerBuilder builder)

ProjectTemplates/ReferenceProject/Configuration/DependenciesConfig.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ namespace ReferenceProject
88
{
99
public static class DependenciesConfig
1010
{
11+
/// <summary>
12+
/// Add Swagger middleware
13+
/// </summary>
14+
/// <remarks>
15+
/// See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#documenting-api
16+
/// </remarks>
1117
public static IServiceCollection AddSwagger(this IServiceCollection services)
1218
{
1319
// Register the Swagger generator, defining 1 or more Swagger documents

ProjectTemplates/ReferenceProject/Configuration/MiddlewareConfig.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ namespace ReferenceProject
44
{
55
public static class MiddlewareConfig
66
{
7+
/// <summary>
8+
/// Use swagger UI and endpoint
9+
/// </summary>
10+
/// <remarks>
11+
/// See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#documenting-api
12+
/// </remarks>
713
public static IApplicationBuilder UseSwaggerWithOptions(this IApplicationBuilder app)
814
{
915
// Enable middleware to serve generated Swagger as a JSON endpoint.

ProjectTemplates/ReferenceProject/Filters/CacheControlFilter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
namespace ReferenceProject.Filters
44
{
5+
/// <summary>
6+
/// Filter to add header Cache-Control to responses
7+
/// </summary>
8+
/// <remarks>See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#cache-control</remarks>
59
public class CacheControlFilter: IResultFilter
610
{
711
public void OnResultExecuted(ResultExecutedContext context)

ProjectTemplates/ReferenceProject/Filters/ValidateModelFilter.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
namespace ReferenceProject.Filters
55
{
6+
/// <summary>
7+
/// Filter to check is a model valid
8+
/// </summary>
9+
/// <remarks>See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#model-validation</remarks>
610
public class ValidateModelFilter: IActionFilter
711
{
812
public void OnActionExecuted(ActionExecutedContext context)

ProjectTemplates/ReferenceProject/Middleware/ExceptionMiddleware.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace ReferenceProject.Middleware
1818
/// There is another way to do this - an exception filter.
1919
/// However, a middleware is a preferred way to achieve this according to the official documentation.
2020
/// To learn more see https://docs.microsoft.com/en-us/aspnet/core/mvc/controllers/filters?view=aspnetcore-2.1#exception-filters
21+
///
22+
/// See also: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#unhandled-exceptions-handling
2123
/// </remarks>
2224
public class ExceptionMiddleware
2325
{

ProjectTemplates/ReferenceProject/Middleware/OptionsVerbMiddleware.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@
33

44
namespace ReferenceProject.Middleware
55
{
6-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS
7-
// https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#Preflighted_requests
8-
// https://developer.mozilla.org/ru/docs/Web/HTTP/Methods/OPTIONS
6+
/// <summary>
7+
/// OPTIONS HTTP-method handler
8+
/// </summary>
9+
/// <remarks>
10+
/// See: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#cross-origin-resource-sharing-cors-and-preflight-requests
11+
/// </remarks>
912
public class OptionsVerbMiddleware
1013
{
1114
RequestDelegate Next { get; }

ProjectTemplates/ReferenceProject/Program.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
2424

2525
/*
2626
* You can use a global logger as this, but I don't recommend this way
27+
* More information: https://github.com/drwatson1/AspNet-Core-REST-Service/wiki#logging
2728
Log.Logger = new LoggerConfiguration()
2829
.ReadFrom.Configuration(context.Configuration)
2930
.CreateLogger();

0 commit comments

Comments
 (0)