// return loaded, failed, notallowed public Tuple <string, string, string> Load(string directory, string ourversion, string dllfolder, EDDDLLIF.EDDCallBacks callbacks, string allowed) { string loaded = ""; string failed = ""; string notallowed = ""; if (!Directory.Exists(directory)) { failed = "DLL Folder does not exist"; } else { FileInfo[] allFiles = Directory.EnumerateFiles(directory, "*.dll", SearchOption.TopDirectoryOnly).Select(f => new FileInfo(f)).OrderBy(p => p.LastWriteTime).ToArray(); string[] allowedfiles = allowed.Split(','); foreach (FileInfo f in allFiles) { string filename = System.IO.Path.GetFileNameWithoutExtension(f.FullName); EDDDLLCaller caller = new EDDDLLCaller(); if (caller.Load(f.FullName)) // if loaded (meaning it loaded, and its got EDDInitialise) { if (allowed.Equals("All", StringComparison.InvariantCultureIgnoreCase) || allowedfiles.Contains(filename, StringComparer.InvariantCultureIgnoreCase)) // if allowed.. { if (caller.Init(ourversion, dllfolder, callbacks)) // must init { dlls.Add(caller); loaded = loaded.AppendPrePad(caller.Name, ","); } else { string errstr = caller.Version.HasChars() ? (": " + caller.Version.Substring(1)) : ""; failed = failed.AppendPrePad(caller.Name + errstr, ","); } } else { notallowed = notallowed.AppendPrePad(caller.Name, ","); } } } } return(new Tuple <string, string, string>(loaded, failed, notallowed)); }
public string Load(string directory, string ourversion, string dllfolder, EDDDLLIF.EDDCallBacks callbacks, string allowed) { string res = ""; if (!Directory.Exists(directory)) { return("No Folder"); } FileInfo[] allFiles = Directory.EnumerateFiles(directory, "*.dll", SearchOption.TopDirectoryOnly).Select(f => new FileInfo(f)).OrderBy(p => p.LastWriteTime).ToArray(); foreach (FileInfo f in allFiles) { string name = "<" + System.IO.Path.GetFileNameWithoutExtension(f.FullName) + ">"; EDDDLLCaller caller = new EDDDLLCaller(); if (caller.Load(f.FullName)) // if loaded (meaning it loaded, and its got EDDInitialise) { if (allowed.Equals("All", StringComparison.InvariantCultureIgnoreCase) || allowed.IndexOf(name, StringComparison.InvariantCultureIgnoreCase) >= 0) // if allowed.. { if (caller.Init(ourversion, dllfolder, callbacks)) // must init { dlls.Add(caller); } else { return("DLL " + name + " Failed"); } } else { res += name; } } } return(res); }