private static string GetNormalizedTypeSignature(string signature) { if (signature.Length <= 512) { return(signature); } string signatureHash = CryptographyHelper.ComputeHash(signature, HashType.MD5); return(string.Format("{0}_{1}", signature.Substring(0, 478), signatureHash)); }
private Type BuildType(string signature) { string signatureHash = CryptographyHelper.ComputeHash(signature, HashType.MD5); AssemblyName assemblyName = new AssemblyName("__DynamicType_" + signatureHash); string typeName = "__DynamicType_" + signature; AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run); ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name); CreateTypeBuilder(moduleBuilder, typeName); DefineTypeComponents(); return(TypeBuilder.CreateType()); }