Command line options holder.
Example #1
0
        internal static void Main(string[] args)
        {
            Program.Options = ParseArguments(args);

            if (Program.Options.Help)
            {
                return;
            }

            var writer = CreateOutput(Program.Options);

            try
            {
                var text = LoadSourceText(Program.Options);
                var metadata = MetadataParser.Parse(text);

                ClassWriter.Write(Program.Options, metadata, writer);
            }
            catch (FormatException)
            {
                Console.WriteLine("Input does not contain text in the correct format.");
            }
            finally
            {
                if (writer != Console.Out)
                {
                    writer.Close();
                }
            }
        }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClassWriter"/> class.
        /// </summary>
        /// <param name="options">Output options.</param>
        /// <param name="output">Output writer to send class to.</param>
        /// <param name="headerFormat">Header format text.</param>
        public ClassWriter(Options options, TextWriter output, string headerFormat)
        {
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            this.options = options;

            if (output == null)
            {
                throw new ArgumentNullException("output");
            }

            this.output = output;

            if (headerFormat == null)
            {
                throw new ArgumentNullException("headerFormat");
            }

            this.headerFormat = headerFormat;

            this.indentWidth = options.IndentWidth;
        }
Example #3
0
 /// <summary>
 /// Creates the correct output.
 /// </summary>
 /// <param name="options">Save options.</param>
 /// <returns>A text writer instance.</returns>
 private static TextWriter CreateOutput(Options options)
 {
     switch (options.OutputFile)
     {
         case "CONS":
             return Console.Out;
         default:
             return new StreamWriter(options.OutputFile);
     }
 }
Example #4
0
 /// <summary>
 /// Depending on the current settings fetches the source metadata.
 /// </summary>
 /// <param name="options">Load options.</param>
 /// <returns>A string representing the whole metadata input.</returns>
 private static string LoadSourceText(Options options)
 {
     switch (options.MetadataSource)
     {
         case "CONS":
             return LoadSourceTextFromConsole();
         case "CLIP":
             return Clipboard.GetText();
         default:
             return File.ReadAllText(options.MetadataSource);
     }
 }
Example #5
0
        /// <summary>
        /// Helper function to setup the class and write the output.
        /// </summary>
        /// <param name="options">Output options.</param>
        /// <param name="metadata">Sequence of metadata to write.</param>
        /// <param name="output">Output writer to send class to.</param>
        public static void Write(Options options, IEnumerable<SsisMetadata> metadata, TextWriter output)
        {
            string headerFormat = Properties.Settings.Default.HeaderTemplate;

            var writer = new ClassWriter(options, output, headerFormat);
            writer.Write(metadata);
        }