Skip to content

Commit 579b6b3

Browse files
committed
Added documentation for Web package
1 parent 09332b8 commit 579b6b3

10 files changed

Lines changed: 87 additions & 3 deletions

File tree

docs/articles/available-packages.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,12 +226,12 @@ Taking advantage of the Data Validation library, you can simply and easily setup
226226

227227
## Web
228228

229-
The Web library contains a collection of helpers and extensions that sit on top of ASP.NET Core, to provide useful components to compliment your web applications.
229+
The Web library contains a collection of helpers and extensions that sit on top of ASP.NET Core, to provide useful components to complement your web applications.
230230

231231
This includes features such as:
232232

233233
- PaginatedRequest, a simple request object that provides the expected return type, with properties for the current `Page`, the `PageSize`, and the number of items to `Skip` and `Take`.
234-
- PaginatedResponse, a complimentary response return type for the `PaginatedRequest`, with properties including the `Items` collection, the current `Page` and `PageSize`, plus the `AvailableCount` of requestable items, and the `TotalPages` based on the available count and page size requested.
234+
- PaginatedResponse, a complementary response return type for the `PaginatedRequest`, with properties including the `Items` collection, the current `Page` and `PageSize`, plus the `AvailableCount` of requestable items, and the `TotalPages` based on the available count and page size requested.
235235
- HttpContextExceptionsMiddleware, a middleware that manages the handling of exceptions thrown within a `HttpContext` to serve up meaningful exception details to the requesting client using exception handlers.
236236

237237
<span class="button">
@@ -242,7 +242,7 @@ This includes features such as:
242242

243243
## Web.Mvc
244244

245-
The Web MVC library is a complimentary extension package to ASP.NET Core MVC applications, providing additional helpers for building applications following the MVC pattern.
245+
The Web MVC library is a complementary extension package to ASP.NET Core MVC applications, providing additional helpers for building applications following the MVC pattern.
246246

247247
Included in this package is:
248248

docs/articles/features/collections.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Using the Collections package | MADE.NET
55

66
# Using the Collections package
77

8+
The Collections package is designed to provide helpful extensions and additional types for working with enumerable objects in your applications.
9+
810
## Comparing objects using the GenericEqualityComparer
911

1012
The `MADE.Collections.Compare.GenericEqualityComparer` is a simple to use `IEqualityComparer` that takes a function as a parameter when constructed.

docs/articles/features/data-converters.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Using the Data Converters package | MADE.NET
55

66
# Using the Data Converters package
77

8+
The Data Converters package provides a collection of value converters and extensions to manipulate data in your applications.
9+
810
## Converting a DateTime to a String using the DateTimeToStringValueConverter
911

1012
Value converters are a common coding practice for building XAML applications that allow values to be bound to a view, converted to a different type and back depending on the binding mode.

docs/articles/features/data-validation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Using the Data Validation package | MADE.NET
55

66
# Using the Data Validation package
77

8+
The Data Validation package is designed to provide out-of-the-box data validation to applications built with C#.
9+
810
## Validating an object using the ValidatorCollection
911

1012
Data validation can be implemented in so many different ways. MADE provides the capability to perform data validation through it's own `IValidator` interface which can be used to create consistent data validators.

docs/articles/features/diagnostics.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Using the Diagnostics package | MADE.NET
55

66
# Using the Diagnostics package
77

8+
The Diagnostic package contains a set of simple application logging mechanisms for applications.
9+
810
## Logging events to files on disk with FileEventLogger
911

1012
Using the `MADE.Diagnostics.Logging.FileEventLogger`, you can quickly and easily get up and running with event logging for your application's diagnostic needs.

docs/articles/features/media-image.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Using the Media Image package | MADE.NET
55

66
# Using the Media Image package
77

8+
The Media Image package is designed to be used in applications that require image processing.
9+
810
## Loading Windows StorageFile thumbnails into an Image with LoadStorageFileThumbnailImageBehavior
911

