[quote] Crappy chat quote implementation.

This commit is contained in:
West14
2022-01-21 00:10:27 +02:00
parent d9d5221280
commit 7cd1a295bb
10 changed files with 331 additions and 10 deletions
@@ -0,0 +1,26 @@
using System.Reflection;
using Newtonsoft.Json.Serialization;
using Telegram.Bot.Types;
namespace West.TelegramBot.ChatQuotes.Json;
public class NullToEmptyStringValueProvider : IValueProvider
{
private readonly PropertyInfo _memberInfo;
public NullToEmptyStringValueProvider(PropertyInfo memberInfo)
{
_memberInfo = memberInfo;
}
public object? GetValue(object target)
{
var result = _memberInfo.GetValue(target);
if (_memberInfo.PropertyType == typeof(Message) && result == null) result = new object();
return result;
}
public void SetValue(object target, object value)
{
_memberInfo.SetValue(target, value);
}
}