public BlockchainNetworkConnection(BlockchainNetworkType networkType, string apiHost = "localhost", int apiPort = 3000, HttpProtocol apiProtocol = HttpProtocol.Http) { CheckParameter(apiHost != null, "apiHost is required"); CheckParameter(apiPort > 0, "apiPort must be non-negative int"); NetworkType = networkType.GetNetworkType(); ApiHost = apiHost; ApiPort = apiPort; HttpProtocol = apiProtocol; RestApiUrl = new UriBuilder(HttpProtocol.GetProtocol(), apiHost, apiPort).Uri.AbsoluteUri; }
public static NetworkType GetNetworkType(this BlockchainNetworkType type) { switch (type) { case BlockchainNetworkType.MainNet: return(NetworkType.MAIN_NET); case BlockchainNetworkType.TestNet: return(NetworkType.TEST_NET); case BlockchainNetworkType.Private: return(NetworkType.PRIVATE); case BlockchainNetworkType.PrivateTest: return(NetworkType.PRIVATE_TEST); case BlockchainNetworkType.Mijin: return(NetworkType.MIJIN); case BlockchainNetworkType.MijinTest: return(NetworkType.MIJIN_TEST); default: throw new NetworkTypeInvalidException("Invalid network type"); } }