예제 #1
0
파일: Program.cs 프로젝트: jam231/LinFu
        static void Main(string[] args)
        {
            var employee = new Employee();

            // All LinFu.AOP-modified objects implement the IModifiableType interface
            var modifiableType = employee as IModifiableType;

            // Plug in our custom implementation
            if (modifiableType != null)
                modifiableType.MethodBodyReplacementProvider = new SimpleMethodReplacementProvider(new SampleInterceptor());

            // The employee object will call the interceptor instead of the actual method implementation
            employee.Pay(12345);

            return;
        }
예제 #2
0
        private static void TestMethodBodyReplacementRegistry()
        {
            var provider = new SpeakProvider();
            MethodBodyReplacementProviderRegistry.SetProvider(provider);

            var employee = new Employee();
            employee.Pay(12345);
            Employee.SayName("Hello Neo");  // crashes unexpectedly
        }