Exemplo n.º 1
0
        public string Merge(RecipeConfigEntity entity)
        {
            FileInfo      fi = new FileInfo(entity.OutputConfigFile);
            DirectoryInfo di = new DirectoryInfo(entity.InputConfigFolder);

            if (!di.Exists)
            {
                return("输入目录不存在。");
            }
            if (!di.GetFiles("*.config").Any())
            {
                return("输入目录没有配置文件。");
            }
            var    name     = string.Format("{0}.recipe", Guid.NewGuid().ToString().Replace("-", ""));
            string fileName = string.Format("{0}{1}", ApplictionDataTemp, name);

            try
            {
                CreateRecipe(fileName, fi, di);
                ConfigMergeTools.Merge(name);
            }
            finally
            {
                if (File.Exists(fileName))
                {
                    File.Delete(fileName);
                }
            }
            return("");
        }
Exemplo n.º 2
0
 private static int Main(string[] args)
 {
     Console.WriteLine(ProgramInfo.Greeting);
     if (args.NeedsHelp())
     {
         PrintUsage();
         return(ErrorCodes.MissingUserInput);
     }
     try
     {
         var arguments = args.To <MergeArgs>();
         ConfigMergeTools.Merge(arguments.Recipe, arguments.L);
         return(ErrorCodes.Ok);
     }
     catch (RecipeCompilerException ex)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine(ex.Message);
         Console.ResetColor();
         return(ErrorCodes.RecipeError);
     }
     catch (Exception ex)
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine($"{ProgramInfo.Name}: error: {ex.Message}");
         Console.WriteLine(ex.StackTrace);
         Console.ResetColor();
         return(ErrorCodes.Unhandled);
     }
 }