/// <summary> /// Assigns a variable to the given context. /// </summary> /// <param name="context">The context, where to assign the variable to.</param> /// <param name="name">The name of the variable.</param> /// <param name="value">The value of the variable.</param> static void AssignVariable(ParseContext context, String name, Value value) { var e = new VariableEventArgs(name, value); if (value != null) { if (context._variables.ContainsKey(name)) { context._variables[name] = value; context.RaiseVariableChanged(e); } else { context._variables.Add(name, value); context.RaiseVariableCreated(e); } } else { if (context._variables.ContainsKey(name)) { context._variables.Remove(name); context.RaiseVariableRemoved(e); } } }
/// <summary> /// This is raised when a variable has been removed. /// </summary> /// <param name="e">The variable arguments.</param> internal void RaiseVariableRemoved(VariableEventArgs e) { if (VariableRemoved != null) { VariableRemoved(this, e); } }
/// <summary> /// This is raised when a variable has been removed. /// </summary> /// <param name="name">The name of the variable.</param> /// <param name="value">The value of the variable.</param> internal void RaiseVariableRemoved(string name, Value value) { if (OnVariableRemoved != null) { var args = new VariableEventArgs(name, value); OnVariableRemoved(this, args); } }
/// <summary> /// Clears the list of assigned variables. /// </summary> public ParseContext Clear() { foreach (var pair in _variables) { var e = new VariableEventArgs(pair.Key, pair.Value); RaiseVariableRemoved(e); } _variables.Clear(); return(this); }
/// <summary> /// Clears the list of assigned variables. /// </summary> public ParseContext Clear() { foreach (var pair in _variables) { var e = new VariableEventArgs(pair.Key, pair.Value); RaiseVariableRemoved(e); } _variables.Clear(); return this; }