public object GetVariable(string key, bool checkGlobal = false) { key = PipelineCommandParser.NormalizeVariableName(key); // See important comment at declaration above var variableRetrievingEvents = new VariableEventArgs(this, key); OnVariableRetrieving(variableRetrievingEvents); key = variableRetrievingEvents.Key; if (!variables.ContainsKey(key)) { if (checkGlobal) { if (IsSetGlobally(key)) { return(GetGlobalVariable(key)); } } throw new DeninaException(string.Format("Attempt to access non-existent variable: \"{0}\"", key)); } var value = variables[PipelineCommandParser.NormalizeVariableName(key)].Value; // See important comment at declaration above var variableRetrievedEvents = new VariableEventArgs(this, key, value); OnVariableRetrieved(variableRetrievedEvents); value = variableRetrievedEvents.Value; return(value ?? string.Empty); }
private void OnVariableRetrieved(VariableEventArgs e) => VariableRetrieved?.Invoke(this, e);