static string Replace(string tag, IStringTagModel customTags) { string tname, tformat; int n = tag.IndexOf(':'); if (n != -1) { tname = tag.Substring(0, n); tformat = tag.Substring(n + 1); } else { tname = tag; tformat = string.Empty; } tname = tname.ToUpperInvariant(); object val = customTags.GetValue(tname); if (val != null) { return(FormatValue(val, tformat)); } if (properties.ContainsKey(tname)) { return(FormatValue(properties [tname], tformat)); } GenerateString genString; if (stringGenerators.TryGetValue(tname, out genString)) { return(genString(tname, tformat)); } if (tformat.Length > 0) { switch (tname) { case "ENV": foreach (DictionaryEntry variable in Environment.GetEnvironmentVariables()) { if (string.Equals(variable.Key.ToString(), tformat, StringComparison.OrdinalIgnoreCase)) { return(variable.Value.ToString()); } } break; case "PROPERTY": return(PropertyService.Get <string> (tformat)); } } return(null); }
public object GetValue(string name) { string val; if (OverrideTags.TryGetValue(name, out val)) { return(val); } return(BaseModel != null?BaseModel.GetValue(name) : null); }
bool IsConditionTrue(IStringTagModel parameters) { string value = parameters.GetValue(Condition.ParameterName) as string; if (value != null) { return(String.Equals(value, Condition.ParameterValue, StringComparison.OrdinalIgnoreCase)); } return(false); }
public static bool GetBoolValue(this IStringTagModel model, string name, bool defaultValue = false) { object value = model.GetValue(name); if (value is bool) { return((bool)value); } var stringValue = value as string; if (!string.IsNullOrEmpty(stringValue)) { bool result; if (bool.TryParse(stringValue, out result)) { return(result); } } return(defaultValue); }
bool IsConditionTrue (IStringTagModel parameters) { string value = parameters.GetValue (Condition.ParameterName) as string; if (value != null) { return String.Equals (value, Condition.ParameterValue, StringComparison.OrdinalIgnoreCase); } return false; }
public string this[string key] { get { var val = tags.GetValue(key); return(val != null?val.ToString() : null); } }