Esempio n. 1
0
        public static bool ItemsUnitializedValue <T>(IList <T> list)
        {
            ValidationUtils.ArgumentNotNull(list, "list");
            Type collectionItemType = ReflectionUtils.GetCollectionItemType(list.GetType());

            if (!collectionItemType.IsValueType)
            {
                if (!collectionItemType.IsClass)
                {
                    throw new Exception("Type {0} is neither a ValueType or a Class.".FormatWith(CultureInfo.InvariantCulture, new object[] { collectionItemType }));
                }
                for (int i = 0; i < list.Count; i++)
                {
                    if (list[i] != null)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                object obj = ReflectionUtils.CreateUnitializedValue(collectionItemType);
                for (int j = 0; j < list.Count; j++)
                {
                    if (!list[j].Equals(obj))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Esempio n. 2
0
 public static bool IsUnitializedValue(object value)
 {
     if (value == null)
     {
         return(true);
     }
     return(value.Equals(ReflectionUtils.CreateUnitializedValue(value.GetType())));
 }