Exemplo n.º 1
0
 public bool Equals(HandlePair <T, U> other)
 {
     if (other.first.Equals((object)this.first))
     {
         return(other.second.Equals((object)this.second));
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 2
0
        public static T GetFirstAttribute <T>(FieldInfo fieldInfo) where T : Attribute, new()
        {
            Type second = typeof(T);
            HandlePair <FieldInfo, Type> key = new HandlePair <FieldInfo, Type>(fieldInfo, second);
            Attribute attribute;

            lock (ReflectionHelper.fieldAttributeCache)
            {
                if (!ReflectionHelper.fieldAttributeCache.TryGetValue(key, out attribute))
                {
                    ReflectionHelper.fieldAttributeCache.Add(key, attribute = (Attribute)Enumerable.FirstOrDefault <object>((IEnumerable <object>)fieldInfo.GetCustomAttributes(typeof(T), false)));
                }
            }
            return(attribute as T);
        }