Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ignatandrei/RSCG_Decorator
Decorator for classes , permit to know when method start and ends
https://github.com/ignatandrei/RSCG_Decorator
Last synced: 2 days ago
JSON representation
Decorator for classes , permit to know when method start and ends
- Host: GitHub
- URL: https://github.com/ignatandrei/RSCG_Decorator
- Owner: ignatandrei
- License: mit
- Created: 2023-09-30T17:03:30.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-01-06T22:30:44.000Z (10 months ago)
- Last Synced: 2024-11-02T04:38:33.553Z (9 days ago)
- Language: C#
- Size: 19.5 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- RSCG_Examples - https://github.com/ignatandrei/RSCG_Decorator
README
# RSCG_Decorator
Decorator for classes , permit to know when method start and ends## Usage
Add reference to RSCG_Decorator and RSCG_DecoratorCommon
```xml
true
$(BaseIntermediateOutputPath)\GX
```For any class that you want to intercept methods, implement interface IDecoratorMethodV1
See example at the RSCG_DecoratorTestConsole
```csharp
public partial class Person : IDecoratorMethodV1
{
public void EndMethod(MethodRecognizer recognizer)
{
logger.LogInformation("end "+recognizer.UniqueId);
}
public void ExceptionMethod(Exception ex, MethodRecognizer recognizer)
{
logger.LogError(ex, "exception on " + recognizer.UniqueId+ " Value Parameters:" + recognizer.ValueTypeParametersString);
}public void StartMethod(MethodRecognizer recognizer)
{
logger.LogInformation("start " + recognizer.UniqueId + " Value Parameters:"+recognizer.ValueTypeParametersString);
}
}
```## Usage with ASP.NET Core - or any DI framework
Let's take Person with interface IPerson. You have the following:
```csharp
serviceCollection
.AddTransient();```
You can add this as the latest```csharp
serviceCollection = serviceCollection
.AddTransient()
.AddTransient();
```And when asking for IPerson , the last wins:
```csharp
var data = serviceProvider.GetRequiredService();
//obtaining Person_Decorator because is the last one```
# More Roslyn Source Code GeneratorsYou can find more RSCG with examples at [Roslyn Source Code Generators](https://ignatandrei.github.io/RSCG_Examples/v2/)