Ejemplo n.º 1
0
        protected IDictionary <object, object> FieldNameAsKeyFormat(object field, object fieldValue, Action <FluentDictionary <object, object> > moreProperties = null)
        {
            var dict = new FluentDictionary <object, object> {
                { field, fieldValue },
            };

            if (moreProperties != null)
            {
                moreProperties(dict);
            }

            var fb = (IFilter)this;

            if (fb.Cache.HasValue)
            {
                dict.Add("_cache", fb.Cache);
            }
            if (!fb.FilterName.IsNullOrEmpty())
            {
                dict.Add("_name", fb.FilterName);
            }
            if (!fb.CacheKey.IsNullOrEmpty())
            {
                dict.Add("_cache_key", fb.CacheKey);
            }
            return(dict);
        }
 internal static FluentDictionary <TKey, TValue> AddOrUpdate <TKey, TValue>(this FluentDictionary <TKey, TValue> dictionary, TKey key, TValue value, Predicate <TValue> predicate = null)
 {
     if (predicate?.Invoke(value) ?? true)
     {
         if (dictionary.ContainsKey(key))
         {
             dictionary[key] = value;
         }
         dictionary.Add(key, value);
     }
     return(dictionary);
 }