{"id":13629325,"url":"https://github.com/ignatandrei/RSCG_Decorator","last_synced_at":"2025-04-17T08:34:38.814Z","repository":{"id":197452894,"uuid":"698690864","full_name":"ignatandrei/RSCG_Decorator","owner":"ignatandrei","description":"Decorator for classes , permit to know when method start and ends","archived":false,"fork":false,"pushed_at":"2024-01-06T22:30:44.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-04T23:41:49.646Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ignatandrei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-09-30T17:03:30.000Z","updated_at":"2024-01-12T09:22:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"838d7552-9d37-45b3-a588-69d80ea8c0af","html_url":"https://github.com/ignatandrei/RSCG_Decorator","commit_stats":null,"previous_names":["ignatandrei/rscg_decorator"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FRSCG_Decorator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FRSCG_Decorator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FRSCG_Decorator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ignatandrei%2FRSCG_Decorator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ignatandrei","download_url":"https://codeload.github.com/ignatandrei/RSCG_Decorator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249326186,"owners_count":21251735,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:01:07.523Z","updated_at":"2025-04-17T08:34:38.570Z","avatar_url":"https://github.com/ignatandrei.png","language":"C#","funding_links":[],"categories":["Content"],"sub_categories":["62. [RSCG_Decorator](https://ignatandrei.github.io/RSCG_Examples/v2/docs/RSCG_Decorator) , in the [EnhancementClass](https://ignatandrei.github.io/RSCG_Examples/v2/docs/rscg-examples#enhancementclass) category"],"readme":"# RSCG_Decorator\nDecorator for classes , permit to know when method start and ends\n\n\n## Usage\n\nAdd reference to RSCG_Decorator and RSCG_DecoratorCommon\n\n```xml\n\u003cItemGroup\u003e\n\t\n\t  \u003cPackageReference Include=\"RSCG_Decorator\" Version=\"7.2023.930.2116\" OutputItemType=\"Analyzer\" ReferenceOutputAssembly=\"false\"  /\u003e\n\t  \u003cPackageReference Include=\"RSCG_DecoratorCommon\" Version=\"7.2023.930.2116\" /\u003e\n\u003c/ItemGroup\u003e\n\u003cPropertyGroup\u003e\n\t\u003cEmitCompilerGeneratedFiles\u003etrue\u003c/EmitCompilerGeneratedFiles\u003e\n\t\u003cCompilerGeneratedFilesOutputPath\u003e$(BaseIntermediateOutputPath)\\GX\u003c/CompilerGeneratedFilesOutputPath\u003e\n\u003c/PropertyGroup\u003e\n\t\n```\n\nFor any class that you want to intercept methods, implement interface IDecoratorMethodV1\n\nSee example at the RSCG_DecoratorTestConsole\n\n```csharp\npublic partial class Person : IDecoratorMethodV1\n{\n    public void EndMethod(MethodRecognizer recognizer)\n    {\n        logger.LogInformation(\"end \"+recognizer.UniqueId);\n    }\n\n   \n    public void ExceptionMethod(Exception ex, MethodRecognizer recognizer)\n    {\n        logger.LogError(ex, \"exception on \" + recognizer.UniqueId+ \" Value Parameters:\" + recognizer.ValueTypeParametersString); \n    }\n\n\n    public void StartMethod(MethodRecognizer recognizer)\n    {\n        logger.LogInformation(\"start \" + recognizer.UniqueId + \" Value Parameters:\"+recognizer.ValueTypeParametersString);\n   }\n}\n```\n\n## Usage with ASP.NET Core - or any DI framework\n\nLet's take Person with interface IPerson. You have the following:\n\n```csharp\nserviceCollection \n          .AddTransient\u003cIPerson, Person\u003e();\n\n```\nYou can add this as the latest\n\n```csharp\nserviceCollection = serviceCollection\n     .AddTransient\u003cPerson, Person\u003e()\n     .AddTransient\u003cIPerson, Person_Decorator\u003e();\n     \n```\n\nAnd when asking for IPerson , the last wins:\n\n```csharp\n\nvar data = serviceProvider.GetRequiredService\u003cIPerson\u003e();\n//obtaining Person_Decorator because is the last one\n\n```\n# More Roslyn Source Code Generators\n\nYou can find more RSCG with examples at [Roslyn Source Code Generators](https://ignatandrei.github.io/RSCG_Examples/v2/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignatandrei%2FRSCG_Decorator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fignatandrei%2FRSCG_Decorator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fignatandrei%2FRSCG_Decorator/lists"}