/// <summary>
        /// Converts a value.
        /// </summary>
        /// <param name="value">The value produced by the binding source.</param>
        /// <param name="targetType">The type of the binding target property.</param>
        /// <param name="parameter">The converter parameter to use.</param>
        /// <param name="culture">The culture to use in the converter.</param>
        /// <returns>
        /// A converted value. If the method returns null, the valid null value is used.
        /// </returns>
        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            IList l = value as IList;

            if (l == null)
            {
                return(string.Empty);
            }

            StringBuilder sb = new StringBuilder();
            int           ct = 0;

            foreach (object obj in l)
            {
                if (ct > 0)
                {
                    sb.Append(", ");
                }

                ct++;
                sb.Append(ObjectToStringConverter.ToDisplayString(obj));
            }

            return(sb.ToString());
        }
Exemple #2
0
        /// <summary>
        /// Converts the specified values.
        /// </summary>
        /// <param name="values">The values.</param>
        /// <param name="targetType">Type of the target.</param>
        /// <param name="parameter">The parameter.</param>
        /// <param name="culture">The culture.</param>
        /// <returns>The anonymized text.</returns>
        public override object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Length != 2)
            {
                return(null);
            }

            string text      = values[0] as string;
            var    anonymize = values[1] is Anonymize ? (Anonymize)values[1] : Anonymize.DoNotAnonymize;

            if (text == null)
            {
                text = ObjectToStringConverter.ToDisplayString(values[0]);
            }

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            if (anonymize == Anonymize.DoNotAnonymize)
            {
                return(text);
            }

            return(Anonymizer.WordsToX(text));
        }