public void Ctor_Bool(bool listBindable) { var attribute = new ListBindableAttribute(listBindable); Assert.Equal(listBindable, attribute.ListBindable); Assert.Equal(listBindable, attribute.IsDefaultAttribute()); }
public void Ctor_BindableSupport(BindableSupport support, bool expectedBindable) { var attribute = new ListBindableAttribute(support); Assert.Equal(expectedBindable, attribute.ListBindable); Assert.Equal(expectedBindable || support == BindableSupport.Default, attribute.IsDefaultAttribute()); }
public void No_Get_ReturnsExpected() { ListBindableAttribute attribute = ListBindableAttribute.No; Assert.Same(attribute, ListBindableAttribute.No); Assert.False(attribute.ListBindable); Assert.False(attribute.IsDefaultAttribute()); }
public void Yes_Get_ReturnsExpected() { ListBindableAttribute attribute = ListBindableAttribute.Yes; Assert.Same(attribute, ListBindableAttribute.Yes); Assert.True(attribute.ListBindable); Assert.True(attribute.IsDefaultAttribute()); }
// Determine if two attribute values are equal. public override bool Equals(Object obj) { ListBindableAttribute other = (obj as ListBindableAttribute); if (other != null) { return(flags == other.flags); } else { return(false); } }
public static bool GetEnumListBindable <TEnum>(TEnum value) { var fi = value.GetType().GetField(value.ToString()); var attributes = new ListBindableAttribute[] { }; if (fi != null) { attributes = (ListBindableAttribute[])fi.GetCustomAttributes(typeof(ListBindableAttribute), false); } //return true by default return((attributes.Length > 0) ? attributes[0].ListBindable : true); }
public static IEnumerable <object[]> Equals_TestData() { var attribute = new ListBindableAttribute(BindableSupport.Yes); yield return(new object[] { attribute, attribute, true }); yield return(new object[] { attribute, new ListBindableAttribute(BindableSupport.Yes), true }); yield return(new object[] { attribute, new ListBindableAttribute(BindableSupport.No), false }); yield return(new object[] { attribute, new object(), false }); yield return(new object[] { attribute, null, false }); }
public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { StandardValuesCollection listSources = base.GetStandardValues(context); StandardValuesCollection lists = listConverter.GetStandardValues(context); ArrayList listsList = new ArrayList(); foreach (object listSource in listSources) { if (listSource != null) { // bug 46563: work around the TableMappings property on the OleDbDataAdapter ListBindableAttribute listBindable = (ListBindableAttribute)TypeDescriptor.GetAttributes(listSource)[typeof(ListBindableAttribute)]; if (listBindable != null && !listBindable.ListBindable) { continue; } listsList.Add(listSource); } } foreach (object list in lists) { if (list != null) { // bug 46563: work around the TableMappings property on the OleDbDataAdapter ListBindableAttribute listBindable = (ListBindableAttribute)TypeDescriptor.GetAttributes(list)[typeof(ListBindableAttribute)]; if (listBindable != null && !listBindable.ListBindable) { continue; } listsList.Add(list); } } // bug 71417: add a null list to reset the dataSource listsList.Add(null); return(new StandardValuesCollection(listsList)); }
protected void FillDataMembers(BindingContext bindingManager, object dataSource, string dataMember, string propertyName, bool isList, TreeNodeCollection nodes, int depth) { if (depth > MaximumDepth) { return; } if (!isList && selectLists) { return; } DataMemberNode dataMemberNode = new DataMemberNode(dataMember, propertyName, isList); nodes.Add(dataMemberNode); if (selectedItem != null && selectedItem.Equals(dataSource, dataMember)) { selectedNode = dataMemberNode; } if (isList) { CurrencyManager listManager = (CurrencyManager)bindingManager[dataSource, dataMember]; PropertyDescriptorCollection properties = listManager.GetItemProperties(); for (int i = 0; i < properties.Count; i++) { ListBindableAttribute listBindable = (ListBindableAttribute)properties[i].Attributes[typeof(ListBindableAttribute)]; // if the attribute exists and it is false, then skip this property. // if (listBindable != null && !listBindable.ListBindable) { continue; } FillDataMembers(bindingManager, dataSource, dataMember + "." + properties[i].Name, properties[i].Name, typeof(IList).IsAssignableFrom(properties[i].PropertyType), dataMemberNode.Nodes, depth + 1); } } }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { ArrayList list = new ArrayList(base.GetStandardValues(context)); TypeConverter.StandardValuesCollection standardValues = this.listConverter.GetStandardValues(context); ArrayList values = new ArrayList(); BindingSource instance = context.Instance as BindingSource; foreach (object obj2 in list) { if (obj2 != null) { ListBindableAttribute attribute = (ListBindableAttribute)TypeDescriptor.GetAttributes(obj2)[typeof(ListBindableAttribute)]; if (((attribute == null) || attribute.ListBindable) && ((instance == null) || (instance != obj2))) { DataTable table = obj2 as DataTable; if ((table == null) || !list.Contains(table.DataSet)) { values.Add(obj2); } } } } foreach (object obj3 in standardValues) { if (obj3 != null) { ListBindableAttribute attribute2 = (ListBindableAttribute)TypeDescriptor.GetAttributes(obj3)[typeof(ListBindableAttribute)]; if (((attribute2 == null) || attribute2.ListBindable) && ((instance == null) || (instance != obj3))) { values.Add(obj3); } } } values.Add(null); return(new TypeConverter.StandardValuesCollection(values)); }
public void GetHashCode_InvokeMultipleTimes_ReturnsSame() { var attribute = new ListBindableAttribute(false); Assert.Equal(attribute.GetHashCode(), attribute.GetHashCode()); }
public void Equals_Object_ReturnsExpected(ListBindableAttribute attribute, object other, bool expected) { Assert.Equal(expected, attribute.Equals(other)); }