├── .gitignore
├── LICENSE
├── README.md
├── libraries
├── AutoMapper
│ ├── .dockerignore
│ ├── AutoMapperExamples.Api
│ │ ├── AutoMapperExamples.Api.csproj
│ │ ├── Controllers
│ │ │ └── CustomerController.cs
│ │ ├── Dockerfile
│ │ ├── Domain
│ │ │ ├── Address.cs
│ │ │ └── Customer.cs
│ │ ├── Infrastructure
│ │ │ └── CustomerAutoMapperProfile.cs
│ │ ├── Models
│ │ │ ├── AddressModel.cs
│ │ │ └── CustomerModel.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Startup.cs
│ │ ├── appsettings.Development.json
│ │ └── appsettings.json
│ ├── AutoMapperExamples.sln
│ └── README.md
├── Autofac
│ ├── .dockerignore
│ ├── AutofacExamples.Api
│ │ ├── AutofacExamples.Api.csproj
│ │ ├── Controllers
│ │ │ └── TestController.cs
│ │ ├── Dockerfile
│ │ ├── Infrastructure
│ │ │ └── MyAutofacModule.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Services
│ │ │ ├── IService.cs
│ │ │ └── MyService.cs
│ │ ├── Startup.cs
│ │ ├── appsettings.Development.json
│ │ └── appsettings.json
│ ├── AutofacExamples.sln
│ └── README.md
├── FluentValidation
│ ├── .dockerignore
│ ├── FluentValidationExamples.Api
│ │ ├── Controllers
│ │ │ └── CustomerController.cs
│ │ ├── Dockerfile
│ │ ├── FluentValidationExamples.Api.csproj
│ │ ├── Infrastructure
│ │ │ └── Validators
│ │ │ │ ├── AddressValidator.cs
│ │ │ │ └── CustomerValidator.cs
│ │ ├── Models
│ │ │ ├── AddressModel.cs
│ │ │ └── CustomerModel.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Startup.cs
│ │ ├── appsettings.Development.json
│ │ └── appsettings.json
│ ├── FluentValidationExamples.sln
│ └── README.md
├── Hangfire
│ ├── .dockerignore
│ ├── HangfireExamples.Api
│ │ ├── Controllers
│ │ │ └── WeatherForecastController.cs
│ │ ├── Dockerfile
│ │ ├── HangfireExamples.Api.csproj
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Startup.cs
│ │ ├── WeatherForecast.cs
│ │ ├── appsettings.Development.json
│ │ └── appsettings.json
│ ├── HangfireExamples.sln
│ └── README.md
├── MediatR
│ ├── .dockerignore
│ ├── MediatRExamples.Api
│ │ ├── Application
│ │ │ └── Customers
│ │ │ │ ├── Commands
│ │ │ │ ├── CreateCustomerCommand.cs
│ │ │ │ ├── CreateCustomerCommandHandler.cs
│ │ │ │ ├── UpdateCustomerCommand.cs
│ │ │ │ └── UpdateCustomerCommandHandler.cs
│ │ │ │ └── Queries
│ │ │ │ ├── GetCustomerByIdQuery.cs
│ │ │ │ ├── GetCustomerByIdQueryHandler.cs
│ │ │ │ ├── GetCustomersQuery.cs
│ │ │ │ └── GetCustomersQueryHandler.cs
│ │ ├── Controllers
│ │ │ └── CustomerController.cs
│ │ ├── Data
│ │ │ ├── IRepository.cs
│ │ │ └── Repository.cs
│ │ ├── Dockerfile
│ │ ├── Domain
│ │ │ └── Customer.cs
│ │ ├── MediatRExamples.Api.csproj
│ │ ├── Models
│ │ │ ├── CreateCustomerModel.cs
│ │ │ └── UpdateCustomerModel.cs
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Startup.cs
│ │ ├── appsettings.Development.json
│ │ └── appsettings.json
│ ├── MediatRExamples.sln
│ └── README.md
├── MiniProfiler
│ ├── .dockerignore
│ ├── MiniProfilerExamples.Api
│ │ ├── Controllers
│ │ │ └── WeatherForecastController.cs
│ │ ├── Dockerfile
│ │ ├── MiniProfilerExamples.Api.csproj
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── Startup.cs
│ │ ├── WeatherForecast.cs
│ │ ├── appsettings.Development.json
│ │ └── appsettings.json
│ ├── MiniProfilerExamples.sln
│ └── README.md
├── Serilog
│ ├── .dockerignore
│ ├── README.md
│ ├── SerilogExamples.Api
│ │ ├── Controllers
│ │ │ └── WeatherForecastController.cs
│ │ ├── Dockerfile
│ │ ├── Program.cs
│ │ ├── Properties
│ │ │ └── launchSettings.json
│ │ ├── SerilogExamples.Api.csproj
│ │ ├── Startup.cs
│ │ ├── WeatherForecast.cs
│ │ ├── appsettings.Development.json
│ │ └── appsettings.json
│ └── SerilogExamples.sln
└── Swagger
│ ├── .dockerignore
│ ├── README.md
│ ├── SwaggerExamples.Api
│ ├── Controllers
│ │ └── WeatherForecastController.cs
│ ├── Dockerfile
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Startup.cs
│ ├── SwaggerExamples.Api.csproj
│ ├── WeatherForecast.cs
│ ├── appsettings.Development.json
│ └── appsettings.json
│ └── SwaggerExamples.sln
└── samples
├── hosted-services
├── README.md
└── background-tasks
│ ├── .dockerignore
│ ├── BackgroundTasksLabs.Web
│ ├── BackgroundTasksLabs.Web.csproj
│ ├── Dockerfile
│ ├── Program.cs
│ ├── Properties
│ │ └── launchSettings.json
│ ├── Services
│ │ └── Worker.cs
│ ├── Startup.cs
│ ├── appsettings.Development.json
│ └── appsettings.json
│ └── hosted-services-background-tasks-labs.sln
├── swagger-openapi
└── README.md
└── zzzzz
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Aa][Rr][Mm]/
27 | [Aa][Rr][Mm]64/
28 | bld/
29 | [Bb]in/
30 | [Oo]bj/
31 | [Ll]og/
32 | [Ll]ogs/
33 |
34 | # Visual Studio 2015/2017 cache/options directory
35 | .vs/
36 | # Uncomment if you have tasks that create the project's static files in wwwroot
37 | #wwwroot/
38 |
39 | # Visual Studio 2017 auto generated files
40 | Generated\ Files/
41 |
42 | # MSTest test Results
43 | [Tt]est[Rr]esult*/
44 | [Bb]uild[Ll]og.*
45 |
46 | # NUnit
47 | *.VisualState.xml
48 | TestResult.xml
49 | nunit-*.xml
50 |
51 | # Build Results of an ATL Project
52 | [Dd]ebugPS/
53 | [Rr]eleasePS/
54 | dlldata.c
55 |
56 | # Benchmark Results
57 | BenchmarkDotNet.Artifacts/
58 |
59 | # .NET Core
60 | project.lock.json
61 | project.fragment.lock.json
62 | artifacts/
63 |
64 | # StyleCop
65 | StyleCopReport.xml
66 |
67 | # Files built by Visual Studio
68 | *_i.c
69 | *_p.c
70 | *_h.h
71 | *.ilk
72 | *.meta
73 | *.obj
74 | *.iobj
75 | *.pch
76 | *.pdb
77 | *.ipdb
78 | *.pgc
79 | *.pgd
80 | *.rsp
81 | *.sbr
82 | *.tlb
83 | *.tli
84 | *.tlh
85 | *.tmp
86 | *.tmp_proj
87 | *_wpftmp.csproj
88 | *.log
89 | *.vspscc
90 | *.vssscc
91 | .builds
92 | *.pidb
93 | *.svclog
94 | *.scc
95 |
96 | # Chutzpah Test files
97 | _Chutzpah*
98 |
99 | # Visual C++ cache files
100 | ipch/
101 | *.aps
102 | *.ncb
103 | *.opendb
104 | *.opensdf
105 | *.sdf
106 | *.cachefile
107 | *.VC.db
108 | *.VC.VC.opendb
109 |
110 | # Visual Studio profiler
111 | *.psess
112 | *.vsp
113 | *.vspx
114 | *.sap
115 |
116 | # Visual Studio Trace Files
117 | *.e2e
118 |
119 | # TFS 2012 Local Workspace
120 | $tf/
121 |
122 | # Guidance Automation Toolkit
123 | *.gpState
124 |
125 | # ReSharper is a .NET coding add-in
126 | _ReSharper*/
127 | *.[Rr]e[Ss]harper
128 | *.DotSettings.user
129 |
130 | # TeamCity is a build add-in
131 | _TeamCity*
132 |
133 | # DotCover is a Code Coverage Tool
134 | *.dotCover
135 |
136 | # AxoCover is a Code Coverage Tool
137 | .axoCover/*
138 | !.axoCover/settings.json
139 |
140 | # Visual Studio code coverage results
141 | *.coverage
142 | *.coveragexml
143 |
144 | # NCrunch
145 | _NCrunch_*
146 | .*crunch*.local.xml
147 | nCrunchTemp_*
148 |
149 | # MightyMoose
150 | *.mm.*
151 | AutoTest.Net/
152 |
153 | # Web workbench (sass)
154 | .sass-cache/
155 |
156 | # Installshield output folder
157 | [Ee]xpress/
158 |
159 | # DocProject is a documentation generator add-in
160 | DocProject/buildhelp/
161 | DocProject/Help/*.HxT
162 | DocProject/Help/*.HxC
163 | DocProject/Help/*.hhc
164 | DocProject/Help/*.hhk
165 | DocProject/Help/*.hhp
166 | DocProject/Help/Html2
167 | DocProject/Help/html
168 |
169 | # Click-Once directory
170 | publish/
171 |
172 | # Publish Web Output
173 | *.[Pp]ublish.xml
174 | *.azurePubxml
175 | # Note: Comment the next line if you want to checkin your web deploy settings,
176 | # but database connection strings (with potential passwords) will be unencrypted
177 | *.pubxml
178 | *.publishproj
179 |
180 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
181 | # checkin your Azure Web App publish settings, but sensitive information contained
182 | # in these scripts will be unencrypted
183 | PublishScripts/
184 |
185 | # NuGet Packages
186 | *.nupkg
187 | # NuGet Symbol Packages
188 | *.snupkg
189 | # The packages folder can be ignored because of Package Restore
190 | **/[Pp]ackages/*
191 | # except build/, which is used as an MSBuild target.
192 | !**/[Pp]ackages/build/
193 | # Uncomment if necessary however generally it will be regenerated when needed
194 | #!**/[Pp]ackages/repositories.config
195 | # NuGet v3's project.json files produces more ignorable files
196 | *.nuget.props
197 | *.nuget.targets
198 |
199 | # Microsoft Azure Build Output
200 | csx/
201 | *.build.csdef
202 |
203 | # Microsoft Azure Emulator
204 | ecf/
205 | rcf/
206 |
207 | # Windows Store app package directories and files
208 | AppPackages/
209 | BundleArtifacts/
210 | Package.StoreAssociation.xml
211 | _pkginfo.txt
212 | *.appx
213 | *.appxbundle
214 | *.appxupload
215 |
216 | # Visual Studio cache files
217 | # files ending in .cache can be ignored
218 | *.[Cc]ache
219 | # but keep track of directories ending in .cache
220 | !?*.[Cc]ache/
221 |
222 | # Others
223 | ClientBin/
224 | ~$*
225 | *~
226 | *.dbmdl
227 | *.dbproj.schemaview
228 | *.jfm
229 | *.pfx
230 | *.publishsettings
231 | orleans.codegen.cs
232 |
233 | # Including strong name files can present a security risk
234 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
235 | #*.snk
236 |
237 | # Since there are multiple workflows, uncomment next line to ignore bower_components
238 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
239 | #bower_components/
240 |
241 | # RIA/Silverlight projects
242 | Generated_Code/
243 |
244 | # Backup & report files from converting an old project file
245 | # to a newer Visual Studio version. Backup files are not needed,
246 | # because we have git ;-)
247 | _UpgradeReport_Files/
248 | Backup*/
249 | UpgradeLog*.XML
250 | UpgradeLog*.htm
251 | ServiceFabricBackup/
252 | *.rptproj.bak
253 |
254 | # SQL Server files
255 | *.mdf
256 | *.ldf
257 | *.ndf
258 |
259 | # Business Intelligence projects
260 | *.rdl.data
261 | *.bim.layout
262 | *.bim_*.settings
263 | *.rptproj.rsuser
264 | *- [Bb]ackup.rdl
265 | *- [Bb]ackup ([0-9]).rdl
266 | *- [Bb]ackup ([0-9][0-9]).rdl
267 |
268 | # Microsoft Fakes
269 | FakesAssemblies/
270 |
271 | # GhostDoc plugin setting file
272 | *.GhostDoc.xml
273 |
274 | # Node.js Tools for Visual Studio
275 | .ntvs_analysis.dat
276 | node_modules/
277 |
278 | # Visual Studio 6 build log
279 | *.plg
280 |
281 | # Visual Studio 6 workspace options file
282 | *.opt
283 |
284 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
285 | *.vbw
286 |
287 | # Visual Studio LightSwitch build output
288 | **/*.HTMLClient/GeneratedArtifacts
289 | **/*.DesktopClient/GeneratedArtifacts
290 | **/*.DesktopClient/ModelManifest.xml
291 | **/*.Server/GeneratedArtifacts
292 | **/*.Server/ModelManifest.xml
293 | _Pvt_Extensions
294 |
295 | # Paket dependency manager
296 | .paket/paket.exe
297 | paket-files/
298 |
299 | # FAKE - F# Make
300 | .fake/
301 |
302 | # CodeRush personal settings
303 | .cr/personal
304 |
305 | # Python Tools for Visual Studio (PTVS)
306 | __pycache__/
307 | *.pyc
308 |
309 | # Cake - Uncomment if you are using it
310 | # tools/**
311 | # !tools/packages.config
312 |
313 | # Tabs Studio
314 | *.tss
315 |
316 | # Telerik's JustMock configuration file
317 | *.jmconfig
318 |
319 | # BizTalk build output
320 | *.btp.cs
321 | *.btm.cs
322 | *.odx.cs
323 | *.xsd.cs
324 |
325 | # OpenCover UI analysis results
326 | OpenCover/
327 |
328 | # Azure Stream Analytics local run output
329 | ASALocalRun/
330 |
331 | # MSBuild Binary and Structured Log
332 | *.binlog
333 |
334 | # NVidia Nsight GPU debugger configuration file
335 | *.nvuser
336 |
337 | # MFractors (Xamarin productivity tool) working folder
338 | .mfractor/
339 |
340 | # Local History for Visual Studio
341 | .localhistory/
342 |
343 | # BeatPulse healthcheck temp database
344 | healthchecksdb
345 |
346 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
347 | MigrationBackup/
348 |
349 | # Ionide (cross platform F# VS Code tools) working folder
350 | .ionide/
351 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2021 Ashish Patel
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # .NET Labs
3 |
4 | > .NET Labs: Samples .NET 7.x projects.
5 |
6 |
7 |
8 | - [.NET Hub](https://medium.com/dotnet-hub)
9 |
10 |
11 |
12 | ---
13 |
14 |
15 |
16 | ## Samples
17 |
18 |
19 |
20 |
21 |
22 | #### [Background/Worker/Hosted Service](samples/hosted-services)
23 |
24 |
25 |
26 | ---
27 |
28 |
29 |
30 | ## Libraries
31 |
32 |
33 |
34 |
35 |
36 | #### [Autofac](libraries/Autofac)
37 |
38 |
39 | #### [AutoMapper](libraries/AutoMapper)
40 |
41 |
42 | #### [FluentValidation](libraries/FluentValidation)
43 |
44 |
45 | #### [Swagger](libraries/Swagger)
46 |
47 |
48 | #### [Serilog](libraries/Serilog)
49 |
50 |
51 | #### [Hangfire](libraries/Hangfire)
52 |
53 |
54 | #### [MediatR](libraries/MediatR)
55 |
56 |
57 | #### [MiniProfiler](libraries/MiniProfiler)
58 |
59 |
60 |
61 |
62 |
63 | ---
64 |
65 |
66 | ## Other .NET Labs
67 |
68 |
69 | #### [Azure .NET Labs](https://github.com/a-patel/azure-labs)
70 |
71 |
72 | #### [AWS .NET Labs](https://github.com/a-patel/aws-dotnet-labs)
73 |
74 |
75 | #### [.NET Data Protection Labs](https://github.com/a-patel/dotnet-data-protection-labs)
76 |
77 |
78 |
79 |
80 |
81 | ---
82 |
83 |
84 |
85 |
86 |
87 | ## Give a Star! :star:
88 |
89 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
90 |
91 |
92 | ## Support :telephone:
93 |
94 | > Reach out to me at one of the following places!
95 |
96 | - Email :envelope: at `toaashishpatel@gmail.com`
97 |
98 |
99 | ## Author :boy:
100 |
101 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
102 |
103 |
104 | ##### Connect with me
105 |
106 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
107 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
108 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
109 |
110 |
111 | ## Donate :dollar:
112 |
113 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
114 | | PayPal | BMC | Patreon |
115 | | ------------- | ------------- | ------------- |
116 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
117 |
118 |
119 | ## License :lock:
120 |
121 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
122 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/AutoMapperExamples.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | c1561ed4-030a-4c94-808a-33cde29146ff
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Controllers/CustomerController.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using AutoMapper;
3 | using AutoMapperExamples.Api.Domain;
4 | using AutoMapperExamples.Api.Model;
5 | using Microsoft.AspNetCore.Mvc;
6 | using Microsoft.Extensions.Logging;
7 | #endregion
8 |
9 | namespace AutoMapperExamples.Api.Controllers
10 | {
11 | [ApiController]
12 | [Route("[controller]")]
13 | public class CustomerController : ControllerBase
14 | {
15 | #region Members
16 |
17 | private readonly IMapper _mapper;
18 | private readonly ILogger _logger;
19 |
20 | #endregion
21 |
22 | #region Ctor
23 |
24 | public CustomerController(IMapper mapper, ILogger logger)
25 | {
26 | _mapper = mapper;
27 | _logger = logger;
28 | }
29 |
30 | #endregion
31 |
32 | #region Methods
33 |
34 | [HttpGet]
35 | public IActionResult Get()
36 | {
37 | //TODO: Get it from in database
38 | var entity = new Customer()
39 | {
40 | Name = "Ashish Patel",
41 | Age = 30,
42 | Phone = "1234567890",
43 | Address = new Address { Country = "USA", State = "New York" }
44 | };
45 |
46 | var model = _mapper.Map(entity);
47 |
48 | return Ok(model);
49 | }
50 |
51 | [HttpPost]
52 | public IActionResult Add(CustomerModel model)
53 | {
54 | var entity = _mapper.Map(model);
55 |
56 | //TODO: Save in database
57 |
58 | return Ok();
59 | }
60 |
61 | #endregion
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["AutoMapperExamples.Api/AutoMapperExamples.Api.csproj", "AutoMapperExamples.Api/"]
11 | RUN dotnet restore "AutoMapperExamples.Api/AutoMapperExamples.Api.csproj"
12 | COPY . .
13 | WORKDIR "/src/AutoMapperExamples.Api"
14 | RUN dotnet build "AutoMapperExamples.Api.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "AutoMapperExamples.Api.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "AutoMapperExamples.Api.dll"]
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Domain/Address.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapperExamples.Api.Domain
2 | {
3 | public class Address
4 | {
5 | public string State { get; set; }
6 |
7 | public string Country { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Domain/Customer.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapperExamples.Api.Domain
2 | {
3 | public class Customer
4 | {
5 | public string Name { get; set; }
6 |
7 | public int Age { get; set; }
8 |
9 | public string Phone { get; set; }
10 |
11 |
12 | public Address Address { get; set; }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Infrastructure/CustomerAutoMapperProfile.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using AutoMapper;
3 | using AutoMapperExamples.Api.Domain;
4 | using AutoMapperExamples.Api.Model;
5 | #endregion
6 |
7 | namespace AutoMapperExamples.Api.Infrastructure
8 | {
9 | public class CustomerAutoMapperProfile : Profile
10 | {
11 | public CustomerAutoMapperProfile()
12 | {
13 | CreateMap()
14 | .ForMember(dest => dest.Phone, opt => opt.MapFrom(src => src.PhoneNumber));
15 |
16 | CreateMap()
17 | .ForMember(dest => dest.PhoneNumber, opt => opt.MapFrom(src => src.Phone))
18 | .ForMember(dest => dest.IsAdult, opt => opt.MapFrom(src => src.Age > 18));
19 |
20 | CreateMap().ReverseMap();
21 | }
22 | }
23 | }
24 |
25 |
26 |
27 | // https://github.com/AutoMapper/AutoMapper/blob/master/docs/Configuration.md
28 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Models/AddressModel.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapperExamples.Api.Model
2 | {
3 | public class AddressModel
4 | {
5 | public string State { get; set; }
6 |
7 | public string Country { get; set; }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Models/CustomerModel.cs:
--------------------------------------------------------------------------------
1 | namespace AutoMapperExamples.Api.Model
2 | {
3 | public class CustomerModel
4 | {
5 | public string Name { get; set; }
6 |
7 | public int Age { get; set; }
8 |
9 | public string PhoneNumber { get; set; }
10 |
11 | public bool IsAdult { get; set; }
12 |
13 |
14 | public AddressModel Address { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Program.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.Extensions.Hosting;
4 | #endregion
5 |
6 | namespace AutoMapperExamples.Api
7 | {
8 | public class Program
9 | {
10 | public static void Main(string[] args)
11 | {
12 | CreateHostBuilder(args).Build().Run();
13 | }
14 |
15 | public static IHostBuilder CreateHostBuilder(string[] args) =>
16 | Host.CreateDefaultBuilder(args)
17 | .ConfigureWebHostDefaults(webBuilder =>
18 | {
19 | webBuilder.UseStartup();
20 | });
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:55088",
7 | "sslPort": 44382
8 | }
9 | },
10 | "$schema": "http://json.schemastore.org/launchsettings.json",
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "AutoMapperExamples.Api": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | },
27 | "dotnetRunMessages": "true",
28 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
29 | },
30 | "Docker": {
31 | "commandName": "Docker",
32 | "launchBrowser": true,
33 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
34 | "publishAllPorts": true,
35 | "useSSL": true
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/Startup.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using AutoMapper;
3 | using AutoMapperExamples.Api.Infrastructure;
4 | using Microsoft.AspNetCore.Builder;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.DependencyInjection;
8 | using Microsoft.Extensions.Hosting;
9 | using Microsoft.OpenApi.Models;
10 | #endregion
11 |
12 | namespace AutoMapperExamples.Api
13 | {
14 | public class Startup
15 | {
16 | public IConfiguration Configuration { get; }
17 |
18 |
19 | public Startup(IConfiguration configuration)
20 | {
21 | Configuration = configuration;
22 | }
23 |
24 | public void ConfigureServices(IServiceCollection services)
25 | {
26 | // Way-1: Register Profiles and/or Mapping manually.
27 | services.AddAutoMapper(cfg =>
28 | {
29 | cfg.AddProfile();
30 | //cfg.CreateMap(); // other option
31 | });
32 |
33 |
34 | // Way-2: Register using Assembly. Scan an assembly for components.
35 | //services.AddAutoMapper(typeof(Startup));
36 |
37 |
38 | services.AddControllers();
39 | services.AddSwaggerGen(c =>
40 | {
41 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "AutoMapperExamples.Api", Version = "v1" });
42 | });
43 | }
44 |
45 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
46 | {
47 | if (env.IsDevelopment())
48 | {
49 | app.UseDeveloperExceptionPage();
50 | }
51 |
52 | app.UseSwagger();
53 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "AutoMapperExamples.Api v1"));
54 |
55 | app.UseHttpsRedirection();
56 |
57 | app.UseRouting();
58 |
59 | app.UseAuthorization();
60 |
61 | app.UseEndpoints(endpoints =>
62 | {
63 | endpoints.MapControllers();
64 | });
65 | }
66 | }
67 | }
68 |
69 |
70 |
71 | // https://github.com/AutoMapper/AutoMapper/blob/master/docs/Configuration.md
72 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.Api/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/AutoMapperExamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{12366824-1C88-4271-AB4C-4335FAADE755}"
7 | ProjectSection(SolutionItems) = preProject
8 | README.md = README.md
9 | EndProjectSection
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutoMapperExamples.Api", "AutoMapperExamples.Api\AutoMapperExamples.Api.csproj", "{C2C94EDB-8863-44D8-BE0A-4EE1B681D9CE}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {C2C94EDB-8863-44D8-BE0A-4EE1B681D9CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {C2C94EDB-8863-44D8-BE0A-4EE1B681D9CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {C2C94EDB-8863-44D8-BE0A-4EE1B681D9CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {C2C94EDB-8863-44D8-BE0A-4EE1B681D9CE}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {B028DB18-BD60-46F6-9C93-D4EAF49AE26F}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/libraries/AutoMapper/README.md:
--------------------------------------------------------------------------------
1 | # AutoMapper in .NET
2 |
3 | > Demo: Example project that consume and demonstrate AutoMapper functionality and integration in ASP.NET/.NET Core.
4 |
5 | ## Work in progress
6 |
7 |
8 | Please refer to below article of my publication [.NET Hub](https://medium.com/dotnet-hub):
9 |
10 | - [Use AutoMapper in ASP.NET or ASP.NET Core](https://medium.com/dotnet-hub)
11 |
12 |
13 |
14 |
15 | ---
16 |
17 |
18 |
19 |
20 |
21 | ## Give a Star! :star:
22 |
23 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
24 |
25 |
26 | ## Support :telephone:
27 |
28 | > Reach out to me at one of the following places!
29 |
30 | - Email :envelope: at `toaashishpatel@gmail.com`
31 |
32 |
33 | ## Author :boy:
34 |
35 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
36 |
37 |
38 | ##### Connect with me
39 |
40 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
41 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
42 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
43 |
44 |
45 | ## Donate :dollar:
46 |
47 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
48 | | PayPal | BMC | Patreon |
49 | | ------------- | ------------- | ------------- |
50 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
51 |
52 |
53 | ## License :lock:
54 |
55 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
56 |
--------------------------------------------------------------------------------
/libraries/Autofac/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/AutofacExamples.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | dbd8da73-2b10-4182-9f86-7bb5f2a42347
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/Controllers/TestController.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using AutofacExamples.Api.Services;
3 | using Microsoft.AspNetCore.Mvc;
4 | using Microsoft.Extensions.Logging;
5 | #endregion
6 |
7 | namespace AutofacExamples.Api.Controllers
8 | {
9 | [ApiController]
10 | [Route("[controller]")]
11 | public class TestController : ControllerBase
12 | {
13 | #region Members
14 |
15 | private readonly IService _service;
16 | private readonly ILogger _logger;
17 |
18 | #endregion
19 |
20 | #region Ctor
21 |
22 | public TestController(IService service, ILogger logger)
23 | {
24 | _service = service;
25 | _logger = logger;
26 | }
27 |
28 | #endregion
29 |
30 | #region Methods
31 |
32 | [HttpGet]
33 | public IActionResult Get()
34 | {
35 | var result = _service.Method(0, "");
36 | return Ok(result);
37 | }
38 |
39 | #endregion
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["AutofacExamples.Api/AutofacExamples.Api.csproj", "AutofacExamples.Api/"]
11 | RUN dotnet restore "AutofacExamples.Api/AutofacExamples.Api.csproj"
12 | COPY . .
13 | WORKDIR "/src/AutofacExamples.Api"
14 | RUN dotnet build "AutofacExamples.Api.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "AutofacExamples.Api.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "AutofacExamples.Api.dll"]
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/Infrastructure/MyAutofacModule.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using Autofac;
3 | using AutofacExamples.Api.Services;
4 | #endregion
5 |
6 | namespace AutofacExamples.Api.Infrastructure
7 | {
8 | ///
9 | /// Autofac module
10 | /// Configure related services that provide a subsystem.
11 | /// Package optional application features as ‘plug-ins’.
12 | /// Register a number of similar services that are often used together.
13 | ///
14 | public class MyAutofacModule : Module
15 | {
16 | protected override void Load(ContainerBuilder builder)
17 | {
18 | //builder.RegisterType().As();
19 |
20 | // Transient
21 | builder.RegisterType().As()
22 | .InstancePerDependency();
23 |
24 | // Scoped
25 | builder.RegisterType().As()
26 | .InstancePerLifetimeScope();
27 |
28 | builder.RegisterType().As()
29 | .InstancePerRequest();
30 |
31 |
32 | // Singleton
33 | builder.RegisterType().As()
34 | .SingleInstance();
35 |
36 |
37 |
38 | //// Scan an assembly for components
39 | //builder.RegisterAssemblyTypes(typeof(Startup).Assembly)
40 | // .Where(t => t.Name.EndsWith("Service"))
41 | // .AsImplementedInterfaces();
42 | }
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/Program.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using Autofac.Extensions.DependencyInjection;
3 | using Microsoft.AspNetCore.Hosting;
4 | using Microsoft.Extensions.Hosting;
5 | #endregion
6 |
7 | namespace AutofacExamples.Api
8 | {
9 | public class Program
10 | {
11 | public static void Main(string[] args)
12 | {
13 | CreateHostBuilder(args).Build().Run();
14 | }
15 |
16 | public static IHostBuilder CreateHostBuilder(string[] args) =>
17 | Host.CreateDefaultBuilder(args)
18 | .UseServiceProviderFactory(new AutofacServiceProviderFactory())
19 | .ConfigureWebHostDefaults(webBuilder =>
20 | {
21 | webBuilder.UseStartup();
22 | });
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:36994",
7 | "sslPort": 44355
8 | }
9 | },
10 | "$schema": "http://json.schemastore.org/launchsettings.json",
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "AutofacExamples.Api": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | },
27 | "dotnetRunMessages": "true",
28 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
29 | },
30 | "Docker": {
31 | "commandName": "Docker",
32 | "launchBrowser": true,
33 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
34 | "publishAllPorts": true,
35 | "useSSL": true
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/Services/IService.cs:
--------------------------------------------------------------------------------
1 | namespace AutofacExamples.Api.Services
2 | {
3 | public interface IService
4 | {
5 | string Method(int i, string s);
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/Services/MyService.cs:
--------------------------------------------------------------------------------
1 | namespace AutofacExamples.Api.Services
2 | {
3 | public class MyService : IService
4 | {
5 | public string Method(int i, string s)
6 | {
7 | return "My Data";
8 | }
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/Startup.cs:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/a-patel/dotnet-labs/c63f76c2c7bcc16f6520402c04685f775004c9a7/libraries/Autofac/AutofacExamples.Api/Startup.cs
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.Api/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/Autofac/AutofacExamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutofacExamples.Api", "AutofacExamples.Api\AutofacExamples.Api.csproj", "{DD821011-40B2-4DEB-B93B-EDB9E8D1B895}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {DD821011-40B2-4DEB-B93B-EDB9E8D1B895}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {DD821011-40B2-4DEB-B93B-EDB9E8D1B895}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {DD821011-40B2-4DEB-B93B-EDB9E8D1B895}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {DD821011-40B2-4DEB-B93B-EDB9E8D1B895}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {99081486-B9D4-4C38-BA2F-E090A68310D6}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/libraries/Autofac/README.md:
--------------------------------------------------------------------------------
1 | # Autofac in .NET
2 |
3 | > Demo: Example project that consume and demonstrate Autofac functionality and integration in ASP.NET/.NET Core.
4 |
5 |
6 |
7 | Please refer to below article of my publication [.NET Hub](https://medium.com/dotnet-hub):
8 |
9 | - [Use Autofac IoC Container in ASP.NET or ASP.NET Core](https://medium.com/dotnet-hub/use-autofac-ioc-container-in-dotnet-or-aspnetcore-autofac-dependency-injection-netcore-ffad19d87163)
10 |
11 |
12 |
13 |
14 | ---
15 |
16 |
17 |
18 |
19 |
20 | ## Give a Star! :star:
21 |
22 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
23 |
24 |
25 | ## Support :telephone:
26 |
27 | > Reach out to me at one of the following places!
28 |
29 | - Email :envelope: at `toaashishpatel@gmail.com`
30 |
31 |
32 | ## Author :boy:
33 |
34 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
35 |
36 |
37 | ##### Connect with me
38 |
39 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
40 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
41 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
42 |
43 |
44 | ## Donate :dollar:
45 |
46 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
47 | | PayPal | BMC | Patreon |
48 | | ------------- | ------------- | ------------- |
49 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
50 |
51 |
52 | ## License :lock:
53 |
54 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
55 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Controllers/CustomerController.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using FluentValidationExamples.Api.Infrastructure.Validators;
3 | using FluentValidationExamples.Api.Model;
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.Extensions.Logging;
6 | #endregion
7 |
8 | namespace FluentValidationExamples.Api.Controllers
9 | {
10 | [ApiController]
11 | [Route("[controller]")]
12 | public class CustomerController : ControllerBase
13 | {
14 | #region Members
15 |
16 | private readonly ILogger _logger;
17 |
18 | #endregion
19 |
20 | #region Ctor
21 |
22 | public CustomerController(ILogger logger)
23 | {
24 | _logger = logger;
25 | }
26 |
27 | #endregion
28 |
29 | #region Methods
30 |
31 | [HttpPost]
32 | public IActionResult Add(CustomerModel model)
33 | {
34 | if (!ModelState.IsValid)
35 | {
36 | return BadRequest(ModelState);
37 |
38 | // re-render the view when validation failed.
39 | //return View(model);
40 | }
41 |
42 | //TODO: Save the data to the database, or some other logic.
43 |
44 | return Ok();
45 | }
46 |
47 | // Manual validation
48 | [HttpPost]
49 | public IActionResult Update(CustomerModel model)
50 | {
51 | CustomerValidator validator = new CustomerValidator();
52 | var validationResult = validator.Validate(model);
53 |
54 | if (!validationResult.IsValid)
55 | {
56 | return BadRequest(validationResult.Errors);
57 | }
58 |
59 | //TODO: Save the data to the database, or some other logic.
60 |
61 | return Ok();
62 | }
63 |
64 | #endregion
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["FluentValidationExamples.Api/FluentValidationExamples.Api.csproj", "FluentValidationExamples.Api/"]
11 | RUN dotnet restore "FluentValidationExamples.Api/FluentValidationExamples.Api.csproj"
12 | COPY . .
13 | WORKDIR "/src/FluentValidationExamples.Api"
14 | RUN dotnet build "FluentValidationExamples.Api.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "FluentValidationExamples.Api.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "FluentValidationExamples.Api.dll"]
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/FluentValidationExamples.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | af78c881-bc90-4d3b-ae77-c3400a6b4330
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Infrastructure/Validators/AddressValidator.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using FluentValidation;
3 | using FluentValidationExamples.Api.Model;
4 | #endregion
5 |
6 | namespace FluentValidationExamples.Api.Infrastructure.Validators
7 | {
8 | public class AddressValidator : AbstractValidator
9 | {
10 | public AddressValidator()
11 | {
12 | RuleFor(x => x.State).NotNull().NotEmpty();
13 | RuleFor(x => x.Country).NotEmpty().WithMessage("Please specify a Country.");
14 |
15 | RuleFor(x => x.Postcode).NotNull();
16 | //RuleFor(x => x.Postcode).Must(BeAValidPostcode).WithMessage("Please specify a valid postcode");
17 | }
18 |
19 | //private bool BeAValidPostcode(string postcode)
20 | //{
21 | // // custom postcode validating logic goes here
22 | //}
23 | }
24 | }
25 |
26 |
27 | // https://docs.fluentvalidation.net/en/latest/
28 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Infrastructure/Validators/CustomerValidator.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using FluentValidation;
3 | using FluentValidationExamples.Api.Model;
4 | #endregion
5 |
6 | namespace FluentValidationExamples.Api.Infrastructure.Validators
7 | {
8 | public class CustomerValidator : AbstractValidator
9 | {
10 | public CustomerValidator()
11 | //public CustomerValidator(IValidator addressValidator)
12 | {
13 | RuleFor(x => x.Name).NotNull().NotEmpty();
14 | RuleFor(x => x.Name).Length(20, 250);
15 | RuleFor(x => x.PhoneNumber).NotEmpty().WithMessage("Please specify a phone number.");
16 | RuleFor(x => x.Age).InclusiveBetween(18, 60);
17 |
18 | // Complex Properties
19 | //RuleFor(x => x.Address).SetValidator(addressValidator);
20 | //RuleFor(x => x.Address).SetValidator(new AddressValidator());
21 | RuleFor(x => x.Address).InjectValidator();
22 |
23 | // Collections of Complex Types
24 | //RuleForEach(x => x.Addresses).SetValidator(new AddressValidator());
25 | }
26 | }
27 | }
28 |
29 |
30 |
31 | // https://docs.fluentvalidation.net/en/latest/
32 | // https://docs.fluentvalidation.net/en/latest/start.html#complex-properties
33 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Models/AddressModel.cs:
--------------------------------------------------------------------------------
1 | namespace FluentValidationExamples.Api.Model
2 | {
3 | public class AddressModel
4 | {
5 | public string Line1 { get; set; }
6 |
7 | public string Line2 { get; set; }
8 |
9 | public string Town { get; set; }
10 |
11 | public string Postcode { get; set; }
12 |
13 | public string Country { get; set; }
14 |
15 | public string State { get; set; }
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Models/CustomerModel.cs:
--------------------------------------------------------------------------------
1 | namespace FluentValidationExamples.Api.Model
2 | {
3 | public class CustomerModel
4 | {
5 | public string Name { get; set; }
6 |
7 | public int Age { get; set; }
8 |
9 | public string PhoneNumber { get; set; }
10 |
11 | public bool IsAdult { get; set; }
12 |
13 |
14 | public AddressModel Address { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Program.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.Extensions.Hosting;
4 | #endregion
5 |
6 | namespace FluentValidationExamples.Api
7 | {
8 | public class Program
9 | {
10 | public static void Main(string[] args)
11 | {
12 | CreateHostBuilder(args).Build().Run();
13 | }
14 |
15 | public static IHostBuilder CreateHostBuilder(string[] args) =>
16 | Host.CreateDefaultBuilder(args)
17 | .ConfigureWebHostDefaults(webBuilder =>
18 | {
19 | webBuilder.UseStartup();
20 | });
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:45062",
7 | "sslPort": 44367
8 | }
9 | },
10 | "$schema": "http://json.schemastore.org/launchsettings.json",
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "FluentValidationExamples.Api": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | },
27 | "dotnetRunMessages": "true",
28 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
29 | },
30 | "Docker": {
31 | "commandName": "Docker",
32 | "launchBrowser": true,
33 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
34 | "publishAllPorts": true,
35 | "useSSL": true
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/Startup.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using FluentValidation.AspNetCore;
3 | using Microsoft.AspNetCore.Builder;
4 | using Microsoft.AspNetCore.Hosting;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.OpenApi.Models;
9 | using System.Reflection;
10 | #endregion
11 |
12 | namespace FluentValidationExamples.Api
13 | {
14 | public class Startup
15 | {
16 | public IConfiguration Configuration { get; }
17 |
18 |
19 | public Startup(IConfiguration configuration)
20 | {
21 | Configuration = configuration;
22 | }
23 |
24 |
25 | public void ConfigureServices(IServiceCollection services)
26 | {
27 | services.AddControllers();
28 |
29 | // version 11.1 and newer
30 | services.AddFluentValidationAutoValidation(config =>
31 | {
32 | config.ImplicitlyValidateChildProperties = true;
33 | });
34 |
35 | // In older versions, call services.AddFluentValidation() instead,
36 | // which is the equivalent of calling services.AddFluentValidationAutoValidation().AddFluentValidationClientsideAdapters()
37 | services.AddFluentValidationAutoValidation().AddFluentValidationClientsideAdapters();
38 |
39 | //// Obsolute
40 | //services.AddFluentValidation(fv =>
41 | // {
42 | // fv.ImplicitlyValidateChildProperties = true;
43 | // fv.ImplicitlyValidateRootCollectionElements = true;
44 | // fv.RegisterValidatorsFromAssembly(Assembly.GetExecutingAssembly());
45 | // //fv.RegisterValidatorsFromAssemblyContaining(); // Other way to register validators
46 | // });
47 |
48 | services.AddSwaggerGen(c =>
49 | {
50 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "FluentValidation Examples Api", Version = "v1" });
51 | });
52 | }
53 |
54 |
55 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
56 | {
57 | if (env.IsDevelopment())
58 | {
59 | app.UseDeveloperExceptionPage();
60 | }
61 |
62 | app.UseSwagger();
63 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "FluentValidation Examples Api v1"));
64 |
65 |
66 | app.UseHttpsRedirection();
67 |
68 | app.UseRouting();
69 |
70 | app.UseAuthorization();
71 |
72 | app.UseEndpoints(endpoints =>
73 | {
74 | endpoints.MapControllers();
75 | });
76 | }
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.Api/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/FluentValidationExamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CAA6C037-49D9-4D4C-83C6-6BA4D5B62907}"
7 | ProjectSection(SolutionItems) = preProject
8 | README.md = README.md
9 | EndProjectSection
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentValidationExamples.Api", "FluentValidationExamples.Api\FluentValidationExamples.Api.csproj", "{BAF096C2-3E18-48ED-B477-02960AFC0C17}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {BAF096C2-3E18-48ED-B477-02960AFC0C17}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {BAF096C2-3E18-48ED-B477-02960AFC0C17}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {BAF096C2-3E18-48ED-B477-02960AFC0C17}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {BAF096C2-3E18-48ED-B477-02960AFC0C17}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {BB487477-F56B-4E14-889C-C99906EAC39F}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/libraries/FluentValidation/README.md:
--------------------------------------------------------------------------------
1 | # Fluent Validation in .NET
2 |
3 | > Demo: Example project that consume and demonstrate Fluent Validation functionality and integration in ASP.NET/.NET Core.
4 |
5 | ## Work in progress
6 |
7 |
8 | Please refer to below article of my publication [.NET Hub](https://medium.com/dotnet-hub):
9 |
10 | - [Use Fluent Validation in ASP.NET or ASP.NET Core](https://medium.com/dotnet-hub)
11 |
12 |
13 |
14 |
15 | ---
16 |
17 |
18 |
19 |
20 |
21 | ## Give a Star! :star:
22 |
23 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
24 |
25 |
26 | ## Support :telephone:
27 |
28 | > Reach out to me at one of the following places!
29 |
30 | - Email :envelope: at `toaashishpatel@gmail.com`
31 |
32 |
33 | ## Author :boy:
34 |
35 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
36 |
37 |
38 | ##### Connect with me
39 |
40 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
41 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
42 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
43 |
44 |
45 | ## Donate :dollar:
46 |
47 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
48 | | PayPal | BMC | Patreon |
49 | | ------------- | ------------- | ------------- |
50 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
51 |
52 |
53 | ## License :lock:
54 |
55 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
56 |
--------------------------------------------------------------------------------
/libraries/Hangfire/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.Extensions.Logging;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 |
8 | namespace HangfireExamples.Api.Controllers
9 | {
10 | [ApiController]
11 | [Route("[controller]")]
12 | public class WeatherForecastController : ControllerBase
13 | {
14 | private static readonly string[] Summaries = new[]
15 | {
16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
17 | };
18 |
19 | private readonly ILogger _logger;
20 |
21 | public WeatherForecastController(ILogger logger)
22 | {
23 | _logger = logger;
24 | }
25 |
26 | [HttpGet]
27 | public IEnumerable Get()
28 | {
29 | var rng = new Random();
30 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
31 | {
32 | Date = DateTime.Now.AddDays(index),
33 | TemperatureC = rng.Next(-20, 55),
34 | Summary = Summaries[rng.Next(Summaries.Length)]
35 | })
36 | .ToArray();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["HangfireExamples.Api/HangfireExamples.Api.csproj", "HangfireExamples.Api/"]
11 | RUN dotnet restore "HangfireExamples.Api/HangfireExamples.Api.csproj"
12 | COPY . .
13 | WORKDIR "/src/HangfireExamples.Api"
14 | RUN dotnet build "HangfireExamples.Api.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "HangfireExamples.Api.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "HangfireExamples.Api.dll"]
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/HangfireExamples.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | d1a7b171-5961-4586-968c-7a6c50c5a67c
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.Hosting;
4 | using Microsoft.Extensions.Logging;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 |
10 | namespace HangfireExamples.Api
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | CreateHostBuilder(args).Build().Run();
17 | }
18 |
19 | public static IHostBuilder CreateHostBuilder(string[] args) =>
20 | Host.CreateDefaultBuilder(args)
21 | .ConfigureWebHostDefaults(webBuilder =>
22 | {
23 | webBuilder.UseStartup();
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:9099",
7 | "sslPort": 44312
8 | }
9 | },
10 | "$schema": "http://json.schemastore.org/launchsettings.json",
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "HangfireExamples.Api": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | },
27 | "dotnetRunMessages": "true",
28 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
29 | },
30 | "Docker": {
31 | "commandName": "Docker",
32 | "launchBrowser": true,
33 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
34 | "publishAllPorts": true,
35 | "useSSL": true
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.AspNetCore.HttpsPolicy;
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.Extensions.Logging;
9 | using Microsoft.OpenApi.Models;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.Linq;
13 | using System.Threading.Tasks;
14 |
15 | namespace HangfireExamples.Api
16 | {
17 | public class Startup
18 | {
19 | public Startup(IConfiguration configuration)
20 | {
21 | Configuration = configuration;
22 | }
23 |
24 | public IConfiguration Configuration { get; }
25 |
26 | // This method gets called by the runtime. Use this method to add services to the container.
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 |
30 | services.AddControllers();
31 | services.AddSwaggerGen(c =>
32 | {
33 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "HangfireExamples.Api", Version = "v1" });
34 | });
35 | }
36 |
37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
38 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
39 | {
40 | if (env.IsDevelopment())
41 | {
42 | app.UseDeveloperExceptionPage();
43 | app.UseSwagger();
44 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "HangfireExamples.Api v1"));
45 | }
46 |
47 | app.UseHttpsRedirection();
48 |
49 | app.UseRouting();
50 |
51 | app.UseAuthorization();
52 |
53 | app.UseEndpoints(endpoints =>
54 | {
55 | endpoints.MapControllers();
56 | });
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace HangfireExamples.Api
4 | {
5 | public class WeatherForecast
6 | {
7 | public DateTime Date { get; set; }
8 |
9 | public int TemperatureC { get; set; }
10 |
11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12 |
13 | public string Summary { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.Api/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/Hangfire/HangfireExamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{38184D78-1EFC-47CA-867B-11D6DAA1930A}"
7 | ProjectSection(SolutionItems) = preProject
8 | README.md = README.md
9 | EndProjectSection
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HangfireExamples.Api", "HangfireExamples.Api\HangfireExamples.Api.csproj", "{E2EFF1CA-6BD7-4362-A5BF-34BEB5A61A3A}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {E2EFF1CA-6BD7-4362-A5BF-34BEB5A61A3A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {E2EFF1CA-6BD7-4362-A5BF-34BEB5A61A3A}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {E2EFF1CA-6BD7-4362-A5BF-34BEB5A61A3A}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {E2EFF1CA-6BD7-4362-A5BF-34BEB5A61A3A}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {028AD691-6002-4E1E-845E-C3F30200FFA2}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/libraries/Hangfire/README.md:
--------------------------------------------------------------------------------
1 | # Hangfire in .NET
2 |
3 | > Demo: Example project that consume and demonstrate Hangfire functionality and integration in ASP.NET/.NET Core.
4 |
5 | ## Work in progress
6 |
7 |
8 | Please refer to below article of my publication [.NET Hub](https://medium.com/dotnet-hub):
9 |
10 | - [Use Hangfire in ASP.NET or ASP.NET Core](https://medium.com/dotnet-hub)
11 |
12 |
13 |
14 |
15 | ---
16 |
17 |
18 |
19 |
20 |
21 | ## Give a Star! :star:
22 |
23 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
24 |
25 |
26 | ## Support :telephone:
27 |
28 | > Reach out to me at one of the following places!
29 |
30 | - Email :envelope: at `toaashishpatel@gmail.com`
31 |
32 |
33 | ## Author :boy:
34 |
35 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
36 |
37 |
38 | ##### Connect with me
39 |
40 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
41 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
42 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
43 |
44 |
45 | ## Donate :dollar:
46 |
47 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
48 | | PayPal | BMC | Patreon |
49 | | ------------- | ------------- | ------------- |
50 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
51 |
52 |
53 | ## License :lock:
54 |
55 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
56 |
--------------------------------------------------------------------------------
/libraries/MediatR/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Application/Customers/Commands/CreateCustomerCommand.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Model;
4 | #endregion
5 |
6 | namespace MediatRExamples.Api.Application.Customers.Commands
7 | {
8 | public class CreateCustomerCommand : IRequest
9 | {
10 | public Customer Customer { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Application/Customers/Commands/CreateCustomerCommandHandler.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Data;
4 | using MediatRExamples.Api.Model;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | #endregion
8 |
9 | namespace MediatRExamples.Api.Application.Customers.Commands
10 | {
11 | public class CreateCustomerCommandHandler : IRequestHandler
12 | {
13 | private readonly IRepository _repository;
14 |
15 | public CreateCustomerCommandHandler(IRepository repository)
16 | {
17 | _repository = repository;
18 | }
19 |
20 | public async Task Handle(CreateCustomerCommand request, CancellationToken cancellationToken)
21 | {
22 | return await _repository.AddAsync(request.Customer);
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Application/Customers/Commands/UpdateCustomerCommand.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Model;
4 | using System;
5 | #endregion
6 |
7 | namespace MediatRExamples.Api.Application.Customers.Commands
8 | {
9 | public class UpdateCustomerCommand : IRequest
10 | {
11 | public Customer Customer { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Application/Customers/Commands/UpdateCustomerCommandHandler.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Data;
4 | using MediatRExamples.Api.Model;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | #endregion
8 |
9 | namespace MediatRExamples.Api.Application.Customers.Commands
10 | {
11 | public class UpdateCustomerCommandHandler : IRequestHandler
12 | {
13 | private readonly IRepository _repository;
14 |
15 | public UpdateCustomerCommandHandler(IRepository repository)
16 | {
17 | _repository = repository;
18 | }
19 |
20 | public async Task Handle(UpdateCustomerCommand request, CancellationToken cancellationToken)
21 | {
22 | var customer = await _repository.UpdateAsync(request.Customer);
23 |
24 | return customer;
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Application/Customers/Queries/GetCustomerByIdQuery.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Model;
4 | using System;
5 | #endregion
6 |
7 | namespace MediatRExamples.Api.Application.Customers.Queries
8 | {
9 | public class GetCustomerByIdQuery : IRequest
10 | {
11 | public Guid Id { get; set; }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Application/Customers/Queries/GetCustomerByIdQueryHandler.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Data;
4 | using MediatRExamples.Api.Model;
5 | using System.Linq;
6 | using System.Threading;
7 | using System.Threading.Tasks;
8 | #endregion
9 |
10 | namespace MediatRExamples.Api.Application.Customers.Queries
11 | {
12 | public class GetCustomerByIdQueryHandler : IRequestHandler
13 | {
14 | private readonly IRepository _repository;
15 |
16 | public GetCustomerByIdQueryHandler(IRepository repository)
17 | {
18 | _repository = repository;
19 | }
20 |
21 | public async Task Handle(GetCustomerByIdQuery request, CancellationToken cancellationToken)
22 | {
23 | return _repository.GetAll().FirstOrDefault(x => x.Id == request.Id);
24 | //return await _repository.GetAll().FirstOrDefaultAsync(x => x.Id == request.Id, cancellationToken);
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Application/Customers/Queries/GetCustomersQuery.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Model;
4 | using System.Collections.Generic;
5 | #endregion
6 |
7 | namespace MediatRExamples.Api.Application.Customers.Queries
8 | {
9 | public class GetCustomersQuery : IRequest>
10 | {
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Application/Customers/Queries/GetCustomersQueryHandler.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Data;
4 | using MediatRExamples.Api.Model;
5 | using System.Linq;
6 | using System.Collections.Generic;
7 | using System.Threading;
8 | using System.Threading.Tasks;
9 | #endregion
10 |
11 | namespace MediatRExamples.Api.Application.Customers.Queries
12 | {
13 | public class GetCustomersQueryHandler : IRequestHandler>
14 | {
15 | private readonly IRepository _repository;
16 |
17 | public GetCustomersQueryHandler(IRepository repository)
18 | {
19 | _repository = repository;
20 | }
21 |
22 | public async Task> Handle(GetCustomersQuery request, CancellationToken cancellationToken)
23 | {
24 | return _repository.GetAll().ToList();
25 | //return await _repository.GetAll().ToListAsync(cancellationToken: cancellationToken);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Controllers/CustomerController.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Application.Customers.Commands;
4 | using MediatRExamples.Api.Application.Customers.Queries;
5 | using MediatRExamples.Api.Model;
6 | using MediatRExamples.Api.Models;
7 | using Microsoft.AspNetCore.Mvc;
8 | using Microsoft.Extensions.Logging;
9 | using System;
10 | using System.Threading.Tasks;
11 | #endregion
12 |
13 | namespace MediatRExamples.Api.Controllers
14 | {
15 | [ApiController]
16 | [Route("[controller]")]
17 | public class CustomerController : ControllerBase
18 | {
19 | #region Members
20 |
21 | private readonly IMediator _mediator;
22 | private readonly ILogger _logger;
23 |
24 | #endregion
25 |
26 | #region Ctor
27 |
28 | public CustomerController(IMediator mediator, ILogger logger)
29 | {
30 | _mediator = mediator;
31 | _logger = logger;
32 | }
33 |
34 | #endregion
35 |
36 | #region Methods
37 |
38 | [HttpGet("all")]
39 | public async Task GetAll()
40 | {
41 | var result = await _mediator.Send(new GetCustomersQuery());
42 |
43 | return Ok(result);
44 | }
45 |
46 |
47 | [HttpGet("{id}")]
48 | public async Task Get([FromRoute] Guid id)
49 | {
50 | var result = await _mediator.Send(new GetCustomerByIdQuery
51 | {
52 | Id = id
53 | });
54 |
55 | return Ok(result);
56 | }
57 |
58 |
59 | [HttpPost("add")]
60 | public async Task Add([FromBody] CreateCustomerModel createCustomerModel)
61 | {
62 | //TODO: Use AutoMapper for mappings
63 |
64 | var customer = new Customer()
65 | {
66 | FirstName = createCustomerModel.FirstName,
67 | LastName = createCustomerModel.LastName,
68 | Birthday = createCustomerModel.Birthday,
69 | Age = createCustomerModel.Age,
70 | Phone = createCustomerModel.Phone,
71 | };
72 |
73 | var result = await _mediator.Send(new CreateCustomerCommand
74 | {
75 | Customer = customer
76 | });
77 |
78 | return Ok(result);
79 | }
80 |
81 |
82 | [HttpPut("update")]
83 | public async Task Update([FromBody] UpdateCustomerModel updateCustomerModel)
84 | {
85 | //TODO: Use AutoMapper for mappings
86 |
87 | var existCustomer = await _mediator.Send(new GetCustomerByIdQuery
88 | {
89 | Id = updateCustomerModel.Id
90 | });
91 |
92 | if (existCustomer == null)
93 | {
94 | return BadRequest($"No customer found with the id {updateCustomerModel.Id}");
95 | }
96 |
97 |
98 | var customer = new Customer()
99 | {
100 | Id = updateCustomerModel.Id,
101 | FirstName = updateCustomerModel.FirstName,
102 | LastName = updateCustomerModel.LastName,
103 | Birthday = updateCustomerModel.Birthday,
104 | Age = updateCustomerModel.Age,
105 | Phone = updateCustomerModel.Phone,
106 | };
107 |
108 | var result = await _mediator.Send(new UpdateCustomerCommand
109 | {
110 | Customer = customer
111 | });
112 |
113 | return Ok(result);
114 | }
115 |
116 | #endregion
117 | }
118 | }
119 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Data/IRepository.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using System.Linq;
3 | using System.Threading.Tasks;
4 | #endregion
5 |
6 | namespace MediatRExamples.Api.Data
7 | {
8 | public interface IRepository where TEntity : class, new()
9 | {
10 | IQueryable GetAll();
11 |
12 | Task AddAsync(TEntity entity);
13 |
14 | Task UpdateAsync(TEntity entity);
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Data/Repository.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using System;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | #endregion
6 |
7 | namespace MediatRExamples.Api.Data
8 | {
9 | public class Repository : IRepository where TEntity : class, new()
10 | {
11 | //private readonly AppDbContext _dbContext;
12 |
13 | //public Repository(AppDbContext customerContext)
14 | //{
15 | // _dbContext = customerContext;
16 | //}
17 |
18 | public IQueryable GetAll()
19 | {
20 | throw new NotImplementedException();
21 |
22 | //try
23 | //{
24 | // return _dbContext.Set();
25 | //}
26 | //catch (Exception)
27 | //{
28 | // throw new Exception("Couldn't retrieve entities");
29 | //}
30 | }
31 |
32 | public async Task AddAsync(TEntity entity)
33 | {
34 | throw new NotImplementedException();
35 |
36 | //if (entity == null)
37 | //{
38 | // throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
39 | //}
40 |
41 | //try
42 | //{
43 | // await _dbContext.AddAsync(entity);
44 | // await _dbContext.SaveChangesAsync();
45 |
46 | // return entity;
47 | //}
48 | //catch (Exception)
49 | //{
50 | // throw new Exception($"{nameof(entity)} could not be saved");
51 | //}
52 | }
53 |
54 | public async Task UpdateAsync(TEntity entity)
55 | {
56 | throw new NotImplementedException();
57 |
58 | //if (entity == null)
59 | //{
60 | // throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
61 | //}
62 |
63 | //try
64 | //{
65 | // _dbContext.Update(entity);
66 | // await _dbContext.SaveChangesAsync();
67 |
68 | // return entity;
69 | //}
70 | //catch (Exception)
71 | //{
72 | // throw new Exception($"{nameof(entity)} could not be updated");
73 | //}
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["MediatRExamples.Api/MediatRExamples.Api.csproj", "MediatRExamples.Api/"]
11 | RUN dotnet restore "MediatRExamples.Api/MediatRExamples.Api.csproj"
12 | COPY . .
13 | WORKDIR "/src/MediatRExamples.Api"
14 | RUN dotnet build "MediatRExamples.Api.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "MediatRExamples.Api.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "MediatRExamples.Api.dll"]
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Domain/Customer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MediatRExamples.Api.Model
4 | {
5 | public class Customer
6 | {
7 | public Guid Id { get; set; }
8 |
9 | public string FirstName { get; set; }
10 |
11 | public string LastName { get; set; }
12 |
13 | public DateTime? Birthday { get; set; }
14 |
15 | public int? Age { get; set; }
16 |
17 | public string Phone { get; set; }
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/MediatRExamples.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | 44a51f9e-3278-4927-aa86-63ce98087374
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Models/CreateCustomerModel.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using System;
3 | using System.ComponentModel.DataAnnotations;
4 | #endregion
5 |
6 | namespace MediatRExamples.Api.Models
7 | {
8 | public class CreateCustomerModel
9 | {
10 | [Required]
11 | public string FirstName { get; set; }
12 |
13 | [Required]
14 | public string LastName { get; set; }
15 |
16 | public DateTime? Birthday { get; set; }
17 |
18 | public int? Age { get; set; }
19 |
20 | public string Phone { get; set; }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Models/UpdateCustomerModel.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using System;
3 | using System.ComponentModel.DataAnnotations;
4 | #endregion
5 |
6 | namespace MediatRExamples.Api.Models
7 | {
8 | public class UpdateCustomerModel
9 | {
10 | [Required]
11 | public Guid Id { get; set; }
12 |
13 | [Required]
14 | public string FirstName { get; set; }
15 |
16 | [Required]
17 | public string LastName { get; set; }
18 |
19 | public DateTime? Birthday { get; set; }
20 |
21 | public int? Age { get; set; }
22 |
23 | public string Phone { get; set; }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Program.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.Extensions.Hosting;
4 | #endregion
5 |
6 | namespace MediatRExamples.Api
7 | {
8 | public class Program
9 | {
10 | public static void Main(string[] args)
11 | {
12 | CreateHostBuilder(args).Build().Run();
13 | }
14 |
15 | public static IHostBuilder CreateHostBuilder(string[] args) =>
16 | Host.CreateDefaultBuilder(args)
17 | .ConfigureWebHostDefaults(webBuilder =>
18 | {
19 | webBuilder.UseStartup();
20 | });
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:6948",
7 | "sslPort": 44309
8 | }
9 | },
10 | "$schema": "http://json.schemastore.org/launchsettings.json",
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "MediatRExamples.Api": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | },
27 | "dotnetRunMessages": "true",
28 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
29 | },
30 | "Docker": {
31 | "commandName": "Docker",
32 | "launchBrowser": true,
33 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
34 | "publishAllPorts": true,
35 | "useSSL": true
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/Startup.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using MediatR;
3 | using MediatRExamples.Api.Data;
4 | using Microsoft.AspNetCore.Builder;
5 | using Microsoft.AspNetCore.Hosting;
6 | using Microsoft.Extensions.Configuration;
7 | using Microsoft.Extensions.DependencyInjection;
8 | using Microsoft.Extensions.Hosting;
9 | using Microsoft.OpenApi.Models;
10 | using System.Reflection;
11 | #endregion
12 |
13 | namespace MediatRExamples.Api
14 | {
15 | public class Startup
16 | {
17 | public IConfiguration Configuration { get; }
18 |
19 |
20 | public Startup(IConfiguration configuration)
21 | {
22 | Configuration = configuration;
23 | }
24 |
25 |
26 | public void ConfigureServices(IServiceCollection services)
27 | {
28 | services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
29 |
30 | services.AddControllers();
31 | services.AddSwaggerGen(c =>
32 | {
33 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "MediatR Examples Api", Version = "v1" });
34 | });
35 |
36 | // Register MediatR services
37 | services.AddMediatR(cfg => cfg.RegisterServicesFromAssembly(typeof(Startup).Assembly));
38 |
39 | // Way-2
40 | //services.AddMediatR(Assembly.GetExecutingAssembly());
41 |
42 | // Register from multiple assembly.
43 | //services.AddMediatR(Assembly.GetExecutingAssembly(), typeof(ICustomerService).Assembly);
44 | }
45 |
46 |
47 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
48 | {
49 | if (env.IsDevelopment())
50 | {
51 | app.UseDeveloperExceptionPage();
52 | }
53 |
54 | app.UseHttpsRedirection();
55 |
56 | app.UseSwagger();
57 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MediatR Examples Api v1"));
58 |
59 |
60 | app.UseRouting();
61 |
62 | app.UseEndpoints(endpoints =>
63 | {
64 | endpoints.MapControllers();
65 | });
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.Api/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/MediatR/MediatRExamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{0605E737-E7D7-483C-9B32-D45C933DE8D6}"
7 | ProjectSection(SolutionItems) = preProject
8 | README.md = README.md
9 | EndProjectSection
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediatRExamples.Api", "MediatRExamples.Api\MediatRExamples.Api.csproj", "{DB31756A-67F0-4BBD-A4B4-480E52CEBE0B}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {DB31756A-67F0-4BBD-A4B4-480E52CEBE0B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {DB31756A-67F0-4BBD-A4B4-480E52CEBE0B}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {DB31756A-67F0-4BBD-A4B4-480E52CEBE0B}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {DB31756A-67F0-4BBD-A4B4-480E52CEBE0B}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {72907FA6-282D-427E-BE90-CB8CC3C8FE73}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/libraries/MediatR/README.md:
--------------------------------------------------------------------------------
1 | # MediatR in .NET
2 |
3 | > Demo: Example project that consume and demonstrate MediatR functionality and integration in ASP.NET/.NET Core.
4 |
5 | ## Work in progress
6 |
7 |
8 | Please refer to below article of my publication [.NET Hub](https://medium.com/dotnet-hub):
9 |
10 | - [Use MediatR in ASP.NET or ASP.NET Core](https://medium.com/dotnet-hub)
11 |
12 |
13 |
14 |
15 | ---
16 |
17 |
18 |
19 |
20 |
21 | ## Give a Star! :star:
22 |
23 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
24 |
25 |
26 | ## Support :telephone:
27 |
28 | > Reach out to me at one of the following places!
29 |
30 | - Email :envelope: at `toaashishpatel@gmail.com`
31 |
32 |
33 | ## Author :boy:
34 |
35 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
36 |
37 |
38 | ##### Connect with me
39 |
40 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
41 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
42 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
43 |
44 |
45 | ## Donate :dollar:
46 |
47 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
48 | | PayPal | BMC | Patreon |
49 | | ------------- | ------------- | ------------- |
50 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
51 |
52 |
53 | ## License :lock:
54 |
55 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
56 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.Extensions.Logging;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 |
8 | namespace MiniProfilerExamples.Api.Controllers
9 | {
10 | [ApiController]
11 | [Route("[controller]")]
12 | public class WeatherForecastController : ControllerBase
13 | {
14 | private static readonly string[] Summaries = new[]
15 | {
16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
17 | };
18 |
19 | private readonly ILogger _logger;
20 |
21 | public WeatherForecastController(ILogger logger)
22 | {
23 | _logger = logger;
24 | }
25 |
26 | [HttpGet]
27 | public IEnumerable Get()
28 | {
29 | var rng = new Random();
30 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
31 | {
32 | Date = DateTime.Now.AddDays(index),
33 | TemperatureC = rng.Next(-20, 55),
34 | Summary = Summaries[rng.Next(Summaries.Length)]
35 | })
36 | .ToArray();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["MiniProfilerExamples.Api/MiniProfilerExamples.Api.csproj", "MiniProfilerExamples.Api/"]
11 | RUN dotnet restore "MiniProfilerExamples.Api/MiniProfilerExamples.Api.csproj"
12 | COPY . .
13 | WORKDIR "/src/MiniProfilerExamples.Api"
14 | RUN dotnet build "MiniProfilerExamples.Api.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "MiniProfilerExamples.Api.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "MiniProfilerExamples.Api.dll"]
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/MiniProfilerExamples.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | c9849afd-9e42-4e85-9ba7-c32863d29182
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.Hosting;
4 | using Microsoft.Extensions.Logging;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 |
10 | namespace MiniProfilerExamples.Api
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | CreateHostBuilder(args).Build().Run();
17 | }
18 |
19 | public static IHostBuilder CreateHostBuilder(string[] args) =>
20 | Host.CreateDefaultBuilder(args)
21 | .ConfigureWebHostDefaults(webBuilder =>
22 | {
23 | webBuilder.UseStartup();
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:31867",
7 | "sslPort": 44347
8 | }
9 | },
10 | "$schema": "http://json.schemastore.org/launchsettings.json",
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "MiniProfilerExamples.Api": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | },
27 | "dotnetRunMessages": "true",
28 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
29 | },
30 | "Docker": {
31 | "commandName": "Docker",
32 | "launchBrowser": true,
33 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
34 | "publishAllPorts": true,
35 | "useSSL": true
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.AspNetCore.HttpsPolicy;
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.Extensions.Logging;
9 | using Microsoft.OpenApi.Models;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.Linq;
13 | using System.Threading.Tasks;
14 |
15 | namespace MiniProfilerExamples.Api
16 | {
17 | public class Startup
18 | {
19 | public Startup(IConfiguration configuration)
20 | {
21 | Configuration = configuration;
22 | }
23 |
24 | public IConfiguration Configuration { get; }
25 |
26 | // This method gets called by the runtime. Use this method to add services to the container.
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 |
30 | services.AddControllers();
31 | services.AddSwaggerGen(c =>
32 | {
33 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "MiniProfilerExamples.Api", Version = "v1" });
34 | });
35 | }
36 |
37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
38 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
39 | {
40 | if (env.IsDevelopment())
41 | {
42 | app.UseDeveloperExceptionPage();
43 | app.UseSwagger();
44 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MiniProfilerExamples.Api v1"));
45 | }
46 |
47 | app.UseHttpsRedirection();
48 |
49 | app.UseRouting();
50 |
51 | app.UseAuthorization();
52 |
53 | app.UseEndpoints(endpoints =>
54 | {
55 | endpoints.MapControllers();
56 | });
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace MiniProfilerExamples.Api
4 | {
5 | public class WeatherForecast
6 | {
7 | public DateTime Date { get; set; }
8 |
9 | public int TemperatureC { get; set; }
10 |
11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12 |
13 | public string Summary { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.Api/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/MiniProfilerExamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.5.33424.131
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{9F7FFDB3-ED2F-45AB-9DF0-63DB66AF6D39}"
7 | ProjectSection(SolutionItems) = preProject
8 | README.md = README.md
9 | EndProjectSection
10 | EndProject
11 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MiniProfilerExamples.Api", "MiniProfilerExamples.Api\MiniProfilerExamples.Api.csproj", "{8B9D7805-2841-4007-857A-0D4E160B1939}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {8B9D7805-2841-4007-857A-0D4E160B1939}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {8B9D7805-2841-4007-857A-0D4E160B1939}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {8B9D7805-2841-4007-857A-0D4E160B1939}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {8B9D7805-2841-4007-857A-0D4E160B1939}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {BF787107-07B4-411F-B3D9-4CEB8C88F210}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/libraries/MiniProfiler/README.md:
--------------------------------------------------------------------------------
1 | # MiniProfiler in .NET
2 |
3 | > Demo: Example project that consume and demonstrate MiniProfiler functionality and integration in ASP.NET/.NET Core.
4 |
5 | ## Work in progress
6 |
7 |
8 | Please refer to below article of my publication [.NET Hub](https://medium.com/dotnet-hub):
9 |
10 | - [Use MiniProfiler in ASP.NET or ASP.NET Core](https://medium.com/dotnet-hub)
11 |
12 |
13 |
14 |
15 | ---
16 |
17 |
18 |
19 |
20 |
21 | ## Give a Star! :star:
22 |
23 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
24 |
25 |
26 | ## Support :telephone:
27 |
28 | > Reach out to me at one of the following places!
29 |
30 | - Email :envelope: at `toaashishpatel@gmail.com`
31 |
32 |
33 | ## Author :boy:
34 |
35 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
36 |
37 |
38 | ##### Connect with me
39 |
40 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
41 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
42 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
43 |
44 |
45 | ## Donate :dollar:
46 |
47 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
48 | | PayPal | BMC | Patreon |
49 | | ------------- | ------------- | ------------- |
50 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
51 |
52 |
53 | ## License :lock:
54 |
55 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
56 |
--------------------------------------------------------------------------------
/libraries/Serilog/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/libraries/Serilog/README.md:
--------------------------------------------------------------------------------
1 | # Serilog in .NET
2 |
3 | > Demo: Example project that consume and demonstrate Serilog functionality and integration in ASP.NET/.NET Core.
4 |
5 | ## Work in progress
6 |
7 |
8 | Please refer to below article of my publication [.NET Hub](https://medium.com/dotnet-hub):
9 |
10 | - [Use Serilog in ASP.NET or ASP.NET Core](https://medium.com/dotnet-hub)
11 |
12 |
13 |
14 |
15 | ---
16 |
17 |
18 |
19 |
20 |
21 | ## Give a Star! :star:
22 |
23 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
24 |
25 |
26 | ## Support :telephone:
27 |
28 | > Reach out to me at one of the following places!
29 |
30 | - Email :envelope: at `toaashishpatel@gmail.com`
31 |
32 |
33 | ## Author :boy:
34 |
35 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
36 |
37 |
38 | ##### Connect with me
39 |
40 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
41 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
42 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
43 |
44 |
45 | ## Donate :dollar:
46 |
47 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
48 | | PayPal | BMC | Patreon |
49 | | ------------- | ------------- | ------------- |
50 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
51 |
52 |
53 | ## License :lock:
54 |
55 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
56 |
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.Extensions.Logging;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 |
8 | namespace SerilogExamples.Api.Controllers
9 | {
10 | [ApiController]
11 | [Route("[controller]")]
12 | public class WeatherForecastController : ControllerBase
13 | {
14 | private static readonly string[] Summaries = new[]
15 | {
16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
17 | };
18 |
19 | private readonly ILogger _logger;
20 |
21 | public WeatherForecastController(ILogger logger)
22 | {
23 | _logger = logger;
24 | }
25 |
26 | [HttpGet]
27 | public IEnumerable Get()
28 | {
29 | var rng = new Random();
30 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
31 | {
32 | Date = DateTime.Now.AddDays(index),
33 | TemperatureC = rng.Next(-20, 55),
34 | Summary = Summaries[rng.Next(Summaries.Length)]
35 | })
36 | .ToArray();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["SerilogExamples.Api/SerilogExamples.Api.csproj", "SerilogExamples.Api/"]
11 | RUN dotnet restore "SerilogExamples.Api/SerilogExamples.Api.csproj"
12 | COPY . .
13 | WORKDIR "/src/SerilogExamples.Api"
14 | RUN dotnet build "SerilogExamples.Api.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "SerilogExamples.Api.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "SerilogExamples.Api.dll"]
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.Hosting;
4 | using Microsoft.Extensions.Logging;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 |
10 | namespace SerilogExamples.Api
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | CreateHostBuilder(args).Build().Run();
17 | }
18 |
19 | public static IHostBuilder CreateHostBuilder(string[] args) =>
20 | Host.CreateDefaultBuilder(args)
21 | .ConfigureWebHostDefaults(webBuilder =>
22 | {
23 | webBuilder.UseStartup();
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:23733",
7 | "sslPort": 44334
8 | }
9 | },
10 | "$schema": "http://json.schemastore.org/launchsettings.json",
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "SerilogExamples.Api": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | },
27 | "dotnetRunMessages": "true",
28 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
29 | },
30 | "Docker": {
31 | "commandName": "Docker",
32 | "launchBrowser": true,
33 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
34 | "publishAllPorts": true,
35 | "useSSL": true
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/SerilogExamples.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | 42a74440-988c-495f-83da-c3979594cf7c
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.AspNetCore.HttpsPolicy;
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.Extensions.Logging;
9 | using Microsoft.OpenApi.Models;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.Linq;
13 | using System.Threading.Tasks;
14 |
15 | namespace SerilogExamples.Api
16 | {
17 | public class Startup
18 | {
19 | public Startup(IConfiguration configuration)
20 | {
21 | Configuration = configuration;
22 | }
23 |
24 | public IConfiguration Configuration { get; }
25 |
26 | // This method gets called by the runtime. Use this method to add services to the container.
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 |
30 | services.AddControllers();
31 | services.AddSwaggerGen(c =>
32 | {
33 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "SerilogExamples.Api", Version = "v1" });
34 | });
35 | }
36 |
37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
38 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
39 | {
40 | if (env.IsDevelopment())
41 | {
42 | app.UseDeveloperExceptionPage();
43 | app.UseSwagger();
44 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "SerilogExamples.Api v1"));
45 | }
46 |
47 | app.UseHttpsRedirection();
48 |
49 | app.UseRouting();
50 |
51 | app.UseAuthorization();
52 |
53 | app.UseEndpoints(endpoints =>
54 | {
55 | endpoints.MapControllers();
56 | });
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SerilogExamples.Api
4 | {
5 | public class WeatherForecast
6 | {
7 | public DateTime Date { get; set; }
8 |
9 | public int TemperatureC { get; set; }
10 |
11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12 |
13 | public string Summary { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.Api/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/Serilog/SerilogExamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{567DB155-A6ED-4C75-B883-2154A9A8C402}"
7 | ProjectSection(SolutionItems) = preProject
8 | README.md = README.md
9 | EndProjectSection
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SerilogExamples.Api", "SerilogExamples.Api\SerilogExamples.Api.csproj", "{2372D950-7A98-4599-BC9A-37CE4DD3EE59}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {2372D950-7A98-4599-BC9A-37CE4DD3EE59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {2372D950-7A98-4599-BC9A-37CE4DD3EE59}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {2372D950-7A98-4599-BC9A-37CE4DD3EE59}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {2372D950-7A98-4599-BC9A-37CE4DD3EE59}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {B3BFB95D-50AE-478F-84BB-5D81094871CD}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/libraries/Swagger/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/libraries/Swagger/README.md:
--------------------------------------------------------------------------------
1 | # Swagger (Swashbuckle) — OpenAPI in .NET
2 |
3 | > Demo: Example project that consume and demonstrate Swagger (Swashbuckle) functionality and integration in ASP.NET/.NET Core.
4 |
5 | ## Work in progress
6 |
7 |
8 | Please refer to below article of my publication [.NET Hub](https://medium.com/dotnet-hub):
9 |
10 | - [Use Swagger (Swashbuckle) — OpenAPI in ASP.NET or ASP.NET Core](https://medium.com/dotnet-hub)
11 |
12 |
13 |
14 |
15 | ---
16 |
17 |
18 |
19 |
20 |
21 | ## Give a Star! :star:
22 |
23 | Feel free to request an issue on github if you find bugs or request a new feature. Your valuable feedback is much appreciated to better improve this project. If you find this useful, please give it a star to show your support for this project.
24 |
25 |
26 | ## Support :telephone:
27 |
28 | > Reach out to me at one of the following places!
29 |
30 | - Email :envelope: at `toaashishpatel@gmail.com`
31 |
32 |
33 | ## Author :boy:
34 |
35 | * **Ashish Patel** - [A-Patel](https://github.com/a-patel)
36 |
37 |
38 | ##### Connect with me
39 |
40 | | Linkedin | Portfolio | Medium | GitHub | NuGet | Microsoft | Twitter | Facebook | Instagram |
41 | |----------|----------|----------|----------|----------|----------|----------|----------|----------|
42 | | [](https://www.linkedin.com/in/iamaashishpatel) | [](https://aashishpatel.netlify.app/) | [](https://iamaashishpatel.medium.com) | [](https://github.com/a-patel) | [](https://nuget.org/profiles/iamaashishpatel) | [](https://docs.microsoft.com/en-us/users/iamaashishpatel) | [](https://twitter.com/aashish_mrcool) | [](https://www.facebook.com/aashish.mrcool) | [](https://www.instagram.com/iamaashishpatel/) |
43 |
44 |
45 | ## Donate :dollar:
46 |
47 | If you find this project useful — or just feeling generous, consider buying me a beer or a coffee. Cheers! :beers: :coffee:
48 | | PayPal | BMC | Patreon |
49 | | ------------- | ------------- | ------------- |
50 | | [](https://www.paypal.me/iamaashishpatel) | [](https://www.buymeacoffee.com/iamaashishpatel) | [](https://www.patreon.com/iamaashishpatel) |
51 |
52 |
53 | ## License :lock:
54 |
55 | This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
56 |
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/Controllers/WeatherForecastController.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Mvc;
2 | using Microsoft.Extensions.Logging;
3 | using System;
4 | using System.Collections.Generic;
5 | using System.Linq;
6 | using System.Threading.Tasks;
7 |
8 | namespace SwaggerExamples.Api.Controllers
9 | {
10 | [ApiController]
11 | [Route("[controller]")]
12 | public class WeatherForecastController : ControllerBase
13 | {
14 | private static readonly string[] Summaries = new[]
15 | {
16 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
17 | };
18 |
19 | private readonly ILogger _logger;
20 |
21 | public WeatherForecastController(ILogger logger)
22 | {
23 | _logger = logger;
24 | }
25 |
26 | [HttpGet]
27 | public IEnumerable Get()
28 | {
29 | var rng = new Random();
30 | return Enumerable.Range(1, 5).Select(index => new WeatherForecast
31 | {
32 | Date = DateTime.Now.AddDays(index),
33 | TemperatureC = rng.Next(-20, 55),
34 | Summary = Summaries[rng.Next(Summaries.Length)]
35 | })
36 | .ToArray();
37 | }
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["SwaggerExamples.Api/SwaggerExamples.Api.csproj", "SwaggerExamples.Api/"]
11 | RUN dotnet restore "SwaggerExamples.Api/SwaggerExamples.Api.csproj"
12 | COPY . .
13 | WORKDIR "/src/SwaggerExamples.Api"
14 | RUN dotnet build "SwaggerExamples.Api.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "SwaggerExamples.Api.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "SwaggerExamples.Api.dll"]
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/Program.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Hosting;
2 | using Microsoft.Extensions.Configuration;
3 | using Microsoft.Extensions.Hosting;
4 | using Microsoft.Extensions.Logging;
5 | using System;
6 | using System.Collections.Generic;
7 | using System.Linq;
8 | using System.Threading.Tasks;
9 |
10 | namespace SwaggerExamples.Api
11 | {
12 | public class Program
13 | {
14 | public static void Main(string[] args)
15 | {
16 | CreateHostBuilder(args).Build().Run();
17 | }
18 |
19 | public static IHostBuilder CreateHostBuilder(string[] args) =>
20 | Host.CreateDefaultBuilder(args)
21 | .ConfigureWebHostDefaults(webBuilder =>
22 | {
23 | webBuilder.UseStartup();
24 | });
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:54250",
7 | "sslPort": 44381
8 | }
9 | },
10 | "$schema": "http://json.schemastore.org/launchsettings.json",
11 | "profiles": {
12 | "IIS Express": {
13 | "commandName": "IISExpress",
14 | "launchBrowser": true,
15 | "launchUrl": "swagger",
16 | "environmentVariables": {
17 | "ASPNETCORE_ENVIRONMENT": "Development"
18 | }
19 | },
20 | "SwaggerExamples.Api": {
21 | "commandName": "Project",
22 | "launchBrowser": true,
23 | "launchUrl": "swagger",
24 | "environmentVariables": {
25 | "ASPNETCORE_ENVIRONMENT": "Development"
26 | },
27 | "dotnetRunMessages": "true",
28 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
29 | },
30 | "Docker": {
31 | "commandName": "Docker",
32 | "launchBrowser": true,
33 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
34 | "publishAllPorts": true,
35 | "useSSL": true
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/Startup.cs:
--------------------------------------------------------------------------------
1 | using Microsoft.AspNetCore.Builder;
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.AspNetCore.HttpsPolicy;
4 | using Microsoft.AspNetCore.Mvc;
5 | using Microsoft.Extensions.Configuration;
6 | using Microsoft.Extensions.DependencyInjection;
7 | using Microsoft.Extensions.Hosting;
8 | using Microsoft.Extensions.Logging;
9 | using Microsoft.OpenApi.Models;
10 | using System;
11 | using System.Collections.Generic;
12 | using System.Linq;
13 | using System.Threading.Tasks;
14 |
15 | namespace SwaggerExamples.Api
16 | {
17 | public class Startup
18 | {
19 | public Startup(IConfiguration configuration)
20 | {
21 | Configuration = configuration;
22 | }
23 |
24 | public IConfiguration Configuration { get; }
25 |
26 | // This method gets called by the runtime. Use this method to add services to the container.
27 | public void ConfigureServices(IServiceCollection services)
28 | {
29 |
30 | services.AddControllers();
31 | services.AddSwaggerGen(c =>
32 | {
33 | c.SwaggerDoc("v1", new OpenApiInfo { Title = "SwaggerExamples.Api", Version = "v1" });
34 | });
35 | }
36 |
37 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
38 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
39 | {
40 | if (env.IsDevelopment())
41 | {
42 | app.UseDeveloperExceptionPage();
43 | app.UseSwagger();
44 | app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "SwaggerExamples.Api v1"));
45 | }
46 |
47 | app.UseHttpsRedirection();
48 |
49 | app.UseRouting();
50 |
51 | app.UseAuthorization();
52 |
53 | app.UseEndpoints(endpoints =>
54 | {
55 | endpoints.MapControllers();
56 | });
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/SwaggerExamples.Api.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | add551b8-58d2-4c84-a9e1-9198c2b3a32e
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/WeatherForecast.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SwaggerExamples.Api
4 | {
5 | public class WeatherForecast
6 | {
7 | public DateTime Date { get; set; }
8 |
9 | public int TemperatureC { get; set; }
10 |
11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12 |
13 | public string Summary { get; set; }
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.Api/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | },
9 | "AllowedHosts": "*"
10 | }
11 |
--------------------------------------------------------------------------------
/libraries/Swagger/SwaggerExamples.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{624BF0CC-AF32-4219-BA6A-705F605F540E}"
7 | ProjectSection(SolutionItems) = preProject
8 | README.md = README.md
9 | EndProjectSection
10 | EndProject
11 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SwaggerExamples.Api", "SwaggerExamples.Api\SwaggerExamples.Api.csproj", "{1737D3F1-F183-499C-B183-D5056A8990A5}"
12 | EndProject
13 | Global
14 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
15 | Debug|Any CPU = Debug|Any CPU
16 | Release|Any CPU = Release|Any CPU
17 | EndGlobalSection
18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
19 | {1737D3F1-F183-499C-B183-D5056A8990A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20 | {1737D3F1-F183-499C-B183-D5056A8990A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
21 | {1737D3F1-F183-499C-B183-D5056A8990A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
22 | {1737D3F1-F183-499C-B183-D5056A8990A5}.Release|Any CPU.Build.0 = Release|Any CPU
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {27FB20CB-F190-44D6-84B4-9E4A39D7C2CE}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/samples/hosted-services/README.md:
--------------------------------------------------------------------------------
1 |
2 | # .NET Labs: Hosted Services
3 |
4 | > .NET Labs: Hosted Services Examples.
5 |
6 |
7 |
8 | - [.NET Hub](https://medium.com/dotnet-hub)
9 |
10 |
11 |
12 | ---
13 |
14 |
15 |
16 | ## Examples
17 |
18 |
19 |
20 |
21 |
22 | #### [Background Task](background-tasks)
23 |
24 | Implement background tasks using the new IHostedService interface.
25 |
26 |
27 |
28 |
29 |
30 | ---
31 |
32 |
33 |
34 | ### Reference
35 |
36 | - [Background tasks with hosted services in ASP.NET Core](https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services)
37 | - []()
38 | - []()
39 | - []()
40 | - []()
41 |
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/.dockerignore:
--------------------------------------------------------------------------------
1 | **/.classpath
2 | **/.dockerignore
3 | **/.env
4 | **/.git
5 | **/.gitignore
6 | **/.project
7 | **/.settings
8 | **/.toolstarget
9 | **/.vs
10 | **/.vscode
11 | **/*.*proj.user
12 | **/*.dbmdl
13 | **/*.jfm
14 | **/azds.yaml
15 | **/bin
16 | **/charts
17 | **/docker-compose*
18 | **/Dockerfile*
19 | **/node_modules
20 | **/npm-debug.log
21 | **/obj
22 | **/secrets.dev.yaml
23 | **/values.dev.yaml
24 | LICENSE
25 | README.md
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/BackgroundTasksLabs.Web/BackgroundTasksLabs.Web.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net7.0
5 | 062baed7-813b-4a10-8540-9df0f0803f37
6 | Linux
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/BackgroundTasksLabs.Web/Dockerfile:
--------------------------------------------------------------------------------
1 | #See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.
2 |
3 | FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
4 | WORKDIR /app
5 | EXPOSE 80
6 | EXPOSE 443
7 |
8 | FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
9 | WORKDIR /src
10 | COPY ["BackgroundTasksLabs.Web/BackgroundTasksLabs.Web.csproj", "BackgroundTasksLabs.Web/"]
11 | RUN dotnet restore "BackgroundTasksLabs.Web/BackgroundTasksLabs.Web.csproj"
12 | COPY . .
13 | WORKDIR "/src/BackgroundTasksLabs.Web"
14 | RUN dotnet build "BackgroundTasksLabs.Web.csproj" -c Release -o /app/build
15 |
16 | FROM build AS publish
17 | RUN dotnet publish "BackgroundTasksLabs.Web.csproj" -c Release -o /app/publish
18 |
19 | FROM base AS final
20 | WORKDIR /app
21 | COPY --from=publish /app/publish .
22 | ENTRYPOINT ["dotnet", "BackgroundTasksLabs.Web.dll"]
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/BackgroundTasksLabs.Web/Program.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using Microsoft.AspNetCore.Hosting;
3 | using Microsoft.Extensions.DependencyInjection;
4 | using Microsoft.Extensions.Hosting;
5 | #endregion
6 |
7 | namespace BackgroundTasksLabs.Web
8 | {
9 | public class Program
10 | {
11 | public static void Main(string[] args)
12 | {
13 | CreateHostBuilder(args).Build().Run();
14 | }
15 |
16 | public static IHostBuilder CreateHostBuilder(string[] args) =>
17 | Host.CreateDefaultBuilder(args)
18 | .ConfigureWebHostDefaults(webBuilder =>
19 | {
20 | webBuilder.UseStartup();
21 | })
22 | .ConfigureServices((hostContext, services) =>
23 | {
24 | services.AddHostedService();
25 | });
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/BackgroundTasksLabs.Web/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "iisSettings": {
3 | "windowsAuthentication": false,
4 | "anonymousAuthentication": true,
5 | "iisExpress": {
6 | "applicationUrl": "http://localhost:36083",
7 | "sslPort": 44353
8 | }
9 | },
10 | "profiles": {
11 | "IIS Express": {
12 | "commandName": "IISExpress",
13 | "launchBrowser": true,
14 | "environmentVariables": {
15 | "ASPNETCORE_ENVIRONMENT": "Development"
16 | }
17 | },
18 | "BackgroundTasksLabs.Web": {
19 | "commandName": "Project",
20 | "launchBrowser": true,
21 | "environmentVariables": {
22 | "ASPNETCORE_ENVIRONMENT": "Development"
23 | },
24 | "dotnetRunMessages": "true",
25 | "applicationUrl": "https://localhost:5001;http://localhost:5000"
26 | },
27 | "Docker": {
28 | "commandName": "Docker",
29 | "launchBrowser": true,
30 | "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
31 | "publishAllPorts": true,
32 | "useSSL": true
33 | }
34 | }
35 | }
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/BackgroundTasksLabs.Web/Services/Worker.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using Microsoft.Extensions.Hosting;
3 | using Microsoft.Extensions.Logging;
4 | using System;
5 | using System.Threading;
6 | using System.Threading.Tasks;
7 | #endregion
8 |
9 | namespace BackgroundTasksLabs.Web
10 | {
11 | public class Worker : BackgroundService
12 | {
13 | #region Members
14 |
15 | private readonly ILogger _logger;
16 |
17 | #endregion
18 |
19 | #region Ctor
20 |
21 | public Worker(ILogger logger)
22 | {
23 | _logger = logger;
24 | }
25 |
26 | #endregion
27 |
28 | #region Methods
29 |
30 | protected override async Task ExecuteAsync(CancellationToken stoppingToken)
31 | {
32 | await BackgroundProcessing(stoppingToken);
33 | }
34 |
35 | public override async Task StopAsync(CancellationToken stoppingToken)
36 | {
37 | _logger.LogInformation("Worker Hosted Service is stopping.");
38 |
39 | await base.StopAsync(stoppingToken);
40 | }
41 |
42 | #endregion
43 |
44 | #region Utilities
45 |
46 | private async Task BackgroundProcessing(CancellationToken stoppingToken)
47 | {
48 | while (!stoppingToken.IsCancellationRequested)
49 | {
50 | _logger.LogInformation($"Worker running at: {DateTimeOffset.Now}");
51 | await Task.Delay(1000, stoppingToken);
52 | }
53 | }
54 |
55 | #endregion
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/BackgroundTasksLabs.Web/Startup.cs:
--------------------------------------------------------------------------------
1 | #region Imports
2 | using Microsoft.AspNetCore.Builder;
3 | using Microsoft.AspNetCore.Hosting;
4 | using Microsoft.AspNetCore.Http;
5 | using Microsoft.Extensions.DependencyInjection;
6 | using Microsoft.Extensions.Hosting;
7 | #endregion
8 |
9 | namespace BackgroundTasksLabs.Web
10 | {
11 | public class Startup
12 | {
13 | public void ConfigureServices(IServiceCollection services)
14 | {
15 | }
16 |
17 | public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
18 | {
19 | if (env.IsDevelopment())
20 | {
21 | app.UseDeveloperExceptionPage();
22 | }
23 |
24 | app.UseRouting();
25 |
26 | app.UseEndpoints(endpoints =>
27 | {
28 | endpoints.MapGet("/", async context =>
29 | {
30 | await context.Response.WriteAsync("Background Tasks Labs is running!");
31 | });
32 | });
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/BackgroundTasksLabs.Web/appsettings.Development.json:
--------------------------------------------------------------------------------
1 | {
2 | "Logging": {
3 | "LogLevel": {
4 | "Default": "Information",
5 | "Microsoft": "Warning",
6 | "Microsoft.Hosting.Lifetime": "Information"
7 | }
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/BackgroundTasksLabs.Web/appsettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "QueueCapacity": 10,
3 | "Logging": {
4 | "LogLevel": {
5 | "Default": "Information",
6 | "Microsoft": "Warning",
7 | "Microsoft.Hosting.Lifetime": "Information"
8 | }
9 | },
10 | "AllowedHosts": "*"
11 | }
12 |
--------------------------------------------------------------------------------
/samples/hosted-services/background-tasks/hosted-services-background-tasks-labs.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31129.286
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BackgroundTasksLabs.Web", "BackgroundTasksLabs.Web\BackgroundTasksLabs.Web.csproj", "{7A57CF86-C46E-44E6-B295-D980BB10594B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {7A57CF86-C46E-44E6-B295-D980BB10594B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {7A57CF86-C46E-44E6-B295-D980BB10594B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {7A57CF86-C46E-44E6-B295-D980BB10594B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {7A57CF86-C46E-44E6-B295-D980BB10594B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {724E7BF3-5459-4439-B777-D54B61C47B0C}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/samples/swagger-openapi/README.md:
--------------------------------------------------------------------------------
1 |
2 | # .NET Labs: Swagger/OpenAPI
3 |
4 | > .NET Labs: Swagger/OpenAPI Examples.
5 |
6 |
7 |
8 |
9 |
10 | ---
11 |
12 |
13 |
14 | ## Examples
15 |
16 |
17 |
18 |
19 |
20 | #### [Feature-1](feature-1)
21 |
22 | Feature-1 description.
23 |
24 |
25 |
26 |
27 |
28 | ---
29 |
30 |
31 |
32 | ### Reference
33 |
34 | - []()
35 | - []()
36 | - []()
37 | - []()
38 | - []()
39 |
--------------------------------------------------------------------------------
/samples/zzzzz/README.md:
--------------------------------------------------------------------------------
1 |
2 | # .NET Labs: ZZZZZ
3 |
4 | > .NET Labs: ZZZZZ Examples.
5 |
6 |
7 |
8 |
9 |
10 | ---
11 |
12 |
13 |
14 | ## Examples
15 |
16 |
17 |
18 |
19 |
20 | #### [Feature-1](feature-1)
21 |
22 | Feature-1 description.
23 |
24 |
25 |
26 |
27 |
28 | ---
29 |
30 |
31 |
32 | ### Reference
33 |
34 | - []()
35 | - []()
36 | - []()
37 | - []()
38 | - []()
39 |
--------------------------------------------------------------------------------