有个类的方法:
void Call<T>(string command, Responder<T> responder, params object[] arguments);
Responder<T> responder 这个该如何赋值? 没怎么用过c#,麻烦指点下,谢谢。
Responder类代码如下:public delegate void ResultFunction<T>(T @object);
/// <summary>
/// The function invoked if the server returns an error.
/// </summary>
public delegate void StatusFunction(Fault fault); /// <summary>
/// The Responder class provides an object that is used in NetConnection.call() to handle return values from the server related to the success or failure of specific operations.
/// When working with NetConnection.call(), you may encounter a network operation fault specific to the current operation or a fault related to the current connection status.
/// Operation errors target the Responder object instead of the NetConnection object for easier error handling.
/// </summary>
/// <typeparam name="T"></typeparam>
public class Responder<T>
{
private readonly ResultFunction<T> _result;
private readonly StatusFunction _status; /// <summary>
/// Initializes a new instance of the <see cref="Responder<T>"/> class.
/// You pass a Responder object to NetConnection.call() to handle return values from the server. You may pass null for either or both parameters.
/// </summary>
/// <param name="result">The function invoked if the call to the server succeeds and returns a result.</param>
public Responder(ResultFunction<T> result)
: this(result, null)
{
} /// <summary>
/// Initializes a new instance of the <see cref="Responder<T>"/> class.
/// You pass a Responder object to NetConnection.call() to handle return values from the server. You may pass null for either or both parameters.
/// </summary>
/// <param name="result">The function invoked if the call to the server succeeds and returns a result.</param>
/// <param name="status">The function invoked if the server returns an error.</param>
public Responder(ResultFunction<T> result, StatusFunction status)
{
_result = result;
_status = status;
} /// <summary>
/// Gets the function invoked if the call to the server succeeds and returns a result.
/// </summary>
/// <value>The result function.</value>
public ResultFunction<T> Result
{
get { return _result; }
} /// <summary>
/// Gets the function invoked if the server returns an error.
/// </summary>
/// <value>The status function.</value>
public StatusFunction Status
{
get { return _status; }
}
}
void Call<T>(string command, Responder<T> responder, params object[] arguments);
Responder<T> responder 这个该如何赋值? 没怎么用过c#,麻烦指点下,谢谢。
Responder类代码如下:public delegate void ResultFunction<T>(T @object);
/// <summary>
/// The function invoked if the server returns an error.
/// </summary>
public delegate void StatusFunction(Fault fault); /// <summary>
/// The Responder class provides an object that is used in NetConnection.call() to handle return values from the server related to the success or failure of specific operations.
/// When working with NetConnection.call(), you may encounter a network operation fault specific to the current operation or a fault related to the current connection status.
/// Operation errors target the Responder object instead of the NetConnection object for easier error handling.
/// </summary>
/// <typeparam name="T"></typeparam>
public class Responder<T>
{
private readonly ResultFunction<T> _result;
private readonly StatusFunction _status; /// <summary>
/// Initializes a new instance of the <see cref="Responder<T>"/> class.
/// You pass a Responder object to NetConnection.call() to handle return values from the server. You may pass null for either or both parameters.
/// </summary>
/// <param name="result">The function invoked if the call to the server succeeds and returns a result.</param>
public Responder(ResultFunction<T> result)
: this(result, null)
{
} /// <summary>
/// Initializes a new instance of the <see cref="Responder<T>"/> class.
/// You pass a Responder object to NetConnection.call() to handle return values from the server. You may pass null for either or both parameters.
/// </summary>
/// <param name="result">The function invoked if the call to the server succeeds and returns a result.</param>
/// <param name="status">The function invoked if the server returns an error.</param>
public Responder(ResultFunction<T> result, StatusFunction status)
{
_result = result;
_status = status;
} /// <summary>
/// Gets the function invoked if the call to the server succeeds and returns a result.
/// </summary>
/// <value>The result function.</value>
public ResultFunction<T> Result
{
get { return _result; }
} /// <summary>
/// Gets the function invoked if the server returns an error.
/// </summary>
/// <value>The status function.</value>
public StatusFunction Status
{
get { return _status; }
}
}
解决方案 »
- WPF如何实现控件随着窗体的拉伸而拉伸?
- winform程序在部分XP系统中用回车跳转光标程序没响应
- 求助,大数据串口通信的多线程方法
- net 如何调用java的一个类呢
- .build文件是什么东西?
- 【急】请问如何获得ListView控件选中图标的索引号?
- C# 打开程序、打开网页
- [送分]visio设计师版,那儿下载????
- 救命啊,为什么我安装vs.net的时候总是蓝屏死机?
- 有没有办法将arrayList之类的东西用typeConverter之类的办法转成enum?
- Tool ComboBox的问题
- 如何实现数据字典过滤:Dictionary<IWBTcpClient, WBUserInfo>
Responder<string> responder = new Responder<string>(CallBack);
void CallBack(Fault fault)
{
...
}
public Responder(ResultFunction<T> result)
: this(result, null)
{
}public Responder(ResultFunction<T> result, StatusFunction status)
{
_result = result;
_status = status;
}
谢谢。我改为:
Responder<object> responder = new Responder<object>(new ResultFunction<object>(CallBack));
编译提示:
错误 1 “CallBack”的重载均与委托“FluorineFx.Net.ResultFunction<object>”不匹配