Exemple #1
0
        public bool TryGetProperty <T>(string key, out T value)
        {
            if (IntegerProperties.TryGetValue(key, out var val))
            {
                value = (T)Convert.ChangeType(val, typeof(T));
                return(true);
            }

            if (StringProperties.TryGetValue(key, out var stringVal))
            {
                value = (T)TypeDescriptor.GetConverter(typeof(T)).ConvertFrom(stringVal);
                return(true);
            }

            value = default;
            return(false);
        }
Exemple #2
0
 public bool TryGetProperty(string key, out string value)
 {
     return(StringProperties.TryGetValue(key, out value));
 }