public void SetAction(Component extendee, UIAction action) { if (!initializing) { if (extendee == null) throw new ArgumentNullException("extendee"); if (action != null && action.ActionList != this) throw new ArgumentException("The Action you selected is owned by another ActionList"); } if (targets.ContainsKey(extendee)) { targets[extendee].InternalRemoveTarget(extendee); targets.Remove(extendee); } if (action != null) { if (!typesDescription.ContainsKey(extendee.GetType())) typesDescription.Add( extendee.GetType(), new UIActionTargetDescriptor(extendee.GetType())); targets.Add(extendee, action); action.InternalAddTarget(extendee); } }
public void SetAction(Component extendee, UIAction action) { // There may be a problem: an action can be set to an extendee before it is part // of the manager actions list... // So we add it here to the collection (if it doesn't exist) // This means each action will probably be added twice to the collection. // This is not really an issue as the UIActionCollection checks for duplicates // before adding actions. if (!actionsManager.Actions.Contains(action)) actionsManager.Actions.Add(action); actionsManager.SetAction(extendee, action); }