当前位置: 首页>>代码示例>>C#>>正文


C# Mediator.HasReceiver方法代码示例

本文整理汇总了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;
        }
开发者ID:sillsdev,项目名称:CarlaLegacy,代码行数:36,代码来源:Choice.cs


注:本文中的XCore.Mediator.HasReceiver方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。