Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 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
        }