internal static ScriptRef[] LoadScriptRefs(StreamMarshaler streamHelper, CfgSerializedHeader pFH) { if (pFH.FormatId != _SPGDF_ContextFree) { return(null); } if (pFH.pszWords < Marshal.SizeOf(typeof(CfgSerializedHeader))) { return(null); } StringBlob stringBlob = LoadStringBlob(streamHelper, pFH.pszSymbols, pFH.cchSymbols); CfgScriptRef[] array = Load <CfgScriptRef>(streamHelper, pFH.pScripts, pFH.cScripts); ScriptRef[] array2 = new ScriptRef[array.Length]; for (int i = 0; i < array.Length; i++) { CfgScriptRef cfgScriptRef = array[i]; array2[i] = new ScriptRef(stringBlob[cfgScriptRef._idRule], stringBlob[cfgScriptRef._idMethod], cfgScriptRef._method); } return(array2); }
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; } } }