Esempio n. 1
0
        public object CloneFromPropertyValues(IDictionary propertyValues)
        {
            DefaultableMulti cloned = (DefaultableMulti)Clone();

            cloned.AssignFromPropertyValues(propertyValues);
            return(cloned);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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);
        }
Esempio n. 8
0
        /// <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);
        }
Esempio n. 9
0
        /// <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);
        }
Esempio n. 10
0
 protected abstract bool InternalEqualsTo(DefaultableMulti other);
Esempio n. 11
0
 protected abstract void InternalAssignFrom(DefaultableMulti other);
Esempio n. 12
0
 protected void AssignFrom(DefaultableMulti other)
 {
     InternalAssignFrom(other);
 }