标签:proc RoCE specific net开发 编程 user repr cts col
//首先下载Castle.Windsor.dll //自定义Interceptor public class MyInterceptor : IInterceptor { public void Intercept(IInvocation invocation) { PreProceed(invocation); invocation.Proceed(); PostProceed(invocation); } public void PreProceed(IInvocation invocation) { Console.WriteLine("方法执行前"); } public void PostProceed(IInvocation invocation) { Console.WriteLine("方法执行后"); } } //用户注册接口和实现 public interface IUserProcessor { void RegUser(User user); } public class UserProcessor : IUserProcessor { public virtual void RegUser(User user) { Console.WriteLine("用户已注册。Name:{0},PassWord:{1}", user.Name, user.PassWord); } } //客户端调用 public class Client { public static void Run() { try { ProxyGenerator generator = new ProxyGenerator(); MyInterceptor interceptor = new MyInterceptor(); UserProcessor userprocessor = generator.CreateClassProxy<UserProcessor>(interceptor); User user= new User() { Name = "lee", PassWord = "123123123123" }; userprocessor.RegUser(user); } catch (Exception ex) { throw ex; } } }
标签:proc RoCE specific net开发 编程 user repr cts col
原文地址:https://www.cnblogs.com/zhaoshujie/p/12080569.html