这是否接口标准.NET库中已经存在? [英] Does this interface already exist in the standard .NET libraries?

查看:88
本文介绍了这是否接口标准.NET库中已经存在?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现自己需要一个简单的通用接口,而我写的,但它竟然是pretty的许多世界上最简单的接口。我想知道,如果它已经存在一些其他的名字。我只是想确保我不会重新发明的东西,已经包含在.NET框架。

I found myself needing a simple generic interface, and I wrote it, but it turned out to be pretty much the world's simplest interface. I was wondering if it already exists by some other name. I just want to make sure I'm not reinventing something that is already included with the .NET framework.

interface IReceiver<T>
{
   void Receive(T obj);
}

我实在无法找到随.NET标准接口,一个良好的名单。这是否接口的结构很熟悉的人?我有没有改造的东西,已经是标准的?

I can't really find a good list of "standard" interfaces that came with .NET. Does the structure of this interface look familiar to anyone? Have I reinvented something that is already standard?

编辑:我有一个数据对象和一些对收到的数据对象。对象对收到的数据实现接口,以便路由列表和映射可以将数据发送给他们。我们的想法是完全泛化路由,路由将是数据驱动的。

I have a data object and a number of objects interested in receiving the data. Objects interested in receiving the data implement the interface, so that 'routing' lists and maps can send the data to them. The idea is full generalization in the routing, the routing will be data-driven.

推荐答案

嗯,这听起来像是动作&LT; T&GT; 委托类型......我不知道任何的接口的等价的副手,但可能你只需要使用代理呢?

Well, it sounds like the Action<T> delegate type... I don't know of any interface equivalent off-hand, but could you just use the delegate instead?

编辑:好的,如果你需要的各种类实际上实现它,那么我只是把它作为一个新的接口......特别是如果你可以给它一个稍微更有意义的名称和描述不是 IReceiver

Okay, if you need to make the various classes actually implement it, then I'd just leave it as a new interface... especially if you can give it a slightly more meaningful name and description than IReceiver.

这篇关于这是否接口标准.NET库中已经存在?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