public object CloneFromPropertyValues(IDictionary propertyValues) { DefaultableMulti cloned = (DefaultableMulti)Clone(); cloned.AssignFromPropertyValues(propertyValues); return(cloned); }
public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { DefaultableMulti defaultableMulti = (DefaultableMulti)value; var descriptor = TypeDescriptor.GetProperties(defaultableMulti.GetType(), attributes); PropertyDescriptor[] propertyDescriptors = descriptor.OfType <PropertyDescriptor>().ToArray(); PropertyDescriptorCollection result = new PropertyDescriptorCollection(propertyDescriptors, false); foreach (PropertyDescriptor prop in descriptor) { if (defaultableMulti.CanHideProperty(prop.Name)) { try { result.Remove(prop); } catch (Exception e) { Console.WriteLine(e); } } } return(result); }
protected internal override bool SelectListItemByValue(ListItem item, object value) { DefaultableMulti defaultableMulti = value as DefaultableMulti; if (defaultableMulti != null) { return(defaultableMulti.ValueType.Equals(item.Value)); } return(false); }
protected virtual object InternalCreateInstance(ITypeDescriptorContext context, IDictionary propertyValues) { object propertyValue = context.PropertyDescriptor.GetValue(context.Instance); DefaultableMulti defaultableMulti = propertyValue as DefaultableMulti; if (defaultableMulti != null) { return(defaultableMulti.CloneFromPropertyValues(propertyValues)); } return(null); }
protected internal override object GetValueFromSelectedListItem(object lastSelectedValue, ListItem listItem) { DefaultableMulti lastValue = lastSelectedValue as DefaultableMulti; if (lastValue != null) { DefaultableMulti clone = (DefaultableMulti)lastValue.Clone(); clone.ValueType = listItem == null ? clone.ValueTypeForNull : (string)listItem.Value; return(clone); } return(listItem.Value); }
public override bool EqualsTo(DefaultableBase other) { if (other == null || this.GetType() != other.GetType()) { return(false); } DefaultableMulti otherDefaultableMulti = (DefaultableMulti)other; if (base.EqualsTo(other)) { return(InternalEqualsTo(otherDefaultableMulti)); } return(false); }
public object Clone() { DefaultableMulti cloned = (DefaultableMulti)Activator.CreateInstance(this.GetType()); cloned.ValueType = this.ValueType; cloned.stopPropagateValueChanges = true; try { cloned.AssignFrom(this); } finally { cloned.stopPropagateValueChanges = false; } return(cloned); }
/// <summary> /// Converts a TItemType to a value. /// </summary> /// <param name="context"></param> /// <param name="culture"></param> /// <param name="value"></param> /// <param name="destinationType"></param> /// <returns></returns> /// <remarks></remarks> public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) { object result = string.Empty; if (value is DefaultableMulti) { if (destinationType == typeof(string)) { DefaultableMulti defaultableMulti = (DefaultableMulti)value; return(defaultableMulti.ValueType); } } if (destinationType == typeof(DefaultableMulti)) { bool e = true; } result = base.ConvertTo(context, culture, value, destinationType); return(result); }
/// <summary> /// Converts values to a TItemType. /// </summary> /// <param name="context"></param> /// <param name="culture"></param> /// <param name="value"></param> /// <returns></returns> /// <remarks></remarks> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { if (context != null) { object propertyValue = context.PropertyDescriptor.GetValue(context.Instance); DefaultableMulti defaultableMulti = propertyValue as DefaultableMulti; if (value is string && defaultableMulti != null) { defaultableMulti.ValueType = (string)value; return(defaultableMulti.Clone()); } } else { return(null); } object result = base.ConvertFrom(context, culture, value); return(result); }
protected abstract bool InternalEqualsTo(DefaultableMulti other);
protected abstract void InternalAssignFrom(DefaultableMulti other);
protected void AssignFrom(DefaultableMulti other) { InternalAssignFrom(other); }