Exemple #1
0
        public override void GetData(object inObject, Stream outStream)
        {
            var wr = inObject as WeakReference;

            inObject = wr.Target;

            // Object -> string に変換
            var converter = new ObjectToStringConverter(ObjectVisualizer.GetLanguageTypes());
            var xmlString = string.Empty;

            if (inObject is Type)
            {
                xmlString = converter.CreateBaseTypeTree(inObject as Type);
            }
            else if (inObject is StackFrame[])
            {
                xmlString = converter.CreateCallTree(inObject as StackFrame[]);
            }
            else
            {
                xmlString = converter.Convert(inObject);
            }

            // シリアライズして渡す
            var writer = new StreamWriter(outStream);

            writer.Write(xmlString);
            writer.Flush();
        }
        /// <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 #3
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));
        }