Exemplo n.º 1
0
        public static void RegisterProperty(PropertyInfo property, HardWordAttribute attr = null)
        {
            var hw = attr ?? new HardWordAttribute();

            if (!RegisteredProperties.ContainsKey(property))
            {
                RegisteredProperties.Add(property, hw);
            }
            if (AttributeCaches.ContainsKey(property))
            {
                AttributeCaches[property] = hw;
            }
        }
Exemplo n.º 2
0
        public static HardWordAttribute GetHardWordAttribute(PropertyInfo property)
        {
            HardWordAttribute attr = null;

            if (property != null && !AttributeCaches.TryGetValue(property, out attr))
            {
                attr = property.GetCustomAttributes(typeof(HardWordAttribute), false).FirstOrDefault() as HardWordAttribute;
                if (attr == null)
                {
                    RegisteredProperties.TryGetValue(property, out attr);
                }
                AttributeCaches.AddOrUpdate(property, attr, (k, v) => attr);
            }
            return(attr);
        }
Exemplo n.º 3
0
        public static void RegisterProperty <T>(Expression <Func <T, object> > propertySelector, HardWordAttribute attr = null)
        {
            var property = GetPropertyInfoFromExpression(propertySelector);

            RegisterProperty(property, attr);
        }