protected void ManageCollectionStatus() { IsACollection = BindingType.GetInterfaces().Any(i => i.IsGenericType && i.GetGenericTypeDefinition() == typeof(ICollection <>)); if (IsACollection) { if (BindingType.IsArray) { CollectionType = BindingType; BindingType = BindingType.GetElementType(); } else { Type[] types = BindingType.GetGenericArguments(); if (types == null || types.Count() != 1) { throw new BindingTemplateException($"'{BindingType.FullName}': Only collection with one generic argument are taken into account."); } CollectionType = BindingType; BindingType = types[0]; } } }
protected void ManageEnumAndNullable() { IsNullable = BindingType.IsGenericType && BindingType.GetGenericTypeDefinition() == typeof(Nullable <>); IsEnum = BindingType.IsGenericType ? BindingType.GetGenericArguments()[0].IsEnum : BindingType.IsEnum; }