public bool AddVariable(Variable variable)
 {
     return InternalAddVariable(variable);
 }
 private bool InternalAddVariable(Variable variable, bool force = true)
 {
     if (_globals.ContainsKey(variable.Name))
     {
         if (force)
         {
             _globals.Remove(variable.Name);
         }
         else
         {
             _result.Scenario.Log("Variable " + variable.Name + "already exists. Cannot add new variable.", LogCategory.Warn, LogPriority.Low);
         }
     }
     _globals.Add(variable.Name, variable);
     return true;
 }
Esempio n. 3
0
 private void FinalizeRun()
 {
     //Reflect the property and store the value
     foreach (PostRunPairs p in PostValues.Where(f => !string.IsNullOrEmpty(f.VariableName)))
     {
         PropertyInfo property = this.GetType().GetProperties().First(prop => prop.IsDefined(typeof(PostRunAttribute), false) && prop.Name.Equals(p.PropertyName));
         if (property != null)
         {
             try
             {
                 Object val = property.GetValue(this, null);
                 if (val != null)
                 {
                     Variable v = new Variable(p.VariableName, val);
                     this.Runner.AddVariable(v);
                     this.Log(v.ToString(), LogCategory.Info, LogPriority.None);
                 }
             }
             catch (Exception ex)
             {
                 this.Log(ex.Message, LogCategory.Exception, LogPriority.High);
                 this.Log(ex.StackTrace, LogCategory.Exception, LogPriority.High);
             }
         }
     }
 }