예제 #1
0
        /// <summary>
        /// Converts the instance to a JSON string.
        /// </summary>
        /// <returns>The JSON string.</returns>
        public string WriteJson()
        {
            // Serialize
            string json = JsonIO.To(ToJsonInstance());

            // Return JSON string
            return(json);
        }
예제 #2
0
        private static void Execute(Options opts)
        {
            // Read input file (either from file or from stdin)
            var instance = JsonIO.From <JsonCalculation>(string.IsNullOrWhiteSpace(opts.Input) ? Console.In.ReadToEnd() : File.ReadAllText(opts.Input));

            // >> Run calculation
            Action <string> logger = string.IsNullOrWhiteSpace(opts.Output) ? null : Console.Write;
            var             result = Executor.Execute(Instance.FromJsonInstance(instance.Instance), instance.Configuration, logger);

            // Output result
            if (string.IsNullOrWhiteSpace(opts.Output))
            {
                Console.WriteLine(JsonIO.To(result.Solution.ToJsonSolution()));
            }
            else
            {
                File.WriteAllText(opts.Output, JsonIO.To(result.Solution.ToJsonSolution()));
            }
        }