private static void AssociateConstructorsWithRules(AppDomainCompilerProxy proxy, string[] names, List <Rule> rules, int iCfg, string language) { string[] array = proxy.Constructors(); foreach (Rule rule in rules) { int num = 0; while (num < names.Length && (num = Array.IndexOf(names, rule.Name, num)) >= 0) { if (array[num] != null) { rule.Constructors.Append(array[num]); } num++; } if (rule.Constructors.Length == 0) { rule.Constructors.Append(proxy.GenerateConstructor(iCfg, new ParameterInfo[0], language, rule.Name)); } } }
private void CheckValidAssembly(int iCfg, byte[] il) { Assembly executingAssembly = Assembly.GetExecutingAssembly(); AppDomain appDomain = null; try { appDomain = AppDomain.CreateDomain("Loading Domain"); AppDomainCompilerProxy appDomainCompilerProxy = (AppDomainCompilerProxy)appDomain.CreateInstanceFromAndUnwrap(executingAssembly.GetName().CodeBase, "System.Speech.Internal.SrgsCompiler.AppDomainCompilerProxy"); int count = _scriptRefs.Count; string[] array = new string[count]; string[] array2 = new string[count]; int[] array3 = new int[count]; for (int i = 0; i < count; i++) { ScriptRef scriptRef = _scriptRefs[i]; array[i] = scriptRef._rule; array2[i] = scriptRef._sMethod; array3[i] = (int)scriptRef._method; } Exception ex = appDomainCompilerProxy.CheckAssembly(il, iCfg, _language, _namespace, array, array2, array3); if (ex != null) { throw ex; } AssociateConstructorsWithRules(appDomainCompilerProxy, array, _rules, iCfg, _language); } finally { if (appDomain != null) { AppDomain.Unload(appDomain); appDomain = null; } } }