{"id":21405515,"url":"https://github.com/sagifogel/ncop","last_synced_at":"2025-07-13T23:30:42.777Z","repository":{"id":4955570,"uuid":"6112980","full_name":"sagifogel/NCop","owner":"sagifogel","description":"Composite-aspect oriented framework for .NET","archived":false,"fork":false,"pushed_at":"2022-06-14T18:28:15.000Z","size":3730,"stargazers_count":29,"open_issues_count":0,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-07-06T15:06:20.796Z","etag":null,"topics":["aop","aspect","aspect-oriented-framework","aspect-oriented-programming","composite","csharp","mixins"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"DataTables/Plugins","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sagifogel.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}},"created_at":"2012-10-07T14:29:08.000Z","updated_at":"2024-07-27T09:35:35.000Z","dependencies_parsed_at":"2022-09-16T22:50:13.412Z","dependency_job_id":null,"html_url":"https://github.com/sagifogel/NCop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sagifogel/NCop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagifogel%2FNCop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagifogel%2FNCop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagifogel%2FNCop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagifogel%2FNCop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sagifogel","download_url":"https://codeload.github.com/sagifogel/NCop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sagifogel%2FNCop/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265220092,"owners_count":23729759,"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":["aop","aspect","aspect-oriented-framework","aspect-oriented-programming","composite","csharp","mixins"],"created_at":"2024-11-22T16:26:16.861Z","updated_at":"2025-07-13T23:30:42.157Z","avatar_url":"https://github.com/sagifogel.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"\nNCop\n===================\nWhat is **NCop**?\n\n**NCop** is a framework that implements Composite/Aspect Oriented Programming that encapsulates the concepts of [Mixins](https://github.com/sagifogel/NCop/blob/master/README.md#mixins), [Aspects](https://github.com/sagifogel/NCop/blob/master/README.md#aspects) and [Dependency Injection](https://github.com/sagifogel/NCop/blob/master/README.md#dependency-injection), using the standard .NET.\u003cbr/\u003e\nThe main purpose of composites is separation of concerns. You  achieve it by defining different roles within different entities and combine all of them using **NCop** (much like multiple inheritance).\n\n### Installing\n\n```\nInstall-Package NCop\n```\n\nPlease visit the [Wiki](https://github.com/sagifogel/NCop/wiki) page for explanations and demos.\n------------\n\n\u003ca name=\"mixins\"\u003e\u003c/a\u003e\n### Mixins\n\nA mixin is an interface with implemented methods.\u003cbr/\u003e\nMixins exists in .NET in the form of object oriented interfaces implementation.\n\n```csharp\npublic interface IDeveloper\n{\n    void Code();\n}\n```\n\n```csharp\npublic class CSharpDeveloperMixin : IDeveloper\n{\n    public void Code() {\n        Console.WriteLine(\"C# coding\");\n    }\n}\n```\n\n### Composites\n\nComposites are the artifacts of **NCop** processing. A composite is a combination of Mixins and Aspects.\u003cbr/\u003e\nIn order to create a composite type you need to annotate one of the interfaces with a `CompositeAttribute`\u003cbr/\u003e\nand also to tell **NCop** to match between interface and implementation by annotating the composite type with a `MixinsAttribute`.\n\n```csharp\n[TransientComposite]\n[Mixins(typeof(CSharpDeveloperMixin))]\npublic interface IDeveloper\n{\n    void Code();\n}\n```\n\n\u003ca name=\"aspects\"\u003e\u003c/a\u003e\n### Aspects\n\nAspects aims to increase modularity by allowing the separation of cross-cutting concerns.\u003cbr/\u003e\nIn order to create an aspect you should first create an aspect class that will hold your desired join points.\n\n```csharp\npublic class StopwatchActionInterceptionAspect : ActionInterceptionAspect\n{\n    private readonly Stopwatch stopwatch = null;\n\n    public StopwatchActionInterceptionAspect() {\n        stopwatch = new Stopwatch();\n    }\n\n    public override void OnInvoke(ActionInterceptionArgs args) {\n        stopwatch.Restart();\n        args.Proceed();\n        stopwatch.Stop();\n        Console.WriteLine(\"Elapsed Ticks: {0}\", stopwatch.ElapsedTicks);\n    }\n}\n```\n\n\nThe second thing that you will need to do is to annotate the method which you want to apply the aspect on.\u003cbr/\u003e\n\n```csharp\n[TransientComposite]\n[Mixins(typeof(CSharpDeveloperMixin))]\npublic interface IDeveloper\n{\n    [MethodInterceptionAspect(typeof(StopwatchActionInterceptionAspect))]\n    void Code();\n}\n```\n\n\u003ca name=\"dependency-injection\"\u003e\u003c/a\u003e\n### Dependency Injection\n\n**NCop** IoC is based on \u003ca href=\"http://funq.codeplex.com/\" target=\"_blank\"\u003eFunq\u003c/a\u003e - which was adopted because of its excellent performance and memory characteristics.\u003cbr/\u003e\nIn order to resolve an artifact of **NCop** you need to create a composite IoC Container, \u003cbr/\u003e\nand call the `Resolve` function. \u003cbr/\u003e\n\n```csharp\nstatic void Main(string[] args) {\n    IDeveloper developer = null;\n    var container = new CompositeContainer();\n\n    container.Configure();\n    developer = container.Resolve\u003cIDeveloper\u003e();\n    developer.Code();\n}\n```\n\nThe expected output should be:\n```\n\"C# coding\"\n\"Elapsed Ticks: [Number of ticks]\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagifogel%2Fncop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsagifogel%2Fncop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsagifogel%2Fncop/lists"}