1012
The `MADE.Media.Image.Behaviors.LoadStorageFileThumbnailImageBehavior` is a custom behavior built on the [Microsoft XAML behaviors SDK](https://github.com/Microsoft/XamlBehaviors).

docs/articles/features/networking.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Using the Networking package | MADE.NET
55

66
# Using the Networking package
77

8+
The Networking package contains a collection of helpers for applications that use `HttpClient` for making network requests to APIs.
9+
810
## Making simple network requests using NetworkRequest instances
911

1012
The Network package comes with a variety of `NetworkRequest` types that can be used to perform network requests without a lot of additional overhead.

docs/articles/features/runtime.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Using the Runtime package | MADE.NET
55

66
# Using the Runtime package
77

8+
The Runtime package provides additional types for .NET to provide extensibility over existing `System` types.
9+
810
## Improving callback memory management with WeakReferenceCallback
911

1012
The `MADE.Runtime.WeakReferenceCallback` is a wrapper type for a `WeakReference`. It is capable of taking a delegate action and ensuring that it is available to be garbage collected if the referring object is disposed.

docs/articles/features/threading.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ title: Using the Threading package | MADE.NET
55

66
# Using the Threading package
77

8+
The Threading package contains a collection of `System.Threading` extensions and helpers to improve the developer experience.
9+
810
## Modernizing System.Threading.Timer with the MADE.Threading.Timer
911

1012
Setting up and managing a `System.Threading.Timer` can sometimes be cumbersome. How do you control the start and stop state?

docs/articles/features/web.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,71 @@ title: Using the Web package | MADE.NET
55

66
# Using the Web package
77

8+
The Web library contains a collection of helpers and extensions that sit on top of ASP.NET Core, to provide useful components to complement your web applications.
9+
10+
## Improved HttpContext exception handling with HttpContextExceptionsMiddleware
11+
12+
The Web package contains a `MADE.Web.Exceptions.HttpContextExceptionsMiddleware` which can be used with your ASP.NET Core application to manage how exceptions are handled and errors are returned using JSON responses.
13+
14+
Using the `UseHttpContextExceptionHandling` extension method on your `IApplicationBuilder` instance in the `Startup` of your web application, you can start taking advantage of improved error handling with MADE.
15+
16+
Under the hood, exceptions are handled using `IHttpContextExceptionHandler` types which are registered with your application's `IServiceCollection`.
17+
18+
The implementation has a basic catch-all `Exception` handler which returns an internal server error (500) when an unhandled exception is thrown. This can be registered alongside your own exception handlers in your `Startup` class.
19+
20+
### Registering the HttpContextExceptionsMiddleware and handlers
21+
22+
Below is an example of configuring the exception handling middleware and exception handlers in your application's `Startup` class.
23+
24+
```csharp
25+
// Startup.cs
26+
27+
public void Configure( IApplicationBuilder app )
28+
{
29+
// Registers the middleware for exception handling
30+
app.
31+
UseHttpContextExceptionHandling();
32+
}
33+
34+
public void ConfigureServices( IServiceCollection services )
35+
{
36+
// Registers the default exception handler.
37+
services.AddHttpContextExceptionHandler<Exception, DefaultExceptionHandler>
38+
39+
services.AddHttpContextExceptionHandler<MyCustomException, MyCustomExceptionHandler>
40+
}
41+
```
42+
43+
And this is an example of a custom exception handler.
44+
45+
```csharp
46+
namespace MyApp.Exceptions
47+
{
48+
using System;
49+
using System.Net;
50+
using System.Threading.Tasks;
51+
using MADE.Web.Exceptions;
52+
using MADE.Web.Extensions;
53+
using Microsoft.AspNetCore.Http;
54+
55+
public class MyCustomExceptionHandler : IHttpContextExceptionHandler<MyCustomException>
56+
{
57+
public async Task HandleAsync(HttpContext context, MyCustomException exception)
58+
{
59+
var response = new ExceptionResponse<MyCustomException>("MyCustomExceptionError", "An error occurred causing my custom exception to be thrown.", exception);
60+
61+
await context.Response.WriteJsonAsync(HttpStatusCode.InternalServerError, response);
62+
}
63+
}
64+
}
65+
```
66+
67+
## Improving pagination support with PaginatedRequest and PaginatedResponse
68+
69+
Pagination is a common concept for web requests to help improve performance of UIs and reduce network traffic by querying a subset of data.
70+
71+
The `PaginatedRequest` and `PaginatedResponse` can be used together to help you achieve these performance improvements in your own web applications.
72+
73+
The `PaginatedRequest` takes a page and page size parameter when constructed, and it automatically provides you with the `Skip` and `Take` properties that you can provide to your data queries.
74+
75+
When you have your data from your request, you can construct a response using the `PaginatedResponse` which takes the data, the original page and page size parameters, and the number of available items. It will also provide the `TotalPages` that are available to allow a UI to generate a pagination user experience.

0 commit comments

Comments
 (0)