public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
        {
            if (value == null)
            {
                return(null);
            }

            ChoNotNullableArrayList arrayList = new ChoNotNullableArrayList();
            object notNullItem = null;

            if (value.GetType().IsArray)
            {
                foreach (object item in (Array)value)
                {
                    if (item == null)
                    {
                        continue;
                    }
                    notNullItem = item;

                    ChoValidationResults validationResults = ChoValidation.Validate(item);
                    if (validationResults != null && validationResults.Count > 0)
                    {
                        continue;
                    }

                    arrayList.Add(item);
                }
                return(notNullItem == null ? null : arrayList.ToArray(notNullItem.GetType()));
            }
            else
            {
                return(value);
            }
        }
Exemplo n.º 2
0
        public override string ToString()
        {
            ChoValidationResults results = ChoValidation.Validate(this);

            if (results.Count == 0)
            {
                return(String.Format("SUCCESS - ShortName: {0}, Type: {1}, Override: {3} [TypeFound: {2}]", TypeShortName, TypeName, Type != null, Override));
            }
            else
            {
                return(String.Format("ERROR - ShortName: {0}, Type: {1}, Override: {3} [TypeFound: {2}], {4}[{4}{5}]",
                                     TypeShortName, TypeName, Type != null, Override, Environment.NewLine, results.ToString().Indent()));
            }
        }