/// <summary> /// Sets the action context. /// </summary> /// <param name="parameter">The parameter.</param> private void SetActionContext(object parameter) { _action.ActionContext.Clear(); foreach (var entry in _entries) { _action.ActionContext.Add(entry); } if (parameter == null) { return; } var parameterEntry = ActionContextEntry.Create(RoutedAction.CommandParameter, parameter, false); _action.ActionContext.Add(parameterEntry); }
/// <summary> /// Adds the passed value into the action context. /// If the instance does not implement ICloneable, a clone will be made through serializing. (and thus the Serializable attribute is needed!) /// </summary> /// <param name="entry">The entry.</param> /// <returns> /// Itself. /// </returns> /// <exception cref="ArgumentException">Throws an exception in case the type is not serializable and ICloneable is not implemented.</exception> public ActionContext Add(ActionContextEntry entry) { _context.Add(entry.Key, entry.Value); return(this); }
/// <summary> /// Gets the entries. /// </summary> /// <returns></returns> public IEnumerable <ActionContextEntry> GetEntries() { return(_context.Select(x => ActionContextEntry.Create(x.Key, x.Value, false)).ToList().AsReadOnly()); }