123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- using System;
- using Vinno.FIS.Sonopost.Common;
- namespace Vinno.FIS.Sonopost.Settings.Config
- {
- internal class ServerInfoSetting
- {
- private string _displayName;
- /// <summary>
- /// Gets or sets the host.
- /// </summary>
- public string Host { get; set; }
- /// <summary>
- /// Gets or sets the server port.
- /// </summary>
- public int Port { get; set; }
- /// <summary>
- /// Gets the value to indicate whether the server is FIS default server or custom server.
- /// </summary>
- public bool IsDefault { get; }
- /// <summary>
- /// Gets the value to indicate DisplayName,if is default,the displayName is Flyinsono Server else is host:port
- /// </summary>
- public string DisplayName => _displayName;
- public ServerInfoSetting(string host, int port, bool isDefault = false, string displayName = "")
- {
- Host = host;
- Port = port;
- IsDefault = isDefault;
- if (string.IsNullOrEmpty(displayName))
- {
- if (isDefault)
- {
- if (string.Equals($"{host}:{port}", SonopostConstants.OldChinaServer, StringComparison.OrdinalIgnoreCase) || string.Equals($"{host}:{port}", SonopostConstants.NewChinaServer, StringComparison.OrdinalIgnoreCase))
- {
- _displayName = SonopostConstants.ChinaServerName;
- }
- else if (string.Equals($"{host}:{port}", SonopostConstants.OldGermanyServer, StringComparison.OrdinalIgnoreCase) || string.Equals($"{host}:{port}", SonopostConstants.NewGermanyServer, StringComparison.OrdinalIgnoreCase))
- {
- _displayName = SonopostConstants.GermanyServerName;
- }
- else if (string.Equals($"{host}:{port}", SonopostConstants.OldHongkongServer, StringComparison.OrdinalIgnoreCase) || string.Equals($"{host}:{port}", SonopostConstants.NewHongkongServer, StringComparison.OrdinalIgnoreCase))
- {
- _displayName = SonopostConstants.HongkongServerName;
- }
- else
- {
- _displayName = $"{host}:{port}";
- }
- }
- else
- {
- _displayName = $"{host}:{port}";
- }
- }
- else
- {
- _displayName = displayName;
- }
- }
- public override string ToString()
- {
- return $"{Host}:{Port}";
- }
- }
- }
|