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.
This commit is contained in:
Andres G. Aragoneses 2020-01-31 14:39:19 +08:00 committed by solarin
parent 2b13e7c1d7
commit d9c2cdfd18

View file

@ -31,25 +31,14 @@ namespace TLSharp.Core
private Session session;
private List<TLDcOption> dcOptions;
private TcpClientConnectionHandler handler;
private DataCenterIPVersion dcIpVersion;
public Session Session
{
get { return session; }
}
/// <summary>
/// Creates a new TelegramClient
/// </summary>
/// <param name="apiId">The API ID provided by Telegram. Get one at https://my.telegram.org </param>
/// <param name="apiHash">The API Hash provided by Telegram. Get one at https://my.telegram.org </param>
/// <param name="store">An ISessionStore object that will handle the session</param>
/// <param name="sessionUserId">The name of the session that tracks login info about this TelegramClient connection</param>
/// <param name="handler">A delegate to invoke when a connection is needed and that will return a TcpClient that will be used to connect</param>
/// <param name="dcIpVersion">Indicates the preferred IpAddress version to use to connect to a Telegram server</param>
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<TLExportedAuthorization>(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);