/// <summary>
        /// Creates the inlines for the specified code item's parameters.
        /// </summary>
        /// <param name="codeItem">The code item.</param>
        /// <returns>The inlines representing the parameters.</returns>
        private IEnumerable <Inline> CreateInlinesForParameters(ICodeItemParameters codeItem)
        {
            var inlines = new List <Inline>();

            var opener = GetOpeningString(codeItem);

            if (opener != null)
            {
                inlines.Add(CreateItalicRun(opener));
            }

            bool isFirst = true;

            try
            {
                foreach (var param in codeItem.Parameters)
                {
                    if (isFirst)
                    {
                        isFirst = false;
                    }
                    else
                    {
                        inlines.Add(CreateItalicRun(", "));
                    }

                    try
                    {
                        inlines.Add(CreateTypeRun(TypeFormatHelper.Format(param.Type.AsString) + " "));
                        inlines.Add(CreateItalicRun(param.Name));
                    }
                    catch (Exception)
                    {
                        inlines.Add(CreateItalicRun("?"));
                    }
                }
            }
            catch (Exception)
            {
                inlines.Add(CreateItalicRun("?"));
            }

            var closer = GetClosingString(codeItem);

            if (closer != null)
            {
                inlines.Add(CreateItalicRun(closer));
            }

            return(inlines);
        }
        /// <summary>
        /// Creates the inlines for the type.
        /// </summary>
        /// <param name="codeItemElement">The code item element.</param>
        /// <returns>The inlines representing the type.</returns>
        private IEnumerable <Inline> CreateInlinesForType(BaseCodeItemElement codeItemElement)
        {
            var inlines = new List <Inline>();

            var formattedTypeString = TypeFormatHelper.Format(codeItemElement.TypeString);

            if (!string.IsNullOrWhiteSpace(formattedTypeString))
            {
                inlines.Add(CreateTypeRun(" : "));
                inlines.Add(CreateTypeRun(formattedTypeString));
            }

            return(inlines);
        }
Example #3
0
 /// <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 object Convert(object value, Type targetType, object parameter, CultureInfo culture)
 {
     return(TypeFormatHelper.Format(value as string));
 }
Example #4
0
        /// <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 object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            var codeItem = value as ICodeItemParameters;

            if (codeItem == null)
            {
                return(null);
            }

            var textBlock = new TextBlock();

            textBlock.Inlines.Add(codeItem.Name);

            if (IncludeParameters)
            {
                var opener = GetOpeningString(codeItem);
                if (opener != null)
                {
                    textBlock.Inlines.Add(CreateRun(opener));
                }

                bool isFirst = true;

                try
                {
                    foreach (var param in codeItem.Parameters)
                    {
                        if (isFirst)
                        {
                            isFirst = false;
                        }
                        else
                        {
                            textBlock.Inlines.Add(CreateRun(", "));
                        }

                        try
                        {
                            textBlock.Inlines.Add(CreateTypeRun(TypeFormatHelper.Format(param.Type.AsString) + " "));
                            textBlock.Inlines.Add(CreateRun(param.Name));
                        }
                        catch (Exception)
                        {
                            textBlock.Inlines.Add(CreateRun("?"));
                        }
                    }
                }
                catch (Exception)
                {
                    textBlock.Inlines.Add(CreateRun("?"));
                }

                var closer = GetClosingString(codeItem);
                if (closer != null)
                {
                    textBlock.Inlines.Add(CreateRun(closer));
                }
            }

            return(textBlock);
        }