{"id":20790555,"url":"https://github.com/chsword/expressaop","last_synced_at":"2026-04-30T19:31:17.211Z","repository":{"id":19632439,"uuid":"22884451","full_name":"chsword/expressaop","owner":"chsword","description":null,"archived":false,"fork":false,"pushed_at":"2017-04-23T06:05:01.000Z","size":23,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-11T07:50:03.205Z","etag":null,"topics":["aop","aop-aspects","c-sharp","dotnet","filter"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chsword.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-12T16:30:55.000Z","updated_at":"2019-08-01T06:03:42.000Z","dependencies_parsed_at":"2022-08-21T13:40:28.661Z","dependency_job_id":null,"html_url":"https://github.com/chsword/expressaop","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/chsword/expressaop","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chsword%2Fexpressaop","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chsword%2Fexpressaop/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chsword%2Fexpressaop/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chsword%2Fexpressaop/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chsword","download_url":"https://codeload.github.com/chsword/expressaop/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chsword%2Fexpressaop/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32475191,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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","aop-aspects","c-sharp","dotnet","filter"],"created_at":"2024-11-17T15:35:51.077Z","updated_at":"2026-04-30T19:31:17.196Z","avatar_url":"https://github.com/chsword.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Express AOP\n[![install from nuget](http://img.shields.io/nuget/v/expressaop.svg?style=flat-square)](https://www.nuget.org/packages/expressaop)\n[![Build status](https://ci.appveyor.com/api/projects/status/3665h8dcncl6nlhv?svg=true)](https://ci.appveyor.com/project/chsword/expressaop)\n\n### NuGet Install\n``` powershell\nPM\u003e Install-Package ExpressAOP\n```\n\n###　Test case\nYou can define a fillter like this:\n```c#\n    public class MyFilter : AOPFilterAttribute\n    {\n        private readonly string _key;\n        public MyFilter(String key)\n        {\n            _key = key;\n        }\n        protected override void Executing(IProcesser processer)\n        {\n            Setting.List.Add(\"Executing-\" + _key);\n        }\n        protected override void Executed(IProcesser processer)\n        {\n            Setting.List.Add(\"Executed-\" + _key);\n        }\n    }\n```\neg: You have a class like following:\n```c#\n    class MyClass {\n        public void Foo1()\n        {\n        }\n    }\n```\nAnd you want the filter is working on the Method.\nYou have 2 methods to use the filter;\n### 1.Use the ContextBoundObject baseclass\n```c#\n    [AOPProxy]// Use the AOP\n    class MyModel2 : ContextBoundObject// baseclass\n    {\n        [MyFilter(\":filter\")]//AFilter\n        public void Foo1()\n        {\n            Setting.List.Add(\"method\");\n        }\n    }\n```\nI write a test case for this way:\n```c#\n        [TestMethod]\n        public void ClassContextBoundObject()\n        {\n            var o = new MyModel2();\n            o.Foo1();\n            Assert.AreEqual(new[]\n                                {\n                                    \"Executing-:filter\",\n                                    \"method\",\n                                    \"Executed-:filter\"\n                                }.GetStr(), Setting.List.GetStr());\n        }\n```\nIt'll be working well.\n\n### 2.Use the Interface\nYou must impl a interface for your class\n```c#\n    public interface IMyModel\n    {\n        void Foo(int i);\n    }\n public class MyModel : IMyModel\n    {\n        private readonly string _key;\n\n        public MyModel(string key)\n        {\n            _key = key;\n        }\n\n        [MyFilter(\"method:filter\")]\n        public void Foo(int i)\n        {\n            Setting.List.Add(\"method-foo-\" + _key);\n        }\n    }\n```\n\nAnd use this code:\n```c#\n  var proxy = new AOPProxy\u003cIMyModel\u003e(new MyModel(\"1\"));\n  var obj = proxy.GetObject();\n  obj.Foo(1);\n```\nIt'll be running.\n\n### 3.Other\nYou can use Filter like this:\n```c#\n    [MyFilter(\"I:filter\")]\n    public interface IMyModel\n    {\n\n        [MyFilter(\"I-Method1:filter\")]\n        [MyFilter(\"I-Method2:filter\")]\n        void Foo(int i);\n\n        string MyProperty\n        {\n            [MyFilter(\"I-prop-get:filter\")]\n            get;\n        }\n    }\n    [MyFilter(\"class:filter\")]\n    public class MyModel : IMyModel\n    {\n        private readonly string _key;\n\n        public MyModel(string key)\n        {\n            _key = key;\n        }\n\n        [MyFilter(\"method:filter\")]\n        public void Foo(int i)\n        {\n            Setting.List.Add(\"method-foo-\" + _key);\n        }\n\n\n        public string MyProperty\n        {\n            [MyFilter(\"prop-get:filter\")]\n            get\n            {\n                Setting.List.Add(\"prop-ins-\" + _key);\n                return _key;\n            }\n\n        }\n    }\n```\n\nExecute Order is\n\nOrder | Description \n------------- | -------------\n1 | The Filter on Interface \n2 | The Filter on Class \n3 | The Filter on Interface's Method or Property \n4 | The Filter on Class 's Method or Property \n5 | Method or Property \n\n### References\nhttp://en.wikipedia.org/wiki/Aspect-oriented_programming\n\nhttp://weibo.com/chsword\n\nhttp://lnkd.in/b6vqP_c\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchsword%2Fexpressaop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchsword%2Fexpressaop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchsword%2Fexpressaop/lists"}