嵌套的通用事件

时间:2009-06-18 14:07:12

标签: c# generics events delegates

我想要一个可以触发的通用事件,它将采用自定义eventArgs> ë

到目前为止,这是我的代码

public event resultsEventHandler<T> returnResults;

public delegate void resultsEventHandler<T>(object sender, resultEventArgs<ObservableEntityCollection<T>> e);


protected virtual void OnreturnResults(resultEventArgs<ObservableEntityCollection<T>> > e)
{
    if (returnResults != null)
    {
        returnResults<T>(this, e);
    }
}

public class resultEventArgs<ObservableEntityCollection<T>> : EventArgs
{
    private readonly ObservableEntityCollection<T> _results;
    public resultEventArgs(ObservableEntityCollection<T>  results)
    {
        this._results = results;
    }

    public ObservableEntityCollection<T>>  queryResult 
    { 
        get { return _results; } 
    }
}

1 个答案:

答案 0 :(得分:2)

不确定问题,但

public class resultEventArgs<ObservableEntityCollection<T>> : EventArgs

应该是

public class resultEventArgs<T> : EventArgs