mirror of
https://github.com/Bubuni-Team/telegram-bot.git
synced 2026-07-31 00:29:24 +03:00
[quote] Crappy chat quote implementation.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user