Skip to content

Samples of decorators to add functionality to existing interface implementations

Notifications You must be signed in to change notification settings

jeremybytes/di-decorators

Repository files navigation

di-decorators

Sample C# code to show how decorators can add functionality to existing interface implementations, including caching, retry, and exception logging. Decorators can also be "stacked" to run multiple functions with a single call to an interface member.

About the Code

This application is C# with a combination of .NET Framework 4.7, .NET Standard 2.0, and ASP.NET MVC Core 2.1. It was built with Visual Studio 2017. Since this uses .NET Framework, it is Windows only (this is a desktop application using WPF for the UI).

Running the Application

The application uses a web service with is included as one of the projects. The easiest way to run the application is to start the service in a separate command window and run/debug the application from Visual Studio.

To run the service:

  1. Open a command-prompt (cmd or PowerShell)
  2. Navigate to {source root}\People.Service\
  3. Type "dotnet run"

The service is self-hosted and runs at http://localhost:9874/api/people

In Visual Studio, start the application (with or without debugging). With the service running, the desktop application should be able to retrieve data. See the first article (listed below) for more information on running the application, including screenshots.

Articles

The following articles give an overview of the project and a detailed look at the decorators included.

WPF and .NET Core 3.0

See the "core30" branch for code converting WPF to .NET Core 3.0 (Preview).

About

Samples of decorators to add functionality to existing interface implementations

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages