Esempio n. 1
0
        public static void ToStringTakesRange()
        {
            var builder = new ReverseStringBuilder(100);

            builder.Prepend("0123456789");
            Assert.AreEqual("0", builder.ToString(builder.Length, 1));
            Assert.AreEqual("12345", builder.ToString(builder.Length - 1, 5));
        }
Esempio n. 2
0
        public static void ToStringWithNegativeBackIndexThrowsEvenWithCapacity()
        {
            var builder = new ReverseStringBuilder(20);

            builder.Prepend("0123456789");
            Assert.Throws <ArgumentOutOfRangeException, string>(() => builder.ToString(-1, 1));
        }
Esempio n. 3
0
        public static void ToStringWithBackIndexBeyondLengthReturnsNullChars()
        {
            var builder = new ReverseStringBuilder(20);

            builder.Prepend("0123456789");
            Assert.AreEqual("\0", builder.ToString(builder.Length + 1, 1));
        }
Esempio n. 4
0
        public static void ToStringWithBackIndexBeyondCapacityThrows()
        {
            var builder = new ReverseStringBuilder(10);

            builder.Prepend("0123456789");
            Assert.Throws <ArgumentOutOfRangeException, string>(() => builder.ToString(builder.Length + 1, 1));
        }
        private static string GenerateInstancePathString(List <InstancePathItem> instancePath, int parentInstanceIndex)
        {
            if (instancePath == null || instancePath.Count == 0)
            {
                return("");
            }
            int count = instancePath.Count;
            ReverseStringBuilder builder = new ReverseStringBuilder(count * 2 + 4);
            bool flag  = true;
            bool flag2 = true;
            bool flag3 = parentInstanceIndex >= 0;

            for (int num = count - 1; num >= 0; num--)
            {
                InstancePathItem instancePathItem = instancePath[num];
                switch (instancePathItem.m_indexType)
                {
                case InstancePathItemType.ColumnMemberInstanceIndexTopMost:
                case InstancePathItemType.ColumnMemberInstanceIndex:
                    if (flag3)
                    {
                        flag3 = false;
                        AppendInteger(ref builder, parentInstanceIndex);
                    }
                    else
                    {
                        AppendInteger(ref builder, instancePathItem.m_instanceIndex);
                    }
                    if (flag)
                    {
                        flag = false;
                        builder.Append('x');
                        AppendInteger(ref builder, instancePathItem.m_indexInCollection);
                    }
                    builder.Append('C');
                    break;

                case InstancePathItemType.RowMemberInstanceIndex:
                    if (flag3)
                    {
                        flag3 = false;
                        AppendInteger(ref builder, parentInstanceIndex);
                    }
                    else
                    {
                        AppendInteger(ref builder, instancePathItem.m_instanceIndex);
                    }
                    if (flag2)
                    {
                        flag2 = false;
                        builder.Append('x');
                        AppendInteger(ref builder, instancePathItem.m_indexInCollection);
                    }
                    builder.Append('R');
                    break;

                case InstancePathItemType.DataRegion:
                    AppendInteger(ref builder, instancePathItem.m_indexInCollection);
                    builder.Append('T');
                    break;

                case InstancePathItemType.SubReport:
                    AppendInteger(ref builder, instancePathItem.m_indexInCollection);
                    builder.Append('S');
                    break;
                }
            }
            return(builder.ToString());
        }