value = default(TValue);
return false;
}
-
- // Method similar to TryGetValue that returns the value instead of putting it in an out param.
- public TValue GetValueOrDefault(TKey key) => GetValueOrDefault(key, default(TValue));
-
- // Method similar to TryGetValue that returns the value instead of putting it in an out param. If the entry
- // doesn't exist, returns the defaultValue instead.
- public TValue GetValueOrDefault(TKey key, TValue defaultValue)
- {
- int i = FindEntry(key);
- if (i >= 0)
- {
- return entries[i].value;
- }
- return defaultValue;
- }
-
public bool TryAdd(TKey key, TValue value) => TryInsert(key, value, InsertionBehavior.None);
bool ICollection<KeyValuePair<TKey, TValue>>.IsReadOnly
count = 0;
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
+ if (!all && !s_pca.ContainsKey(caType) && !IsSecurityAttribute(caType))
return Array.Empty<Attribute>();
List<Attribute> pcas = new List<Attribute>();
internal static bool IsDefined(RuntimeType type, RuntimeType caType)
{
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
+ if (!all && !s_pca.ContainsKey(caType) && !IsSecurityAttribute(caType))
return false;
if (all || caType == (RuntimeType)typeof(SerializableAttribute))
count = 0;
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
+ if (!all && !s_pca.ContainsKey(caType) && !IsSecurityAttribute(caType))
return Array.Empty<Attribute>();
List<Attribute> pcas = new List<Attribute>();
internal static bool IsDefined(RuntimeMethodInfo method, RuntimeType caType)
{
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null)
+ if (!all && !s_pca.ContainsKey(caType))
return false;
if (all || caType == (RuntimeType)typeof(DllImportAttribute))
count = 0;
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null)
+ if (!all && !s_pca.ContainsKey(caType))
return null;
Attribute[] pcas = new Attribute[s_pcasCount];
internal static bool IsDefined(RuntimeParameterInfo parameter, RuntimeType caType)
{
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null)
+ if (!all && !s_pca.ContainsKey(caType))
return false;
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
+ if (!all && !s_pca.ContainsKey(caType) && !IsSecurityAttribute(caType))
return Array.Empty<Attribute>();
List<Attribute> pcas = new List<Attribute>();
count = 0;
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null)
+ if (!all && !s_pca.ContainsKey(caType))
return null;
Attribute[] pcas = new Attribute[s_pcasCount];
internal static bool IsDefined(RuntimeFieldInfo field, RuntimeType caType)
{
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null)
+ if (!all && !s_pca.ContainsKey(caType))
return false;
if (all || caType == (RuntimeType)typeof(MarshalAsAttribute))
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null && !IsSecurityAttribute(caType))
+ if (!all && !s_pca.ContainsKey(caType) && !IsSecurityAttribute(caType))
return Array.Empty<Attribute>();
List<Attribute> pcas = new List<Attribute>();
{
bool all = caType == (RuntimeType)typeof(object) || caType == (RuntimeType)typeof(Attribute);
- if (!all && s_pca.GetValueOrDefault(caType) == null)
+ if (!all && !s_pca.ContainsKey(caType))
return false;
if (all || IsSecurityAttribute(caType))