/// <summary> /// This will take an assembly object which the user has loaded and return a new set of ScriptCode’s which have /// been loaded into the provided ScriptDomainManager. /// /// If the language associated with the ScriptCode’s has not already been loaded the DLR will load the /// LanguageContext into the ScriptDomainManager based upon the saved LanguageContext type. /// /// If the LanguageContext or the version of the DLR the language was compiled against is unavailable a /// TypeLoadException will be raised unless policy has been applied by the administrator to redirect bindings. /// </summary> public static ScriptCode[] LoadFromAssembly(ScriptDomainManager runtime, Assembly assembly) { ContractUtils.RequiresNotNull(runtime, "runtime"); ContractUtils.RequiresNotNull(assembly, "assembly"); // get the type which has our cached code... Type t = assembly.GetType("DLRCachedCode"); if (t == null) { return new ScriptCode[0]; } List<ScriptCode> codes = new List<ScriptCode>(); MethodInfo mi = t.GetMethod("GetScriptCodeInfo"); if (mi.IsSpecialName && mi.IsDefined(typeof(DlrCachedCodeAttribute), false)) { var infos = (MutableTuple<Type[], Delegate[][], string[][], string[][]>)mi.Invoke(null, ArrayUtils.EmptyObjects); for (int i = 0; i < infos.Item000.Length; i++) { Type curType = infos.Item000[i]; LanguageContext lc = runtime.GetLanguage(curType); Debug.Assert(infos.Item001[i].Length == infos.Item002[i].Length); Delegate[] methods = infos.Item001[i]; string[] names = infos.Item002[i]; string[] customData = infos.Item003[i]; for (int j = 0; j < methods.Length; j++) { codes.Add(lc.LoadCompiledCode(methods[j], names[j], customData[j])); } } } return codes.ToArray(); }