Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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());
        }