C AOP手動實現

2021-08-01 07:28:21 字數 862 閱讀 6586

1.使用者註冊介面和實現

public inte***ce iuserprocessor

public class userprocessor : iuserprocessor

,password:", user.name, user.password);}}

public class user

public string password

}

2.通過靜態編寫**的方式,裝飾上面的使用者註冊

public class userprocessordecorator : iuserprocessor

public userprocessordecorator(iuserprocessor userprocessor)

public void reguser(user user)

public void preproceed(user user)

public void postproceed(user user)

}

3.客戶端呼叫

public class client

;iuserprocessor userprocessor = new userprocessordecorator(new userprocessor());

userprocessor.reguser(user);

}catch (exception ex)

}}

輸出

方法執行前

使用者已註冊。name:lee,password:123123123123

方法執行後

C AOP微型框架實現(二)

3.aopproxyattribute aop 特性 aopproxyattribute using system using system.runtime.remoting using system.runtime.remoting.proxies namespace enterpriseserv...

C AOP之類方法攔截

新建控制台應用程式 通過nuget新增對castle.core的引用 建立類dog using system 注 此方法不會被攔截。因為此方法不能被重寫。public void eat 重寫 using castle.dynamicproxy using system protected overr...

手動實現strncmp

自己寫的版本 int strncmp char s1,char s2,int maxlen ansi c版本 難懂 360doc.com content 11 0422 23 1317564 111662313.shtml include int strncmp register const cha...