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 9408549d51
commit 2b13e7c1d7

View file

@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
@ -24,7 +22,6 @@ using TLAuthorization = TeleSharp.TL.Auth.TLAuthorization;
namespace TLSharp.Core namespace TLSharp.Core
{ {
public class TelegramClient : IDisposable public class TelegramClient : IDisposable
{ {
private MtProtoSender sender; private MtProtoSender sender;
@ -51,7 +48,8 @@ namespace TLSharp.Core
/// <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="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> /// <param name="dcIpVersion">Indicates the preferred IpAddress version to use to connect to a Telegram server</param>
public TelegramClient(int apiId, string apiHash, 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,
DataCenterIPVersion dcIpVersion = DataCenterIPVersion.Default)
{ {
if (apiId == default(int)) if (apiId == default(int))
throw new MissingApiConfigurationException("API_ID"); throw new MissingApiConfigurationException("API_ID");
@ -130,7 +128,7 @@ namespace TLSharp.Core
var dc = dcIpVersion == DataCenterIPVersion.PreferIPv4 ? dcs.First() : dcs.Last(); // ipv4 addresses are at the beginning of the list because it was ordered var dc = dcIpVersion == DataCenterIPVersion.PreferIPv4 ? dcs.First() : dcs.Last(); // ipv4 addresses are at the beginning of the list because it was ordered
var dataCenter = new DataCenter(dcId, dc.IpAddress, dc.Port); var dataCenter = new DataCenter (dcId, dc.IpAddress, dc.Port);
transport = new TcpTransport(dc.IpAddress, dc.Port, handler); transport = new TcpTransport(dc.IpAddress, dc.Port, handler);
session.DataCenter = dataCenter; session.DataCenter = dataCenter;
@ -271,7 +269,7 @@ namespace TLSharp.Core
return (T)result; return (T)result;
} }
internal async Task<T> SendAuthenticatedRequestAsync<T>(TLMethod methodToExecute, CancellationToken token = default(CancellationToken)) internal async Task<T> SendAuthenticatedRequestAsync<T> (TLMethod methodToExecute, CancellationToken token = default(CancellationToken))
{ {
if (!IsUserAuthorized()) if (!IsUserAuthorized())
throw new InvalidOperationException("Authorize user first!"); throw new InvalidOperationException("Authorize user first!");
@ -298,7 +296,7 @@ namespace TLSharp.Core
public async Task<TLImportedContacts> ImportContactsAsync(IReadOnlyList<TLInputPhoneContact> contacts, CancellationToken token = default(CancellationToken)) public async Task<TLImportedContacts> ImportContactsAsync(IReadOnlyList<TLInputPhoneContact> contacts, CancellationToken token = default(CancellationToken))
{ {
var req = new TLRequestImportContacts { Contacts = new TLVector<TLInputPhoneContact>(contacts) }; var req = new TLRequestImportContacts { Contacts = new TLVector<TLInputPhoneContact>(contacts)};
return await SendAuthenticatedRequestAsync<TLImportedContacts>(req, token) return await SendAuthenticatedRequestAsync<TLImportedContacts>(req, token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -306,7 +304,7 @@ namespace TLSharp.Core
public async Task<bool> DeleteContactsAsync(IReadOnlyList<TLAbsInputUser> users, CancellationToken token = default(CancellationToken)) public async Task<bool> DeleteContactsAsync(IReadOnlyList<TLAbsInputUser> users, CancellationToken token = default(CancellationToken))
{ {
var req = new TLRequestDeleteContacts { Id = new TLVector<TLAbsInputUser>(users) }; var req = new TLRequestDeleteContacts {Id = new TLVector<TLAbsInputUser>(users)};
return await SendAuthenticatedRequestAsync<bool>(req, token) return await SendAuthenticatedRequestAsync<bool>(req, token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -314,7 +312,7 @@ namespace TLSharp.Core
public async Task<TLLink> DeleteContactAsync(TLAbsInputUser user, CancellationToken token = default(CancellationToken)) public async Task<TLLink> DeleteContactAsync(TLAbsInputUser user, CancellationToken token = default(CancellationToken))
{ {
var req = new TLRequestDeleteContact { Id = user }; var req = new TLRequestDeleteContact {Id = user};
return await SendAuthenticatedRequestAsync<TLLink>(req, token) return await SendAuthenticatedRequestAsync<TLLink>(req, token)
.ConfigureAwait(false); .ConfigureAwait(false);
@ -370,13 +368,13 @@ namespace TLSharp.Core
public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption, CancellationToken token = default(CancellationToken)) public async Task<TLAbsUpdates> SendUploadedPhoto(TLAbsInputPeer peer, TLAbsInputFile file, string caption, CancellationToken token = default(CancellationToken))
{ {
return await SendAuthenticatedRequestAsync<TLAbsUpdates>(new TLRequestSendMedia() return await SendAuthenticatedRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{ {
RandomId = Helpers.GenerateRandomLong(), RandomId = Helpers.GenerateRandomLong(),
Background = false, Background = false,
ClearDraft = false, ClearDraft = false,
Media = new TLInputMediaUploadedPhoto() { File = file, Caption = caption }, Media = new TLInputMediaUploadedPhoto() { File = file, Caption = caption },
Peer = peer Peer = peer
}, token) }, token)
.ConfigureAwait(false); .ConfigureAwait(false);
} }
@ -384,30 +382,30 @@ namespace TLSharp.Core
TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector<TLAbsDocumentAttribute> attributes, CancellationToken token = default(CancellationToken)) TLAbsInputPeer peer, TLAbsInputFile file, string caption, string mimeType, TLVector<TLAbsDocumentAttribute> attributes, CancellationToken token = default(CancellationToken))
{ {
return await SendAuthenticatedRequestAsync<TLAbsUpdates>(new TLRequestSendMedia() return await SendAuthenticatedRequestAsync<TLAbsUpdates>(new TLRequestSendMedia()
{
RandomId = Helpers.GenerateRandomLong(),
Background = false,
ClearDraft = false,
Media = new TLInputMediaUploadedDocument()
{ {
File = file, RandomId = Helpers.GenerateRandomLong(),
Caption = caption, Background = false,
MimeType = mimeType, ClearDraft = false,
Attributes = attributes Media = new TLInputMediaUploadedDocument()
}, {
Peer = peer File = file,
}, token) Caption = caption,
MimeType = mimeType,
Attributes = attributes
},
Peer = peer
}, token)
.ConfigureAwait(false); .ConfigureAwait(false);
} }
public async Task<TLFile> GetFile(TLAbsInputFileLocation location, int filePartSize, int offset = 0, CancellationToken token = default(CancellationToken)) public async Task<TLFile> GetFile(TLAbsInputFileLocation location, int filePartSize, int offset = 0, CancellationToken token = default(CancellationToken))
{ {
TLFile result = await SendAuthenticatedRequestAsync<TLFile>(new TLRequestGetFile TLFile result = await SendAuthenticatedRequestAsync<TLFile>(new TLRequestGetFile
{ {
Location = location, Location = location,
Limit = filePartSize, Limit = filePartSize,
Offset = offset Offset = offset
}, token) }, token)
.ConfigureAwait(false); .ConfigureAwait(false);
return result; return result;
} }