当前位置: 首页>>代码示例>>C#>>正文


C# Builder.AppendCollectionItemSeparator方法代码示例

本文整理汇总了C#中Builder.AppendCollectionItemSeparator方法的典型用法代码示例。如果您正苦于以下问题:C# Builder.AppendCollectionItemSeparator方法的具体用法?C# Builder.AppendCollectionItemSeparator怎么用?C# Builder.AppendCollectionItemSeparator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Builder的用法示例。


在下文中一共展示了Builder.AppendCollectionItemSeparator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendAsCollectionEntry

                public bool AppendAsCollectionEntry(Builder result)
                {
                    // Some BCL collections use [{key.ToString()}]: {value.ToString()} pattern to display collection entries.
                    // We want them to be printed initializer-style, i.e. { <key>, <value> } 
                    if (HasKeyName())
                    {
                        result.AppendGroupOpening();
                        result.AppendCollectionItemSeparator(isFirst: true, inline: true);
                        result.Append(Name, 1, Name.Length - 2);
                        result.AppendCollectionItemSeparator(isFirst: false, inline: true);
                        result.Append(Value);
                        result.AppendGroupClosing(inline: true);
                    }
                    else
                    {
                        result.Append(Value);
                    }

                    return true;
                }
开发者ID:Rickinio,项目名称:roslyn,代码行数:20,代码来源:CommonObjectFormatter.Visitor.FormattedMember.cs

示例2: FormatMultidimensionalArray

            private void FormatMultidimensionalArray(Builder result, Array array, bool inline)
            {
                Debug.Assert(array.Rank > 1);

                if (array.Length == 0)
                {
                    result.AppendCollectionItemSeparator(isFirst: true, inline: true);
                    result.AppendGroupOpening();
                    result.AppendGroupClosing(inline: true);
                    return;
                }

                int[] indices = new int[array.Rank];
                for (int i = array.Rank - 1; i >= 0; i--)
                {
                    indices[i] = array.GetLowerBound(i);
                }

                int nesting = 0;
                int flatIndex = 0;
                while (true)
                {
                    // increment indices (lower index overflows to higher):
                    int i = indices.Length - 1;
                    while (indices[i] > array.GetUpperBound(i))
                    {
                        indices[i] = array.GetLowerBound(i);
                        result.AppendGroupClosing(inline: inline || nesting != 1);
                        nesting--;

                        i--;
                        if (i < 0)
                        {
                            return;
                        }

                        indices[i]++;
                    }

                    result.AppendCollectionItemSeparator(isFirst: flatIndex == 0, inline: inline || nesting != 1);

                    i = indices.Length - 1;
                    while (i >= 0 && indices[i] == array.GetLowerBound(i))
                    {
                        result.AppendGroupOpening();
                        nesting++;

                        // array isn't empty, so there is always an element following this separator
                        result.AppendCollectionItemSeparator(isFirst: true, inline: inline || nesting != 1);

                        i--;
                    }

                    string name;
                    FormatObjectRecursive(result, array.GetValue(indices), quoteStrings: true, memberFormat: MemberDisplayFormat.InlineValue, name: out name);

                    indices[indices.Length - 1]++;
                    flatIndex++;
                }
            }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:60,代码来源:ObjectFormatter.Formatter.cs

示例3: FormatSequence

            private void FormatSequence(Builder result, IEnumerable sequence, bool inline)
            {
                result.AppendGroupOpening();
                int i = 0;

                try
                {
                    foreach (var item in sequence)
                    {
                        string name;
                        result.AppendCollectionItemSeparator(isFirst: i == 0, inline: inline);
                        FormatObjectRecursive(result, item, quoteStrings: true, memberFormat: MemberDisplayFormat.InlineValue, name: out name);
                        i++;
                    }
                }
                catch (Exception e)
                {
                    result.AppendCollectionItemSeparator(isFirst: i == 0, inline: inline);
                    FormatException(result, e);
                    result.Append(" ...");
                }

                result.AppendGroupClosing(inline);
            }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:24,代码来源:ObjectFormatter.Formatter.cs

示例4: FormatDictionary

            private void FormatDictionary(Builder result, IDictionary dict, bool inline)
            {
                result.AppendGroupOpening();

                int i = 0;
                try
                {
                    IDictionaryEnumerator enumerator = dict.GetEnumerator();
                    IDisposable disposable = enumerator as IDisposable;
                    try
                    {
                        while (enumerator.MoveNext())
                        {
                            var entry = enumerator.Entry;
                            string _;
                            result.AppendCollectionItemSeparator(isFirst: i == 0, inline: inline);
                            result.AppendGroupOpening();
                            result.AppendCollectionItemSeparator(isFirst: true, inline: true);
                            FormatObjectRecursive(result, entry.Key, quoteStrings: true, memberFormat: MemberDisplayFormat.InlineValue, name: out _);
                            result.AppendCollectionItemSeparator(isFirst: false, inline: true);
                            FormatObjectRecursive(result, entry.Value, quoteStrings: true, memberFormat: MemberDisplayFormat.InlineValue, name: out _);
                            result.AppendGroupClosing(inline: true);
                            i++;
                        }
                    }
                    finally
                    {
                        if (disposable != null)
                        {
                            disposable.Dispose();
                        }
                    }
                }
                catch (Exception e)
                {
                    result.AppendCollectionItemSeparator(isFirst: i == 0, inline: inline);
                    FormatException(result, e);
                    result.Append(' ');
                    result.Append(_options.Ellipsis);
                }

                result.AppendGroupClosing(inline);
            }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:43,代码来源:ObjectFormatter.Formatter.cs

