using Api.Framework.Tools;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Api.Framework.SDK
{
///
/// 插件扩展类
///
public static class PluginExtend
{
///
/// 输出日志
///
///
/// 日志内容
public static void OnLog(this Plugin plugin, string message)
{
EventClient.OnEvent(plugin, new Framework.Events.LogEvents("【" + plugin.Name + "】" + message));
}
///
/// 读入配置
///
///
///
///
public static T ReadConfig(this Plugin plugin)
{
var t = Util.Read();
//System.Drawing.Color c = new System.Drawing.Color();
return t;
}
///
/// 保存配置
///
///
/// 保存的对象
public static void SaveConfig(this Plugin plugin, Object obj)
{
Util.Save(obj);
}
///
/// 反射获取某个对象属性的值
///
/// 对象
/// 对象中的属性
///
public static object FindPropertyValue(this Object obj, string name)
{
var _type = obj.GetType();
var _prot = _type.GetProperties();
foreach (System.Reflection.PropertyInfo p in _prot)
{
if (name == p.Name) return p.GetValue(obj);
}
return null;
}
///
/// 反射获取某个对象属性信息
///
/// 对象
/// 对象中的属性
///
public static System.Reflection.PropertyInfo FindPropertyInfo(this Object obj, string name)
{
var _type = obj.GetType();
var _prot = _type.GetProperties();
foreach (System.Reflection.PropertyInfo p in _prot)
{
if (name == p.Name) return p;
}
return null;
}
}
}