Confuser.Core/Annotations.cs
/// <summary>
///     Retrieves the annotation on the specified object associated with the specified key.
/// </summary>
/// <typeparam name="TValue">The type of the value.</typeparam>
/// <param name="obj">The object.</param>
/// <param name="key">The key of annotation.</param>
/// <param name="defValueFactory">The default value factory function.</param>
/// <returns>The value of annotation, or default value if the annotation does not exist.</returns>
/// <exception cref="T:System.ArgumentNullException">
///     <paramref name="obj" /> or <paramref name="key" /> is <c>null</c>.
/// </exception>
// Token: 0x06000002 RID: 2 RVA: 0x00002154 File Offset: 0x00000354
Retrieves the annotation on the specified object associated with the specified key.
Retrieves the annotation on the specified object associated with the specified key .
public TValue GetLazy<TValue>(object obj, object key, Func<object, TValue> defValueFactory)
		{
			if (obj == null)
			{
				throw new ArgumentNullException("obj");
			}
			if (key == null)
			{
				throw new ArgumentNullException("key");
			}
			ListDictionary objAnno;
			if (!this.annotations.TryGetValue(obj, out objAnno))
			{
				return defValueFactory(key);
			}
			if (!objAnno.Contains(key))
			{
				return defValueFactory(key);
			}
			Type valueType = typeof(TValue);
			if (valueType.IsValueType)
			{
				return (TValue)((object)Convert.ChangeType(objAnno[key], typeof(TValue)));
			}
			return (TValue)((object)objAnno[key]);
		}
public TValue GetLazy < TValue > ( object obj , object key , Func < object , TValue > defValueFactory ) { if ( obj == null ) { throw new ArgumentNullException ( " " ) ; } if ( key == null ) { throw new ArgumentNullException ( " " ) ; } ListDictionary objAnno ; if ( ! this . annotations . TryGetValue ( obj , out objAnno ) ) { return defValueFactory ( key ) ; } if ( ! objAnno . Contains ( key ) ) { return defValueFactory ( key ) ; } Type valueType = typeof ( TValue ) ; if ( valueType . IsValueType ) { return ( TValue ) ( ( object ) Convert . ChangeType ( objAnno [ key ] , typeof ( TValue ) ) ) ; } return ( TValue ) ( ( object ) objAnno [ key ] ) ; }
Retrieves the annotation on the specified object associated with the specified key.
Retrieves the annotation on the specified object associated with the specified key .
The value of annotation, or default value if the annotation does not exist.
The value of annotation or default value if the annotation does not exist .
None
obj
object
None
key
object
The key of annotation.
The key of annotation .
defValueFactory
Func<object, TValue>
The default value factory function.
The default value factory function .
typeparam
The type of the value.
The type of the value .