public void Start(Guid id)
        {
            var entry = Credentials.FirstOrDefault(a => a.Id == id);

            if (entry == null)
            {
                throw new NullReferenceException(nameof(entry));
            }

            var configPath = entry.FilePath;

            CredentialManagerHelper.PutAccountId(configPath, entry.UserName, entry.IsDebug);
            CredentialManagerHelper.PutAccountPassword(configPath, entry.Password, entry.IsDebug);
            Thread.Sleep(500);
            var crystalClient = File.Exists(Path.Combine(CredentialManagerHelper.CrystalClientFileName));
            var startInfo     = new ProcessStartInfo
            {
                WorkingDirectory = entry.FilePath,
                FileName         = crystalClient
                    ? CredentialManagerHelper.CrystalClientFileName
                    : CredentialManagerHelper.ZirconFileName
            };

            Process.Start(startInfo);
        }
 public void Save()
 {
     using var stream = File.Create(CredentialManagerHelper.GetSaveFilePath());
     using var writer = new BinaryWriter(stream);
     writer.Write(Credentials.Count);
     foreach (var credentialEntry in Credentials)
     {
         writer.Write(credentialEntry.GetType().Name);
         credentialEntry.Save(writer);
     }
 }
        public virtual void Save(BinaryWriter writer)
        {
            var id = CredentialManagerHelper.Encrypt(Id.ToString());

            writer.Write(id);
            var serverName = CredentialManagerHelper.Encrypt(ServerName);

            writer.Write(serverName);
            var filePath = CredentialManagerHelper.Encrypt(FilePath);

            writer.Write(filePath);
            var userName = CredentialManagerHelper.Encrypt(UserName);

            writer.Write(userName);
            var password = CredentialManagerHelper.Encrypt(Password);

            writer.Write(password);
            writer.Write(IsDebug);
        }
        public virtual void Load(BinaryReader reader)
        {
            var id = reader.ReadString();

            Id = Guid.Parse(CredentialManagerHelper.Decrypt(id));
            var serverName = reader.ReadString();

            ServerName = CredentialManagerHelper.Decrypt(serverName);
            var filePath = reader.ReadString();

            FilePath = CredentialManagerHelper.Decrypt(filePath);
            var userName = reader.ReadString();

            UserName = CredentialManagerHelper.Decrypt(userName);
            var password = reader.ReadString();

            Password = CredentialManagerHelper.Decrypt(password);
            IsDebug  = reader.ReadBoolean();
        }
        public void Load()
        {
            if (!File.Exists(CredentialManagerHelper.GetSaveFilePath()))
            {
                return;
            }

            using var stream = File.OpenRead(CredentialManagerHelper.GetSaveFilePath());
            using var reader = new BinaryReader(stream);
            var count = reader.ReadInt32();

            for (var i = 0; i < count; i++)
            {
                var type = reader.ReadString();
                if (MappedTypes.ContainsKey(type))
                {
                    var res = Activator.CreateInstance(MappedTypes[type]);

                    ((ICredentialEntry)res).Load(reader);
                    Credentials.Add(res as ICredentialEntry);
                }
            }
        }