Permalink
Browse files

Renamed events, updated to .Net Core RTM

  • Loading branch information...
MrRoundRobin committed Jun 28, 2016
1 parent cde014e commit 54860e7048c2a0b76a206739d1bc1a2795e31199
@@ -1,4 +1,4 @@
version: 10.2.0-alpha-{build}
version: 10.3.0-alpha-{build}
pull_requests:
do_not_increment_build_number: true
branches:
@@ -26,7 +26,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
}
long val;
if (value is DateTime)
if (value is DateTime || value is Nullable<DateTime>)
{
#if NET46
val = new DateTimeOffset((DateTime)value).ToUnixTimeSeconds();
@@ -55,7 +55,7 @@ public override void WriteJson(JsonWriter writer, object value, JsonSerializer s
{
if (reader.TokenType == JsonToken.Null)
{
if (objectType == typeof(DateTime))
if (Nullable.GetUnderlyingType(objectType) != null)
return default(DateTime);
return null;
@@ -58,80 +58,141 @@ public partial class TelegramBotClient
#region Events
/// <summary>
/// Raises the <see cref="UpdateReceived" />, <see cref="MessageReceived"/>, <see cref="InlineQueryReceived"/>, <see cref="ChosenInlineResultReceived"/> and <see cref="CallbackQueryReceived"/> events.
/// Raises the <see cref="OnUpdate" />, <see cref="OnMessage"/>, <see cref="OnInlineQuery"/>, <see cref="OnInlineResultChosen"/> and <see cref="OnCallbackQuery"/> events.
/// </summary>
/// <param name="e">The <see cref="UpdateEventArgs"/> instance containing the event data.</param>
protected virtual void OnUpdateReceived(UpdateEventArgs e)
{
UpdateReceived?.Invoke(this, e);
OnUpdate?.Invoke(this, e);
switch (e.Update.Type)
{
case UpdateType.MessageUpdate:
MessageReceived?.Invoke(this, e);
OnMessage?.Invoke(this, e);
break;
case UpdateType.InlineQueryUpdate:
InlineQueryReceived?.Invoke(this, e);
OnInlineQuery?.Invoke(this, e);
break;
case UpdateType.ChosenInlineResultUpdate:
ChosenInlineResultReceived?.Invoke(this, e);
OnInlineResultChosen?.Invoke(this, e);
break;
case UpdateType.CallbackQueryUpdate:
CallbackQueryReceived?.Invoke(this, e);
OnCallbackQuery?.Invoke(this, e);
break;
case UpdateType.EditedMessage:
MessageEdited?.Invoke(this, e);
OnMessageEdited?.Invoke(this, e);
break;
}
}
/// <summary>
/// Raises the <see cref="ReceiveError" /> event.
/// Occurs when an <see cref="Update"/> is received.
/// </summary>
public event EventHandler<UpdateEventArgs> OnUpdate;
/// <summary>
/// Occurs when an <see cref="Update"/> is received.
/// </summary>
/// <param name="e">The <see cref="ReceiveErrorEventArgs"/> instance containing the event data.</param>
protected virtual void OnReceiveError(ReceiveErrorEventArgs e)
[Obsolete("Use OnUpdate")]
public event EventHandler<UpdateEventArgs> UpdateReceived
{
ReceiveError?.Invoke(this, e);
add { OnUpdate += value; }
remove { OnUpdate -= value; }
}
/// <summary>
/// Occurs when an <see cref="Update"/> is received.
/// Occurs when a <see cref="Message"/> is recieved.
/// </summary>
public event EventHandler<UpdateEventArgs> UpdateReceived;
public event EventHandler<MessageEventArgs> OnMessage;
/// <summary>
/// Occurs when a <see cref="Message"/> is recieved.
/// </summary>
public event EventHandler<MessageEventArgs> MessageReceived;
[Obsolete("Use OnMessage")]
public event EventHandler<MessageEventArgs> MessageReceived
{
add { OnMessage += value; }
remove { OnMessage -= value; }
}
/// <summary>
/// Occurs when <see cref="Message"/> was edited.
/// </summary>
public event EventHandler<MessageEventArgs> OnMessageEdited;
/// <summary>
/// Occurs when <see cref="Message"/> was edited.
/// </summary>
public event EventHandler<MessageEventArgs> MessageEdited;
[Obsolete("Use OnMessageEdited")]
public event EventHandler<MessageEventArgs> MessageEdited
{
add { OnMessageEdited += value; }
remove { OnMessageEdited -= value; }
}
/// <summary>
/// Occurs when an <see cref="InlineQuery"/> is received.
/// </summary>
public event EventHandler<InlineQueryEventArgs> InlineQueryReceived;
public event EventHandler<InlineQueryEventArgs> OnInlineQuery;
/// <summary>
/// Occurs when an <see cref="InlineQuery"/> is received.
/// </summary>
[Obsolete("Use OnInlineQuery")]
public event EventHandler<InlineQueryEventArgs> InlineQueryReceived
{
add { OnInlineQuery += value; }
remove { OnInlineQuery -= value; }
}
/// <summary>
/// Occurs when a <see cref="ChosenInlineResult"/> is received.
/// </summary>
public event EventHandler<ChosenInlineResultEventArgs> OnInlineResultChosen;
/// <summary>
/// Occurs when a <see cref="ChosenInlineResult"/> is received.
/// </summary>
public event EventHandler<ChosenInlineResultEventArgs> ChosenInlineResultReceived;
[Obsolete("Use OnInlineResultChosen")]
public event EventHandler<ChosenInlineResultEventArgs> ChosenInlineResultReceived
{
add { OnInlineResultChosen += value; }
remove { OnInlineResultChosen -= value; }
}
/// <summary>
/// Occurs when an <see cref="CallbackQuery"/> is received
/// </summary>
public event EventHandler<CallbackQueryEventArgs> CallbackQueryReceived;
public event EventHandler<CallbackQueryEventArgs> OnCallbackQuery;
/// <summary>
/// Occurs when an <see cref="CallbackQuery"/> is received
/// </summary>
[Obsolete("Use OnCallbackQuery")]
public event EventHandler<CallbackQueryEventArgs> CallbackQueryReceived
{
add { OnCallbackQuery += value; }
remove { OnCallbackQuery -= value; }
}
/// <summary>
/// Occurs when an error occures during the background update pooling.
/// </summary>
public event EventHandler<ReceiveErrorEventArgs> ReceiveError;
public event EventHandler<ReceiveErrorEventArgs> OnReceiveError;
/// <summary>
/// Occurs when an error occures during the background update pooling.
/// </summary>
[Obsolete("Use OnReceiveError")]
public event EventHandler<ReceiveErrorEventArgs> ReceiveError
{
add { OnReceiveError += value; }
remove { OnReceiveError -= value; }
}
#endregion
@@ -222,7 +283,7 @@ private async void ReceiveAsync(CancellationToken cancellationToken = default(Ca
catch (OperationCanceledException) {}
catch (ApiRequestException e)
{
OnReceiveError(e);
OnReceiveError?.Invoke(this, e);
}
}
@@ -1,5 +1,5 @@
{
"version": "10.2.0-*",
"version": "10.3.0-*",
"title": "Telegram Bot API",
"description": "Telegram Bot API Class Library",
"authors": [ "Robin Müller" ],
@@ -8,7 +8,7 @@
"iconUrl": "https://telegram.org/file/811140058/2/7GzMJk4Ij54/a1649c56fa9f805828",
"projectUrl": "https://github.com/MrRoundRobin/telegram.bot",
"licenseUrl": "https://raw.githubusercontent.com/MrRoundRobin/telegram.bot/master/LICENSE.txt",
"releaseNotes": "Added .NET Core RC2, API 2.1, Task Cancellation",
"releaseNotes": "Added .NET Core, API 2.1, Task Cancellation",
"tags": [ "Telegram", "Api", "Bot" ],
"repository": {
"type": "git",
@@ -37,16 +37,16 @@
"debugType": "portable"
},
"dependencies": {
"Microsoft.CSharp": "4.0.1-rc2-24027",
"System.Net.Http": "4.0.1-rc2-24027",
"System.Reflection": "4.1.0-rc2-24027",
"System.Runtime": "4.1.0-rc2-24027",
"System.Runtime.Serialization.Json": "4.0.2-rc2-24027"
"Microsoft.CSharp": "4.0.1",
"System.Net.Http": "4.1.0",
"System.Reflection": "4.1.0",
"System.Runtime": "4.1.0",
"System.Runtime.Serialization.Json": "4.0.2"
}
}
},
"dependencies": {
"Newtonsoft.Json": "9.0.1-beta1"
"Newtonsoft.Json": "9.0.1"
},
"buildOptions": {
"xmlDoc": true

0 comments on commit 54860e7

Please sign in to comment.