public static JObject GetOptions(WPFViewHelper helper) { OptionCallback c = new OptionCallback(); helper.GetOptions(c); return(c.Options); }
/// <summary> /// Adds a <see cref="Switch"/> to the <see cref="OptionSet"/>. /// </summary> /// <param name="options"></param> /// <param name="prototype"></param> /// <param name="callback"></param> /// <param name="description"></param> /// <returns>The <see cref="Switch"/> associated with the <paramref name="options"/>.</returns> public static Switch AddSwitch(this OptionSet options, string prototype , OptionCallback callback, string description = null) { /* Switch and not a flag. Switch implies on or off, enabled or disabled, * whereas flag implies combinations, masking. */ var result = new Switch(); options.Add(prototype, description, () => { result.Enabled = true; callback?.Invoke(); }); // Return the near-future Switch instance. return(result); }
/// <inheritdoc /> internal KeyValueActionOption(string prototype, string description, OptionCallback <TKey, TValue> callback) : base(prototype, description, callback) { }
protected override OptionSet Add(OptionSet options, string prototype, string description, OptionCallback <TTarget> callback) => options.Add(prototype, description, callback);
/// <summary> /// Accumulates option values in a strongly-typed <see cref="VariableList{T}"/> with /// the <see cref="Option"/> to execute arbitrary code when arguments are parsed. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="options"></param> /// <param name="prototype"></param> /// <param name="callback">Allows execution of arbitrary code when an argument is parsed.</param> /// <param name="description"></param> /// <returns></returns> /// <returns>The VariableList associated with the OptionSet.</returns> internal static VariableList <T> AddVariableList <T>(this OptionSet options, string prototype, OptionCallback <T> callback, string description = null) { var result = new VariableList <T>(prototype); options.Add <T>(prototype, description, x => { result.InternalValues.Add(x); callback(x); }); // Return with the near-future Variable instance. return(result); }
/// <summary> /// Accumulates <typeparamref name="T"/> into a strongly-typed /// <see cref="VariableMatrix{T}"/>. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="options"></param> /// <param name="prototype"></param> /// <param name="callback"></param> /// <param name="description"></param> /// <returns>The <see cref="VariableMatrix{T}"/> associated with the /// <paramref name="options"/>.</returns> public static VariableMatrix <T> AddVariableMatrix <T>(this OptionSet options, string prototype, OptionCallback <string, T> callback, string description = null) { var result = new VariableMatrix <T>(prototype); options.Add <string, T>(prototype, description, (k, x) => { if (IsNullOrEmpty(k)) { throw new OptionException("Name not specified", prototype, null); } result.InternalMatrix.Add(k, x); callback?.Invoke(k, x); }); // Return with the near-future Variable instance. return(result); }
/// <inheritdoc /> internal ActionOption(string prototype, string description, OptionCallback <TTarget> callback) : base(prototype, description, callback) { }
/// <summary> /// Protected Constructor. /// </summary> /// <param name="prototype"></param> /// <param name="description"></param> /// <param name="callback"></param> /// <inheritdoc /> protected ActionOptionBase(string prototype, string description, OptionCallback <TTarget> callback) : base(prototype, description, callback) { }
/// <summary> /// Adds the <see cref="KeyValueActionOption{TKey,TValue}"/> corresponding with the /// arguments to the end of the Collection. /// </summary> /// <param name="prototype"></param> /// <param name="description"></param> /// <param name="callback"></param> /// <returns></returns> public OptionSet Add <TKey, TValue>(string prototype, string description, OptionCallback <TKey, TValue> callback) => Add(callback // ReSharper disable once ConvertClosureToMethodGroup , () => new KeyValueActionOption <TKey, TValue>(prototype, description, (k, v) => callback.Invoke(k, v)) );
/// <summary> /// Adds the <see cref="KeyValueActionOption{TKey,TValue}"/> corresponding with the /// arguments to the end of the Collection. /// </summary> /// <param name="prototype"></param> /// <param name="callback"></param> /// <returns></returns> public OptionSet Add <TKey, TValue>(string prototype, OptionCallback <TKey, TValue> callback) => Add(prototype, null, callback);
/// <summary> /// Adds the <see cref="KeyValueActionOption{TKey,TValue}"/> corresponding with the /// arguments to the end of the Collection. /// </summary> /// <param name="prototype"></param> /// <param name="description"></param> /// <param name="callback"></param> /// <returns></returns> public OptionSet Add(string prototype, string description, OptionCallback <string, string> callback) => Add <string, string>(prototype, description, callback);
/// <summary> /// Adds the <see cref="KeyValueActionOption{TKey,TValue}"/> corresponding with the /// arguments to the end of the Collection. /// </summary> /// <param name="prototype"></param> /// <param name="callback"></param> /// <returns></returns> public OptionSet Add(string prototype, OptionCallback <string, string> callback) => Add(prototype, null, callback);
/// <summary> /// Adds the <see cref="Option"/> corresponding with the arguments /// to the end of the Collection. /// </summary> /// <param name="prototype"></param> /// <param name="description"></param> /// <param name="callback"></param> /// <returns></returns> public OptionSet Add(string prototype, string description, OptionCallback callback) => Add(callback // ReSharper disable once ConvertClosureToMethodGroup , () => new SimpleActionOption(prototype, description, () => callback.Invoke()) );
protected override OptionSet Add(OptionSet options, string prototype, OptionCallback <TKey, TValue> callback) => options.Add(prototype, callback);
public void RaiseOptionChanged() { OptionCallback.Invoke(this); }
public static JObject GetOptions(WPFViewHelper helper) { OptionCallback c = new OptionCallback(); helper.GetOptions(c); return c.Options; }