示例5: FormatKeyValuePair

 private void FormatKeyValuePair(Builder result, object obj)
 {
     Type type = obj.GetType();
     object key = type.GetProperty("Key").GetValue(obj, SpecializedCollections.EmptyObjects);
     object value = type.GetProperty("Value").GetValue(obj, SpecializedCollections.EmptyObjects);
     string _;
     result.AppendGroupOpening();
     result.AppendCollectionItemSeparator(isFirst: true, inline: true);
     FormatObjectRecursive(result, key, quoteStrings: true, memberFormat: MemberDisplayFormat.InlineValue, name: out _);
     result.AppendCollectionItemSeparator(isFirst: false, inline: true);
     FormatObjectRecursive(result, value, quoteStrings: true, memberFormat: MemberDisplayFormat.InlineValue, name: out _);
     result.AppendGroupClosing(inline: true);
 }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:13,代码来源:ObjectFormatter.Formatter.cs

示例6: FormatObjectMembers

            /// <summary>
            /// Formats object members to a list.
            /// 
            /// Inline == false:
            /// <code>
            /// { A=true, B=false, C=new int[3] { 1, 2, 3 } }
            /// </code>
            /// 
            /// Inline == true:
            /// <code>
            /// {
            ///   A: true,
            ///   B: false,
            ///   C: new int[3] { 1, 2, 3 }
            /// }
            /// </code>
            /// </summary>
            private void FormatObjectMembers(Builder result, object obj, Type originalType, bool includeNonPublic, bool inline)
            {
                int lengthLimit = result.Remaining;
                if (lengthLimit < 0)
                {
                    return;
                }

                var members = new List<FormattedMember>();

                // Limits the number of members added into the result. Some more members may be added than it will fit into the result
                // and will be thrown away later but not many more.
                FormatObjectMembersRecursive(members, obj, includeNonPublic, ref lengthLimit);
                bool useCollectionFormat = UseCollectionFormat(members, originalType);

                result.AppendGroupOpening();

                for (int i = 0; i < members.Count; i++)
                {
                    result.AppendCollectionItemSeparator(isFirst: i == 0, inline: inline);
                    if (useCollectionFormat)
                    {
                        members[i].AppendAsCollectionEntry(result);
                    }
                    else
                    {
                        members[i].Append(result, inline ? "=" : ": ");
                    }

                    if (result.LimitReached)
                    {
                        break;
                    }
                }

                result.AppendGroupClosing(inline);
            }
开发者ID:ehsansajjad465,项目名称:roslyn,代码行数:54,代码来源:ObjectFormatter.Formatter.cs

示例7: FormatSequenceMembers

            private void FormatSequenceMembers(Builder result, IEnumerable sequence, bool inline)
            {
                result.AppendGroupOpening();
                int i = 0;

                try
                {
                    foreach (var item in sequence)
                    {
                        string _;
                        result.AppendCollectionItemSeparator(isFirst: i == 0, inline: inline);
                        FormatObjectRecursive(result, item, isRoot: false, debuggerDisplayName: out _);
                        i++;
                    }
                }
                catch (Exception e)
                {
                    result.AppendCollectionItemSeparator(isFirst: i == 0, inline: inline);
                    FormatException(result, e);
                    result.Append(" ...");
                }

                result.AppendGroupClosing(inline);
            }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:24,代码来源:CommonObjectFormatter.Visitor.cs

示例8: FormatKeyValuePair

 private void FormatKeyValuePair(Builder result, object obj)
 {
     TypeInfo type = obj.GetType().GetTypeInfo();
     object key = type.GetDeclaredProperty("Key").GetValue(obj, SpecializedCollections.EmptyObjects);
     object value = type.GetDeclaredProperty("Value").GetValue(obj, SpecializedCollections.EmptyObjects);
     string _;
     result.AppendGroupOpening();
     result.AppendCollectionItemSeparator(isFirst: true, inline: true);
     FormatObjectRecursive(result, key, isRoot: false, debuggerDisplayName: out _);
     result.AppendCollectionItemSeparator(isFirst: false, inline: true);
     FormatObjectRecursive(result, value, isRoot: false, debuggerDisplayName: out _);
     result.AppendGroupClosing(inline: true);
 }
开发者ID:CAPCHIK,项目名称:roslyn,代码行数:13,代码来源:CommonObjectFormatter.Visitor.cs


注:本文中的Builder.AppendCollectionItemSeparator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。