public bool IsNull(object val) { if (val == null || val == DBNull.Value) { return(true); } // WARNING !!! // == comparison result does not match that of .Equals //bool BROKEN1 = NullValue != null && val == NullValue && val.GetType() == NullValue.GetType(); //bool BROKEN2 = NullValue != null && NullValue == val && val.GetType() == NullValue.GetType(); bool WORKS1 = NullValue != null && NullValue.Equals(val) && val.GetType() == NullValue.GetType(); //bool WORKS2 = NullValue != null && val.Equals( NullValue ) && val.GetType() == NullValue.GetType(); bool isSameValue = IsValueType && val.Equals(NullValue); return(WORKS1 || isSameValue); }
/// <summary> /// Gets the specified cacheKey async. /// </summary> /// <returns>The async.</returns> /// <param name="cacheKey">Cache key.</param> /// <typeparam name="T">The 1st type parameter.</typeparam> public override async Task <CacheValue <T> > BaseGetAsync <T>(string cacheKey) { ArgumentCheck.NotNullOrWhiteSpace(cacheKey, nameof(cacheKey)); var result = await _memcachedClient.GetAsync <object>(this.HandleCacheKey(cacheKey)); if (result.Success) { OnCacheHit(cacheKey); return(NullValue.Equals(result.Value) ? CacheValue <T> .Null : new CacheValue <T>((T)result.Value, true)); } else { OnCacheMiss(cacheKey); return(CacheValue <T> .NoValue); } }