main
 1using System;
 2using Castle.Core.Interceptor;
 3
 4namespace gorilla.commons.infrastructure.thirdparty.castle.dynamicproxy
 5{
 6    internal class LazyLoadedInterceptor<T> : IInterceptor
 7    {
 8        private readonly Func<T> get_the_implementation;
 9
10        public LazyLoadedInterceptor(Func<T> get_the_implementation)
11        {
12            this.get_the_implementation = get_the_implementation;
13        }
14
15        public void Intercept(IInvocation invocation)
16        {
17            var method = invocation.GetConcreteMethodInvocationTarget();
18            invocation.ReturnValue = method.Invoke(get_the_implementation(), invocation.Arguments);
19        }
20    }
21}