using System; using System.Collections.Generic; using System.Text; using System.Collections; namespace AsterNET.Manager.Event { public abstract class AbstractAgentVariables : ManagerEvent { private Dictionary variables; public AbstractAgentVariables(ManagerConnection source) : base(source) { } #region Variable /// /// Get/Set the variables to set on the queue call in native asterisk format.
/// Example: "VAR1=abc|VAR2=def". ///
public string Variable { get { return Helper.JoinVariables(variables, Common.VAR_DELIMITER, "="); } set { variables = Helper.ParseVariables(variables, value, Common.VAR_DELIMITER); } } #endregion #region GetVariables() /// /// Get the variables dictionary to set on the originated call. /// public IDictionary GetVariables() { return variables; } #endregion #region SetVariables(IDictionary vars) /// /// Set the variables dictionary to set on the originated call. /// public void SetVariables(Dictionary vars) { this.variables = vars; } #endregion #region SetVariable(string name, string val) /// /// Sets a variable dictionary on the originated call. Replaces any existing variable with the same name. /// public void SetVariable(string key, string val) { if (variables == null) variables = new Dictionary(); if (variables.ContainsKey(key)) variables[key] = val; else variables.Add(key, val); } #endregion #region GetVariable(string name) /// /// Gets a variable on the originated call. Replaces any existing variable with the same name. /// public string GetVariable(string key) { if (variables == null) return string.Empty; return variables[key]; } #endregion } }