Ejemplo n.º 1
0
        public virtual Result UpdateModuleFiles(string assemblyName)
        {
            if (MoldsterModulesConfig.GetProjectPath(assemblyName, out string projectPath))
            {
                try
                {
                    var mod = MoldsterModulesConfig.Modules.Where(d => d.AssemblyName == assemblyName).FirstOrDefault();
                    if (mod == null)
                    {
                        return new Result {
                                   Code = 1, Message = $"Module not registered '{assemblyName}'"
                        }
                    }
                    ;

                    ArchiveScripts(mod, projectPath);
                    ArchiveViews(mod, projectPath);
                    UpdateDefinitionJson(mod, projectPath);
                    return(new Result(0));
                }
                catch (Exception ex)
                {
                    var res = new Result(1);
                    res.Message = "Failed";
                    res.SetException(ex);
                    return(res);
                }
            }
            return(new Result {
                Code = 1, Message = $"No project path registered for '{assemblyName}'"
            });
        }
Ejemplo n.º 2
0
        protected virtual void UpdateDefinitionJson(MoldsterModule mod, string projectPath)
        {
            mod.Categories = unit.PageCategoryRepository.GetByMoldsterModule(mod.InstallPath);
            mod.Resources  = unit.ResourceRepository.GetByMoldsterModule(mod.InstallPath);

            WriteFileOperation("Updating", "Module.json");
            string path = Path.Combine(projectPath, "Module.json");

            File.WriteAllText(path, mod.ToJsonIndent());
            MoldsterModulesConfig.SetModule(mod);
            WriteSuccess();
            Out.WriteLine();
        }
Ejemplo n.º 3
0
        public static void AddMoldsterModules(this IServiceCollection coll, Action <MoldsterModulesConfig> modules)
        {
            var conf = new MoldsterModulesConfig();

            modules(conf);
        }