Пример #1
0
        public bool TryGetValue(TKey key, out TValue value)
        {
            object result;

            if (values.TryGetValue(getStringKey(key), out result))
            {
                value = (dynamic)result;
                return(true);
            }

            value = DefaultValue;
            return(false);
        }
Пример #2
0
        public bool TryGetValue(TKey key, out TValue value)
        {
            object result;

            if (values.TryGetValue(key, out result))
            {
                value = (TValue)result;
                return(true);
            }

            if (resolveValue != null)
            {
                value = resolveValue(key);
                values.Add(key, value);
                return(true);
            }

            if (unsetValues.Contains(key))
            {
                value = DefaultValue;
                return(false);
            }

            if (tryResolveValue(key, out value))
            {
                values.Add(key, value);
                return(true);
            }

            unsetValues.Add(key);
            value = DefaultValue;
            return(false);
        }
Пример #3
0
        public static object GetValue(this IMinimalDictionary minimalDictionary, object key)
        {
            object value;

            if (minimalDictionary.TryGetValue(key, out value))
            {
                return(value);
            }

            throw new Granular.Exception("The given key was not present in the dictionary.");
        }
Пример #4
0
        public static TValue GetValue <TKey, TValue>(this IMinimalDictionary <TKey, TValue> minimalDictionary, TKey key)
        {
            TValue value;

            if (minimalDictionary.TryGetValue(key, out value))
            {
                return(value);
            }

            throw new Granular.Exception("The given key was not present in the dictionary.");
        }