Example #1
0
            /// <summary>
            /// Subclasses may override this with custom logic on how to construct a string for single <see cref="ParameterGroupOrFixedParameter"/>.
            /// This method is allowed to be recursive.
            /// </summary>
            /// <param name="group">The <see cref="ParameterGroupOrFixedParameter"/>.</param>
            /// <param name="sb">The <see cref="StringBuilder"/> holding string being constructed.</param>
            /// <remarks>The default implementation surrounds the actual string with brackets (<c>[</c>, <c>]</c>) if the <see cref="ParameterGroupOrFixedParameter.IsOptional"/> is true for <paramref name="group"/>.</remarks>
            protected virtual void CreateGroupDescriptionString(
                ParameterGroupOrFixedParameter group,
                StringBuilder sb
                )
            {
                var isOptional = group.IsOptional;

                if (isOptional)
                {
                    sb.Append("[");
                }
                switch (group)
                {
                case NamedParameterGroup named:
                    sb.Append(named.Name);
                    break;

                case FixedParameter param:
                    sb.Append(param.Parameter);
                    break;

                case GroupContainer container:
                    foreach (var child in container.ChildGroups)
                    {
                        this.CreateGroupDescriptionString(child, sb);
                        sb.Append(" ");
                    }
                    break;
                }
                if (isOptional)
                {
                    sb.Append("]");
                }
            }
Example #2
0
            private String CreateGroupDescriptionString(
                ParameterGroupOrFixedParameter group
                )
            {
                var sb = new StringBuilder();

                this.CreateGroupDescriptionString(group, sb);
                return(sb.ToString());
            }