1 Star 0 Fork 88

macoco / weixinHttpApi

forked from codeman35 / weixinHttpApi 
Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
Clone or download
DelegateFun.cs 3.48 KB
Copy Edit Web IDE Raw Blame History
codeman35 authored 2016-01-05 19:16 . no commit message
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
//veelee 2006.8.1
namespace WeiXinZhuaFaWang
{
public class DelegateFun
{
#region
delegate void delegateSetControlValue(Control ctl, string key, object value);
delegate object delegateGetControlValue(Control ctl, string key);
static void _FunSetControlValue(Control ctl, string key, object value)
{
if (ctl.InvokeRequired)
ctl.Invoke(new delegateSetControlValue(_FunSetControlValue), new object[] { ctl, key, value });
else
ctl.GetType().GetProperty(key).SetValue(ctl, value, null);
}
static object _FunGetControlValue(Control ctl, string key)
{
if (ctl.InvokeRequired)
return ctl.Invoke(new delegateGetControlValue(_FunGetControlValue), new object[] { ctl, key });
else
return ctl.GetType().GetProperty(key).GetValue(ctl, null);
}
public static void SetControlValue(Control _this, Control ctl, string key, object value)
{
_this.Invoke(
new delegateSetControlValue(_FunSetControlValue),
ctl,
key,
value
);
}
public static object GetControlValue(Control _this, Control ctl, string key)
{
return _this.Invoke(
new delegateGetControlValue(_FunGetControlValue),
ctl,
key
);
}
#endregion
#region
delegate void delegateSetControlValueInvokeRequired(object ctl, string key, object value);
delegate object delegateGetControlValueInvokeRequired(object ctl, string key);
static void _FunSetControlValueInvokeRequired(object ctl, string key, object value)
{
ctl.GetType().GetProperty(key).SetValue(ctl,value,null);
}
static object _FunGetControlValueInvokeRequired(object ctl, string key)
{
return ctl.GetType().GetProperty(key).GetValue(ctl, null);
}
public static void SetControlValue(Control InvokeRequiredCtl, object ctl, string key, object value)
{
if (InvokeRequiredCtl.InvokeRequired)
{
InvokeRequiredCtl.Invoke(new delegateSetControlValueInvokeRequired(_FunSetControlValueInvokeRequired), new object[] { ctl, key, value });
}
else
ctl.GetType().GetProperty(key).SetValue(ctl, value, null);
}
public static object GetControlValue(Control InvokeRequiredCtl, object ctl, string key)
{
if (InvokeRequiredCtl.InvokeRequired)
{
return InvokeRequiredCtl.Invoke(new delegateGetControlValueInvokeRequired(_FunGetControlValueInvokeRequired), new object[] { ctl, key });
}
else
return ctl.GetType().GetProperty(key).GetValue(ctl, null);
}
#endregion
//下面再加入一个执行方法的
public delegate void delegateExeControlFun();
public static void ExeControlFun(Control InvokeRequiredCtl, Delegate del)
{
if (InvokeRequiredCtl.InvokeRequired)
{
InvokeRequiredCtl.Invoke(del);
}
else
del.DynamicInvoke();
}
}
}

Comment ( 0 )

Sign in for post a comment

C#
1
https://gitee.com/macoco/weixinHttpApi.git
git@gitee.com:macoco/weixinHttpApi.git
macoco
weixinHttpApi
weixinHttpApi
master

Search