Пример #1
0
        public static ModuleFile LoadModule(string module)
        {
            if (ModuleFileCache.ContainsKey(module))
            {
                return(ModuleFileCache[module]);
            }
            else
            {
                string file = ModuleList.ModuleList.Instance.GetModuleFile(module);

                if (File.Exists(file))
                {
                    //Read the file's text and parse it
                    string     text = File.ReadAllText(file);
                    ModuleFile dmod = JsonConvert.DeserializeObject <ModuleFile>(text);

                    //Add it to the cache
                    ModuleFileCache.Add(module, dmod);

                    //And return it
                    return(dmod);
                }
                else
                {
                    throw new FileNotFoundException($"Couldn't get module file for module {module}", file);
                }
            }
        }
Пример #2
0
        public async Task Start()
        {
            //If we are doing this recursively, we need to load the module to find its dependencies.
            if (Options.Recursive)
            {
                Console.WriteLine($"Doing tasks for dependencies of module {Module}");

                //Here, we use linq to go through each dependency in the module, turn it into a ModuleTask.
                var deps = ModuleFile.LoadModule(Module).Deps;

                if (deps.Length > 0)
                {
                    var tasks = deps.Select((dep) => new ModuleTask(Options, dep).Start()).ToArray();
                    await Task.WhenAll(tasks);
                }
            }

            await Task.WhenAll(ProvideSTD(), Build());
        }
Пример #3
0
        public static void GenerateHeader(string file)
        {
            Console.WriteLine($"Started generating headers for file {file}");

            //If the file has no extension, it prob has a .dmod extension irl
            if (!Path.HasExtension(file))
            {
                file = file + ".dmod";
            }

            //Make sure we have a valid file
            if (File.Exists(file))
            {
                //Read the file's text and parse it
                string     text = File.ReadAllText(file);
                ModuleFile dmod = JsonConvert.DeserializeObject <ModuleFile>(text);

                //Get the path of the module
                var modulePath = Path.GetDirectoryName(file);

                string headerFile = Path.Combine(modulePath, dmod.Header);
            }
        }