示例#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);
        }
示例#2
0
 public bool TryGetProperty(string key, out long value)
 {
     return(IntegerProperties.TryGetValue(key, out value));
 }