private RegisteredSubProvider GetRegisteredCommands(IContextMenuCommandProvider subProvider) { // note that our dictionary uses the type of "subProvider", not the instance // this is really important for 2 reasons: // * we don't want to hold a reference to the instance of subProvider // * multiple objects of the same type can share the same subProvider // // But it means that we're expecting subProvider.GetCommands to return the // same results for *any* instance of that type. In other words, that method // should act like a static method. RegisteredSubProvider result; if (m_subProviders.TryGetValue(subProvider.GetType(), out result)) { return(result); } result = new RegisteredSubProvider(subProvider, CommandService, this); m_subProviders.Add(subProvider.GetType(), result); return(result); }
public RegisteredSubProvider( IContextMenuCommandProvider subProvider, ICommandService commandService, ICommandClient client) { m_commands = subProvider.GetCommands(null, null); foreach (var c in m_commands) { var description = GetAnnotatedDescription(c).Localize(); commandService.RegisterCommand( c, StandardMenu.File, CustomCommandGroups.NodeSpecific, description, description, Sce.Atf.Input.Keys.None, null, CommandVisibility.ContextMenu, client); } }
private RegisteredSubProvider GetRegisteredCommands(IContextMenuCommandProvider subProvider) { // note that our dictionary uses the type of "subProvider", not the instance // this is really important for 2 reasons: // * we don't want to hold a reference to the instance of subProvider // * multiple objects of the same type can share the same subProvider // // But it means that we're expecting subProvider.GetCommands to return the // same results for *any* instance of that type. In other words, that method // should act like a static method. RegisteredSubProvider result; if (m_subProviders.TryGetValue(subProvider.GetType(), out result)) return result; result = new RegisteredSubProvider(subProvider, CommandService, this); m_subProviders.Add(subProvider.GetType(), result); return result; }