Mam następujące klasysłownik z delegatem jako wartość
public class CVisitor : IVisitor
{
public int Visit(Heartbeat element)
{
Trace.WriteLine("Heartbeat");
return 1;
}
public int Visit(Information element)
{
Trace.WriteLine("Information");
return 1;
}
}
chcę mieć słownik z odwzorowań, że każdy typ argumentu będą mapowane do jego funkcja realizacja: Heartbeat zostaną odwzorowane na public int Visit(Heartbeat element)
Pomyślałem, aby zrobić coś takiego:
_messageMapper = new Dictionary<Type, "what should be here ?" >();
_messageMapper.Add(typeof(Heartbeat), "and how I put it here?");
co powinienem zamiast tego wpisać "co powinno tu być?" i "i jak to tutaj umieściłem?"
Dzięki
Jak wyglądają twoje metody (tzn. Czy są podobne w definicji?) –
może, możesz stworzyć swoje metody jako Delegatów, a Twoja TValue w Słowniku będzie System.Delegate .. czy próbowałeś tego? –
@Yet Another Geek, funkcja Visitor ma zupełnie inną implementację, są to maperzy DTO: –