Created
November 15, 2009 15:45
-
-
Save kkozmic/235285 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Linq; | |
namespace DP_perf_1 | |
{ | |
using System.Data; | |
using System.Diagnostics; | |
using System.ServiceModel; | |
using System.Web; | |
using System.Windows; | |
using System.Windows.Forms; | |
using System.Xml; | |
using Castle.DynamicProxy; | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var generator = new ProxyGenerator(new PersistentProxyBuilder()); | |
int i = 0; | |
var sw = Stopwatch.StartNew(); | |
foreach (var type in typeof(object).Assembly.GetTypes() | |
.Union(typeof(Uri).Assembly.GetTypes() | |
.Union(typeof(DataSet).Assembly.GetTypes()) | |
.Union(typeof(Form).Assembly.GetTypes()) | |
.Union(typeof(AspNetHostingPermission).Assembly.GetTypes() | |
.Union(typeof(IHasXmlNode).Assembly.GetTypes()) | |
.Union(typeof(ICommunicationObject).Assembly.GetTypes()) | |
.Union(typeof(DependencyPropertyHelper).Assembly.GetTypes()))) | |
.Where(t => t.IsVisible && t.IsInterface && !t.IsGenericTypeDefinition)) | |
{ | |
var target = generator.CreateInterfaceProxyWithoutTarget(type); | |
i++; | |
target.GetType(); | |
} | |
sw.Stop(); | |
Console.WriteLine("Number of types proxied: {0}", i); | |
Console.WriteLine("Time taken {0}",sw.Elapsed); | |
Console.WriteLine("Total number of generated types {0}", | |
generator.ProxyBuilder.ModuleScope.ObtainDynamicModuleWithStrongName().GetTypes().Length); | |
Console.ReadKey(true); | |
generator.ProxyBuilder.ModuleScope.SaveAssembly(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment