Exemplo n.º 1
0
        public static CreateGuidOptions Parse(IEnumerable <string> arguments)
        {
            var parms = new CreateGuidOptions();

            var options = new OptionSet()
                          .Add("f=|format", f => parms.Format   = (GuidFormat)Enum.Parse(typeof(GuidFormat), f))
                          .Add("o=|outfile", o => parms.OutFile = o)
                          .Add("n=|num", n => parms.Count       = Convert.ToUInt32(n))
                          .Add("?|help", p => ShowHelp());

            options.Parse(arguments);

            return(parms);
        }
Exemplo n.º 2
0
        public static CreateGuidOptions Parse(IEnumerable<string> arguments)
        {
            var parms = new CreateGuidOptions();

             var options = new OptionSet()
            .Add("f=|format", f => parms.Format = (GuidFormat)Enum.Parse(typeof(GuidFormat), f))
            .Add("o=|outfile", o => parms.OutFile = o)
            .Add("n=|num", n => parms.Count = Convert.ToUInt32(n))
            .Add("?|help", p=> ShowHelp());

             options.Parse(arguments);

             return parms;
        }
Exemplo n.º 3
0
        private static string CreateGuids(CreateGuidOptions options)
        {
            using (var sw = new StringWriter()) {
            for (int ii = 0; ii < options.Count; ++ii) {
               string guid = Guid.NewGuid().ToString(options.Format.ToString()).ToUpper();
               if (options.Count == 1) {
                  sw.Write(guid);
               }
               else {
                  sw.WriteLine(guid);
               }
            }

            return sw.ToString();
             }
        }
Exemplo n.º 4
0
        private static string CreateGuids(CreateGuidOptions options)
        {
            using (var sw = new StringWriter()) {
                for (int ii = 0; ii < options.Count; ++ii)
                {
                    string guid = Guid.NewGuid().ToString(options.Format.ToString()).ToUpper();
                    if (options.Count == 1)
                    {
                        sw.Write(guid);
                    }
                    else
                    {
                        sw.WriteLine(guid);
                    }
                }

                return(sw.ToString());
            }
        }
Exemplo n.º 5
0
 static void Main(string[] args)
 {
     try {
         var options = CreateGuidOptions.Parse(args);
         var guids   = CreateGuids(options);
         if (String.IsNullOrWhiteSpace(options.OutFile))
         {
             CopyToClipboard(guids);
         }
         else
         {
             SendToFile(guids, options);
         }
     }
     catch (Exception ex) {
         Console.WriteLine(ex);
         Environment.Exit(1);
     }
 }
Exemplo n.º 6
0
 private static void SendToFile(string guids, CreateGuidOptions options)
 {
     File.WriteAllText(options.OutFile, guids);
 }
Exemplo n.º 7
0
 private static void SendToFile(string guids, CreateGuidOptions options)
 {
     File.WriteAllText(options.OutFile, guids);
 }