Esempio n. 1
0
        public static void Main(string[] args)
        {
            var showHelp = false;

            var options = new OptionSet()
            {
                {
                    "h|help",
                    "show this message and exit",
                    v => showHelp = v != null
                    },
            };

            List<string> extras;

            try
            {
                extras = options.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("{0}: ", GetExecutableName());
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `{0} --help' for more information.", GetExecutableName());
                return;
            }

            if (extras.Count < 1 || extras.Count > 2 ||
                showHelp == true)
            {
                Console.WriteLine("Usage: {0} [OPTIONS]+ input_cnd [output_file]", GetExecutableName());
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return;
            }

            var inputPath = extras[0];
            var outputPath = extras.Count > 1 ? extras[1] : null;

            var cnd = new ConditionalsFile();
            using (var input = File.OpenRead(inputPath))
            {
                cnd.Deserialize(input);
            }

            if (outputPath == null)
            {
                DumpConditionals(Console.Out, cnd);
            }
            else
            {
                using (var output = File.Create(outputPath))
                {
                    var writer = new StreamWriter(output);
                    DumpConditionals(writer, cnd);
                    writer.Flush();
                }
            }
        }
Esempio n. 2
0
        private static void DumpConditionals(TextWriter writer, ConditionalsFile cnd)
        {
            foreach (var id in cnd.Ids.OrderBy(id => id))
            {
                writer.WriteLine("[conditional_{0}]", id);

                var buffer = cnd.GetConditional(id);
                writer.WriteLine("{0}", DumpConditionalBool(new ByteBufferReader(buffer, 0, cnd.Endian)));

                writer.WriteLine();
            }
        }
Esempio n. 3
0
        private static void DumpConditionals(TextWriter writer, ConditionalsFile cnd)
        {
            foreach (var id in cnd.Ids.OrderBy(id => id))
            {
                writer.WriteLine("[conditional_{0}]", id);

                var buffer = cnd.GetConditional(id);
                writer.WriteLine("{0}", DumpConditionalBool(new ByteBufferReader(buffer, 0, cnd.Endian)));

                writer.WriteLine();
            }
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            var showHelp = false;

            var options = new OptionSet()
            {
                {
                    "h|help",
                    "show this message and exit",
                    v => showHelp = v != null
                },
            };

            List <string> extras;

            try
            {
                extras = options.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("{0}: ", GetExecutableName());
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `{0} --help' for more information.", GetExecutableName());
                return;
            }

            if (extras.Count < 1 || extras.Count > 2 ||
                showHelp == true)
            {
                Console.WriteLine("Usage: {0} [OPTIONS]+ input_cnd [output_file]", GetExecutableName());
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return;
            }

            var inputPath  = extras[0];
            var outputPath = extras.Count > 1 ? extras[1] : null;

            var cnd = new ConditionalsFile();

            using (var input = File.OpenRead(inputPath))
            {
                cnd.Deserialize(input);
            }

            if (outputPath == null)
            {
                DumpConditionals(Console.Out, cnd);
            }
            else
            {
                using (var output = File.Create(outputPath))
                {
                    var writer = new StreamWriter(output);
                    DumpConditionals(writer, cnd);
                    writer.Flush();
                }
            }
        }