internal static void CompileToAssembly(RegexCompilationInfo[] regexes, AssemblyName an, CustomAttributeBuilder[] attribs, String resourceFile, Evidence evidence) { RegexTypeCompiler c = new RegexTypeCompiler(an, attribs, resourceFile, evidence); for (int i=0; i<regexes.Length; i++) { String pattern = regexes[i].Pattern; RegexOptions options = regexes[i].Options; String fullname; if (regexes[i].Namespace.Length == 0) fullname = regexes[i].Name; else fullname = regexes[i].Namespace + "." + regexes[i].Name; RegexTree tree = RegexParser.Parse(pattern, options); RegexCode code = RegexWriter.Write(tree); Type factory; new ReflectionPermission(PermissionState.Unrestricted).Assert(); try { factory = c.FactoryTypeFromCode(code, options, fullname); c.GenerateRegexType(pattern, options, fullname, regexes[i].IsPublic, code, tree, factory); } finally { CodeAccessPermission.RevertAssert(); } } c.Save(); }
internal static void CompileToAssembly(RegexCompilationInfo[] regexes, AssemblyName an, CustomAttributeBuilder[] attribs, string resourceFile) { RegexTypeCompiler compiler = new RegexTypeCompiler(an, attribs, resourceFile); for (int i = 0; i < regexes.Length; i++) { string name; if (regexes[i] == null) { throw new ArgumentNullException("regexes", SR.GetString("ArgumentNull_ArrayWithNullElements")); } string pattern = regexes[i].Pattern; RegexOptions op = regexes[i].Options; if (regexes[i].Namespace.Length == 0) { name = regexes[i].Name; } else { name = regexes[i].Namespace + "." + regexes[i].Name; } RegexTree t = RegexParser.Parse(pattern, op); RegexCode code = RegexWriter.Write(t); new ReflectionPermission(PermissionState.Unrestricted).Assert(); try { Type factory = compiler.FactoryTypeFromCode(code, op, name); compiler.GenerateRegexType(pattern, op, name, regexes[i].IsPublic, code, t, factory); } finally { CodeAccessPermission.RevertAssert(); } } compiler.Save(); }