我有一個MSGCLASS這樣看我所有的appMessages(使用MVVM光使者)MVVM光 - 消息(VS「標籤友好」類)
public static class AppMessages
{
enum MessageTypes
{
changeStateMsg,
inputMsg
}
public class MsgBase
{
public static void unRegister(object recipient)
{
Messenger.Default.Unregister<bool>(recipient);
}
}
public static class changeState : MsgBase
{
public static void Send(bool stateChange)
{
Messenger.Default.Send<bool>(stateChange, MessageTypes.changeStateMsg);
}
public static void Register(object recipient, Action<bool> action)
{
Messenger.Default.Register<bool>(recipient, MessageTypes.changeStateMsg, action);
}
}
public static class inputMsg : MsgBase
{
public static void Send(string key)
{
Messenger.Default.Send<string>(key, MessageTypes.inputMsg);
}
public static void Register(object recipient, Action<string> action)
{
Messenger.Default.Register<string>(recipient, MessageTypes.inputMsg, action);
}
}
}
只是遊蕩,如果有可能,使其更VS標籤友好的我'registrating這樣的:
AppMessages.changeState.Register(this, onStateChange);
我的問題是我怎麼可以讓它自動生成onStateChange方法(只rightClicking讓我能夠做出一個屬性/字段)
所以它是一個「懶惰的問題:」我知道我應該只寫:
public void onStateChange(bool b)
{
}
但是如果你們知道如何自動生成它?我很高興:)
/乾杯