我有一份申请,我想在座标上。 因此,我想在简讯中具体指出一些信息类型,如“申请.msg.UpdateMsg”或“app.msg.SnapshotMsg”等,用以制造问题。
Say my message queue class looks like this:
public class MsgQueue<T> : where T: MsgBase, new()
{
private readonly Action<T> _queueListener;
public MsgQueue(Action<T> queueListener)
{
_queueListener = queueListener;
}
...
}
现在我要说的是,我还有另一类人想从座标的那几类人听起来,把他们放在集装箱内。 与此类似:
public class QueueManager
{
// We know T is a MsgBase, but not much else :(
private List<MsgQueue<MsgBase>> _msgQueues = new List<MsgQueue<MsgBase>>();
public QueueManager()
{
List<string> configuredQueueTypes = GetQueueTypesFromConfig();
PopulateMsgQueues(configuredQueueTypes);
}
private void PopulateMsgQueues(List<string> qTypes)
{
foreach (string qType in qTypes)
{
Action<MsgBase> listener = GetListener(qType);
// What goes here? How do I create a MsgQueue<qType>?
}
}
...
}
How do I define PopulateMsgQueues(), if that s even possible?
如果我能够在“评估”中具体指出“最新信息”等内容,这是否可行(而且会有所帮助)?
Does anyone know of any other way to instantiate a bunch of MsgQueue of T where T is specified by a string at runtime?
我用C# 4.0,这样,动态关键词会帮助我吗?
感谢!