Exemplo n.º 1
0
        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)));
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
 public IEnumerable <ISkillset> LoadSkillsets(UpdateLoadResourcesDelegate updateAction)
 {
     return(_skillsetScriptLoader.LoadScripts(updateAction));
 }
Exemplo n.º 4
0
 public IEnumerable <IArcheType> LoadArcheTypes(UpdateLoadResourcesDelegate updateModel)
 {
     return(_archeTypeScriptLoader.LoadScripts(updateModel));
 }
Exemplo n.º 5
0
 public IEnumerable <IAffliction> LoadAfflictions(UpdateLoadResourcesDelegate updateAction)
 {
     return(_afflictionScriptLoader.LoadScripts(updateAction));
 }
Exemplo n.º 6
0
 public IEnumerable <ISpell> LoadSpells(UpdateLoadResourcesDelegate updateAction)
 {
     return(_spellScriptLoader.LoadScripts(updateAction));
 }
Exemplo n.º 7
0
 public IEnumerable <IRaceTemplate> LoadRaceTemplates(UpdateLoadResourcesDelegate updateAction)
 {
     return(_raceScriptLoader.LoadScripts(updateAction));
 }