public override bool Equals(object obj) { if (!(obj is ShouldSerializeKey)) { return(false); } ShouldSerializeKey other = (ShouldSerializeKey)obj; return(other._type == _type && other._propertyName == _propertyName); }
private static void CacheShouldSerializeMethod(ShouldSerializeKey key, MethodInfo methodInfo) { // The instance stored in _shouldSerializeCacheLock is used as a sentinal for null // The avoids having to perform two lookups in the Hashtable to detect a cached null value. object value = methodInfo == null ? _shouldSerializeCacheLock : methodInfo; lock (_shouldSerializeCacheLock) { _shouldSerializeCache[key] = value; } }
private static bool TryGetShouldSerializeMethod(ShouldSerializeKey key, out MethodInfo methodInfo) { object value = _shouldSerializeCache[key]; if (value == null || value == _shouldSerializeCacheLock) { // The _shouldSerializeCacheLock is used as a sentinal for null methodInfo = null; return(value != null); } else { methodInfo = value as MethodInfo; return(true); } }
private static bool TryGetShouldSerializeMethod(ShouldSerializeKey key, out MethodInfo methodInfo) { object value = _shouldSerializeCache[key]; if (value == null || value == _shouldSerializeCacheLock) { // The _shouldSerializeCacheLock is used as a sentinal for null methodInfo = null; return value != null; } else { methodInfo = value as MethodInfo; return true; } }