From d9c2cdfd18be75859707648e993a859c36c2bad4 Mon Sep 17 00:00:00 2001 From: "Andres G. Aragoneses" Date: Fri, 31 Jan 2020 14:39:19 +0800 Subject: [PATCH] style: more consistent naming removing underscores There were less places with underscores in field names than places without them, so we now are consistent with the most abundant occurrence. --- TLSharp.Core/TelegramClient.cs | 30 ++---------------------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/TLSharp.Core/TelegramClient.cs b/TLSharp.Core/TelegramClient.cs index ca405bf..46e0ad4 100644 --- a/TLSharp.Core/TelegramClient.cs +++ b/TLSharp.Core/TelegramClient.cs @@ -31,25 +31,14 @@ namespace TLSharp.Core private Session session; private List dcOptions; private TcpClientConnectionHandler handler; - private DataCenterIPVersion dcIpVersion; public Session Session { get { return session; } } - /// - /// Creates a new TelegramClient - /// - /// The API ID provided by Telegram. Get one at https://my.telegram.org - /// The API Hash provided by Telegram. Get one at https://my.telegram.org - /// An ISessionStore object that will handle the session - /// The name of the session that tracks login info about this TelegramClient connection - /// A delegate to invoke when a connection is needed and that will return a TcpClient that will be used to connect - /// Indicates the preferred IpAddress version to use to connect to a Telegram server public TelegramClient(int apiId, string apiHash, - ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null, - DataCenterIPVersion dcIpVersion = DataCenterIPVersion.Default) + ISessionStore store = null, string sessionUserId = "session", TcpClientConnectionHandler handler = null) { if (apiId == default(int)) throw new MissingApiConfigurationException("API_ID"); @@ -62,7 +51,6 @@ namespace TLSharp.Core this.apiHash = apiHash; this.apiId = apiId; this.handler = handler; - this.dcIpVersion = dcIpVersion; session = Session.TryLoadOrCreateNew(store, sessionUserId); transport = new TcpTransport (session.DataCenter.Address, session.DataCenter.Port, this.handler); @@ -113,21 +101,7 @@ namespace TLSharp.Core exported = await SendRequestAsync(exportAuthorization, token).ConfigureAwait(false); } - var dcs = dcOptions.Where(d => d.Id == dcId - && ( - (dcIpVersion == DataCenterIPVersion.Default) // any - || (d.Ipv6 && dcIpVersion == DataCenterIPVersion.OnlyIPv6) // selects only ipv6 addresses - || (!d.Ipv6 && dcIpVersion == DataCenterIPVersion.OnlyIPv4) // selects only ipv4 addresses - || dcIpVersion == DataCenterIPVersion.PreferIPv4 // we can take both types of address - || dcIpVersion == DataCenterIPVersion.PreferIPv6 // we can take both types of address - ) - ).OrderBy(d => d.Ipv6); - - if (dcs.Count() == 0) - throw new Exception($"Telegram server didn't provide us with any IPAddress that matches your preferences. If you chose OnlyIPvX, try switch to PreferIPvX instead."); - - var dc = dcIpVersion == DataCenterIPVersion.PreferIPv4 ? dcs.First() : dcs.Last(); // ipv4 addresses are at the beginning of the list because it was ordered - + var dc = dcOptions.First(d => d.Id == dcId); var dataCenter = new DataCenter (dcId, dc.IpAddress, dc.Port); transport = new TcpTransport(dc.IpAddress, dc.Port, handler);