コード例 #1
0
ファイル: Program.cs プロジェクト: MudaKaizen/GuidCreator
        static int Main(string[] args)
        {
            #region "Parse Args, Assign Vars"
            if (args.Length >= 1) { ParseHowMany(args[0]); }
            if (args.Length >= 2) { ParseUsage(args[1]); }
            if (args.Length >= 3) { ParseFormat(args[2]); }

            _gc = new GuidCreator.GuidCreator((byte)_howMany);
            #endregion

            #region "Clipboard"
            if (_clipBoard)
            {
                if (_noDash)
                {
                    Clipboard.SetText(String.Join("\r\n", _gc.CreatedGuids.Select(x => x.Replace("-", "")).ToArray()));
                }
                else
                {
                    Clipboard.SetText(String.Join("\r\n", _gc.CreatedGuids.ToArray()));
                }
            }
            #endregion
            #region "GUI, Notepad, Notepad++, whatever opens txt files"
            else if (_notepadGui)
            {
                if (File.Exists(GuidCreator.GuidCreator.GuidsFilePath))
                {
                    List<string> existing = File.ReadAllLines(GuidCreator.GuidCreator.GuidsFilePath).ToList();
                    if (existing.Count() < 256)
                    {
                        if (_noDash)
                        {
                            File.AppendAllLines(GuidCreator.GuidCreator.GuidsFilePath, _gc.CreatedGuids.Select(x => x.Replace("-", "")).ToArray());
                        }
                        else
                        {
                            File.AppendAllLines(GuidCreator.GuidCreator.GuidsFilePath, _gc.CreatedGuids.ToArray());
                        }
                    }
                }
                else
                {
                    if (_noDash)
                    {
                        List<string> tmp = _gc.CreatedGuids.Select(x => x.Replace("-", "")).ToList();
                        File.WriteAllLines(GuidCreator.GuidCreator.GuidsFilePath, _gc.CreatedGuids.ToArray());
                    }
                    else
                    {
                        File.WriteAllLines(GuidCreator.GuidCreator.GuidsFilePath, _gc.CreatedGuids.ToArray());
                    }
                }
                System.Diagnostics.Process.Start(GuidCreator.GuidCreator.GuidsFilePath);
            }
            #endregion

            return 0;
        }
コード例 #2
0
        private void Generate()
        {
            _gc = new GuidCreator.GuidCreator((byte)_howMany);

            #region "Clipboard"
            if (_clipBoard)
            {
                if (_noDash)
                {
                    Clipboard.SetText(String.Join("\r\n", _gc.CreatedGuids.Select(x => x.Replace("-", "")).ToArray()));
                }
                else
                {
                    Clipboard.SetText(String.Join("\r\n", _gc.CreatedGuids.ToArray()));
                }
            }
            #endregion
            #region "GUI, Notepad, Notepad++, whatever opens txt files"
            else if (_notepadGui)
            {
                if (File.Exists(GuidCreator.GuidCreator.GuidsFilePath))
                {
                    List<string> existing = File.ReadAllLines(GuidCreator.GuidCreator.GuidsFilePath).ToList();
                    if (existing.Count() < 256)
                    {
                        if (_noDash)
                        {
                            File.AppendAllLines(GuidCreator.GuidCreator.GuidsFilePath, _gc.CreatedGuids.Select(x => x.Replace("-", "")).ToArray());
                        }
                        else
                        {
                            File.AppendAllLines(GuidCreator.GuidCreator.GuidsFilePath, _gc.CreatedGuids.ToArray());
                        }
                    }
                }
                else
                {
                    if (_noDash)
                    {
                        List<string> tmp = _gc.CreatedGuids.Select(x => x.Replace("-", "")).ToList();
                        File.WriteAllLines(GuidCreator.GuidCreator.GuidsFilePath, _gc.CreatedGuids.ToArray());
                    }
                    else
                    {
                        File.WriteAllLines(GuidCreator.GuidCreator.GuidsFilePath, _gc.CreatedGuids.ToArray());
                    }
                }
                System.Diagnostics.Process.Start(GuidCreator.GuidCreator.GuidsFilePath);
            }
            #endregion
        }