Command line options holder.
コード例 #1
0
ファイル: Program.cs プロジェクト: jsnape/deeply
        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();
                }
            }
        }
コード例 #2
0
ファイル: ClassWriter.cs プロジェクト: jsnape/deeply
        /// <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;
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: jsnape/deeply
 /// <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);
     }
 }
コード例 #4
0
ファイル: Program.cs プロジェクト: jsnape/deeply
 /// <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);
     }
 }
コード例 #5
0
ファイル: ClassWriter.cs プロジェクト: jsnape/deeply
        /// <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);
        }