예제 #1
0
        static void Main(string[] args)
        {
            // hello world example
            dynamic helloWorld = new HelloWorld.HelloWorld();
            helloWorld.HelloWorldCall();

            string text = "test";
            helloWorld.PrintIfArgNotNull(text);
            helloWorld.PrintIfArgNotNull(null);
            
            // logging example
            var entity = new TestEntity {Name = "Jon", Number = 99};
            dynamic repository = new TestRepository();
            repository.Save(entity);

            // exception handling example
            dynamic publicService = new PublicService
            {
                ServiceName = "TestService",
                Port = 1234,
                SessionId = "123908sdfhjkgdfg"
            };
            
            try
            {
                publicService.Send(entity);
            }
            catch (Exception ex)
            {
                Console.WriteLine("We catched original exception after 'exception aspect' did his job.");
            }

            Console.Read();
        }
예제 #2
0
 [LoggingAspect] // added a login aspect
 public void Save(TestEntity entity)
 {
     entity.Name = "Mark";
     entity.Number = 250;
 }
예제 #3
0
 public void Send(TestEntity entity)
 {
     throw new Exception();
 }