本文整理汇总了C#中XCore.Mediator.HasReceiver方法的典型用法代码示例。如果您正苦于以下问题:C# Mediator.HasReceiver方法的具体用法?C# Mediator.HasReceiver怎么用?C# Mediator.HasReceiver使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XCore.Mediator
的用法示例。
在下文中一共展示了Mediator.HasReceiver方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: QueryDisplayProperties
/// <summary>
///
/// </summary>
/// <param name="group">This provides more context for colleagues to know whether to add a command to a menu.
/// colleagues who want to support short-cut keys should be able to handle <c>null</c>, apart from a context menu group.</param>
/// <param name="mediator"></param>
/// <param name="command"></param>
/// <param name="defaultVisible"></param>
/// <param name="label"></param>
/// <returns></returns>
private static UIItemDisplayProperties QueryDisplayProperties(ChoiceGroup group, Mediator mediator, Command command, bool defaultVisible, string label)
{
// Let the default be that it is enabled if we know that it has
//at least one potential receiver, based on the method signatures of the
//current set of colleagues.
//If one of those colleagues thinks that it should be disabled at the moment,
//then it needs to implement the corresponding Display method
//and disable it from there.
bool hasReceiver = mediator.HasReceiver(command.MessageString);
UIItemDisplayProperties display = new UIItemDisplayProperties(group, label, hasReceiver, command.IconName, defaultVisible);
//OK, this is a little non-obvious
//first we allow anyone who knows about this specific command to influence how it is displayed
//why was it this way? m_mediator.SendMessage("Display"+this.m_idOfCorrespondingCommand, CommandObject, ref display);
mediator.SendMessage("Display" + command.Id, command, ref display);
//but then, we also allow anyone who knows about this specific message that would be sent
//to control how it is displayed. What's the difference?
//Well, it is not uncommon for a single message, e.g. "InsertRecord", to be associated with
//multiple commands, e.g. "CmdInsertPersonRecord", "CmdInsertCompanyRecord".
//And in this case, there may not be any actual code which knows about one of these commands,
//instead the code may be written to just listen for the "InsertRecord" message and then act
//upon its arguments which, in this example, would cause it to either insert a person or a company.
mediator.SendMessage("Display" + command.MessageString, command, ref display);
return display;
}