protected virtual IEnumerable <T> LoadScript(FileSystemInfo file, UpdateLoadResourcesDelegate updateAction, int totalCount, int currentCount) { var assemblyPath = Path.Combine(CompleteCompiledScriptPath, Path.ChangeExtension(file.Name, ".dll")); var md5Path = Path.Combine(CompleteCompiledScriptPath, Path.ChangeExtension(file.Name, ".md5")); Assembly assembly; if (ScriptNeedsCompilation(file, assemblyPath, md5Path)) { updateAction(string.Format("Compiling: {0}", file.Name), currentCount, totalCount); assembly = CSScript.Load(file.ToString(), assemblyPath, false); } else { updateAction(string.Format("Loading: {0}", Path.GetFileName(Path.ChangeExtension(file.Name, ".dll"))), currentCount, totalCount); assembly = Assembly.LoadFrom(assemblyPath); } var helper = new AsmHelper(assembly); return(assembly.ExportedTypes .Where(x => x.GetInterfaces().Contains(typeof(T))) .Select(source => (T)helper.CreateObject(source.FullName))); }
public IEnumerable <T> LoadScripts(UpdateLoadResourcesDelegate updateAction) { var totalCount = ScriptCount; var currentCount = 0; if (!Directory.Exists(CompleteCompiledScriptPath)) { Directory.CreateDirectory(CompleteCompiledScriptPath); } var resultList = new List <T>(); foreach ( var file in Directory.EnumerateFiles(CompletePath, "*.cs", SearchOption.AllDirectories) .Select(x => new FileInfo(x)) .Where(x => x.Extension == ".cs")) { resultList.AddRange(LoadScript(file, updateAction, totalCount, ++currentCount)); } return(resultList); }
public IEnumerable <ISkillset> LoadSkillsets(UpdateLoadResourcesDelegate updateAction) { return(_skillsetScriptLoader.LoadScripts(updateAction)); }
public IEnumerable <IArcheType> LoadArcheTypes(UpdateLoadResourcesDelegate updateModel) { return(_archeTypeScriptLoader.LoadScripts(updateModel)); }
public IEnumerable <IAffliction> LoadAfflictions(UpdateLoadResourcesDelegate updateAction) { return(_afflictionScriptLoader.LoadScripts(updateAction)); }
public IEnumerable <ISpell> LoadSpells(UpdateLoadResourcesDelegate updateAction) { return(_spellScriptLoader.LoadScripts(updateAction)); }
public IEnumerable <IRaceTemplate> LoadRaceTemplates(UpdateLoadResourcesDelegate updateAction) { return(_raceScriptLoader.LoadScripts(updateAction)); }