static void Main(string[] args) { try { Console.WriteLine("特性和AOP"); People people = new People(); UserModel userModel = new UserModel(); userModel.Id = 23; string remark = userModel.GetTableName(); BaseDAL.Save <UserModel>(userModel); #region AOP show Console.WriteLine("***********************"); Decorator.Show(); Console.WriteLine("***********************"); Proxy.Show(); Console.WriteLine("***********************"); CastleProxy.Show(); Console.WriteLine("***********************"); UnityAOP.Show(); #endregion } catch (Exception) { throw; } Console.Read(); }
static void Main(string[] args) { try { Console.WriteLine("欢迎来到.net高级班vip课程,今天的内容是特性和AOP"); People people = new People(); UserModel user = new UserModel(); user.Id = 1; string name = user.GetTableName <UserModel>(); string remark = UserState.Normal.GetRemark(); BaseDAL.Save <UserModel>(user); #region AOP show Console.WriteLine("***********************"); Decorator.Show(); Console.WriteLine("***********************"); Proxy.Show(); Console.WriteLine("***********************"); CastleProxy.Show(); Console.WriteLine("***********************"); UnityAOP.Show(); #endregion } catch (Exception ex) { Console.WriteLine(ex.Message); } Console.Read(); }
public void GivenDefaultConstructionShouldNotThrow() { CastleProxy <IQuestion> castleProxy = new CastleProxy <IQuestion>(); Action action = () => { IQuestion question = castleProxy.Interceptor(new Default()); question.String(1); }; action.ShouldNotThrow(); }
public void ShouldIntercept() { //arrange FakePerformanceMonitor fakePerformanceMonitor = new FakePerformanceMonitor(); CastleProxy <IQuestion> castleProxy = new CastleProxy <IQuestion>(fakePerformanceMonitor); //act IQuestion question = castleProxy.Interceptor(new Default()); question.String(1); //assert fakePerformanceMonitor.AssertInvoked(); }
public FizzBuzzCastleController(CastleProxy <IQuestion> castleProxy) : this(castleProxy.Interceptor(new FizzBuzz(castleProxy.Interceptor(new Buzz(castleProxy.Interceptor(new Fizz(castleProxy.Interceptor(new Default())))))))) { }