using System.Collections.Generic;
public class ListProxy<T> : DispatchProxy
private T Object { set; get; }
public static T CreateListProxy(Func<T> creator)
object proxy = Create<T, ListProxy<T>>();
((ListProxy<T>)proxy).Object = creator();
protected override object Invoke(MethodInfo targetMethod, object[] args)
Console.WriteLine($"Start Running {targetMethod.Name}");
var result = targetMethod.Invoke(Object, args);
Console.WriteLine($"Finish Running {targetMethod.Name}\n");
private static void Main(string[] args)
var foo = ListProxy<IList<string>>.CreateListProxy(() => new List<string>());
foreach (var item in foo)