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


C# Slice.ToString方法代码示例

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


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

示例1: TestEmptySliceAtZero

        public void TestEmptySliceAtZero()
        {
            Slice<char> x = new Slice<char>("test!");
            x = x.Slc(0, 0);

            Assert.AreEqual("", x.ToString());
        }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:7,代码来源:SliceTest.cs

示例2: TestEmptySliceAtEnd

        public void TestEmptySliceAtEnd()
        {
            Slice<char> x = new Slice<char>("test!");
            x = x.Slc(x.Len());

            Assert.AreEqual("", x.ToString());
        }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:7,代码来源:SliceTest.cs

示例3: DumpHumanReadable

	    public static void DumpHumanReadable(Transaction tx, string path, Page start)
	    {
		    using (var writer = File.CreateText(path))
		    {
                var stack = new Stack<Page>();
                stack.Push(start);
				writer.WriteLine("Root page #{0}",start.PageNumber);
			    while (stack.Count > 0)
			    {
					var currentPage = stack.Pop();
				    if (currentPage.IsLeaf)
				    {						
						writer.WriteLine();
						writer.WriteLine("Page #{0}, NumberOfEntries = {1}, Flags = {2} (Leaf), Used: {3} : {4}", currentPage.PageNumber,currentPage.NumberOfEntries,currentPage.Flags, currentPage.SizeUsed, currentPage.CalcSizeUsed());
						if(currentPage.NumberOfEntries <= 0)
							writer.WriteLine("Empty page (tree corrupted?)");
					    
						var key = new Slice(SliceOptions.Key);
					    for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries;nodeIndex++)
					    {
						    var node = currentPage.GetNode(nodeIndex);
							key.Set(node);
							writer.WriteLine("Node #{0}, Flags = {1}, {4} = {2}, Key = {3}, Entry Size: {5}", nodeIndex, node->Flags, node->DataSize, MaxString(key.ToString(), 25), node->Flags == NodeFlags.Data ? "Size" : "Page",
                                SizeOf.NodeEntry(node));
					    }
						writer.WriteLine();
				    }
				    else if(currentPage.IsBranch) 
				    {
						writer.WriteLine();
						writer.WriteLine("Page #{0}, NumberOfEntries = {1}, Flags = {2} (Branch), Used: {3} : {4}", currentPage.PageNumber, currentPage.NumberOfEntries, currentPage.Flags, currentPage.SizeUsed, currentPage.SizeUsed);

						var key = new Slice(SliceOptions.Key);
						for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
						{
							var node = currentPage.GetNode(nodeIndex);
							writer.WriteLine("Node #{2}, {0}  / to page #{1}, Entry Size: {3}", GetBranchNodeString(nodeIndex, key, currentPage, node), node->PageNumber, nodeIndex,
                                SizeOf.NodeEntry(node));
						}

						for (int nodeIndex = 0; nodeIndex < currentPage.NumberOfEntries; nodeIndex++)
						{
							var node = currentPage.GetNode(nodeIndex);
							if (node->PageNumber < 0 || node->PageNumber > tx.State.NextPageNumber)
							{
								writer.Write("Found invalid reference to page #{0}", currentPage.PageNumber);
								stack.Clear();
								break;
							}

							var child = tx.GetReadOnlyPage(node->PageNumber);
							stack.Push(child);
						}
						
						writer.WriteLine();
					}
			    }
		    }
	    }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:59,代码来源:TreeDumper.cs

示例4: SliceShift

 public void SliceShift()
 {
     Constant eight = Constant.Word16(8);
     Constant ate = Constant.Word32(8);
     Identifier C = Reg8("C");
     Identifier ax = Reg16("ax");
     Expression e = new Slice(PrimitiveType.Byte, new BinaryExpression(Operator.Shl, PrimitiveType.Word16, C, eight), 8);
     var vp = new ExpressionSimplifier(new SsaEvaluationContext(arch, ssaIds));
     e = e.Accept(vp);
     Assert.AreEqual("C", e.ToString());
 }
开发者ID:nemerle,项目名称:reko,代码行数:11,代码来源:ValuePropagationTests.cs

示例5: VpSliceConstant

		public void VpSliceConstant()
		{
            var vp = new ExpressionSimplifier(new SsaEvaluationContext(arch, ssaIds));
            Expression c = new Slice(PrimitiveType.Byte, Constant.Word32(0x10FF), 0).Accept(vp);
			Assert.AreEqual("0xFF", c.ToString());
		}
开发者ID:uxmal,项目名称:reko,代码行数:6,代码来源:ValuePropagationTests.cs

示例6: leadingInt

 /// <summary>
 /// leadingInt consumes the leading [0-9]* from s.
 /// </summary>
 private static long leadingInt(ref Slice<char> s)
 {
     int i = 0;
     long x = 0;
     for (; i < s.Len(); i++)
     {
         char c = s[i];
         if (c < '0' || c > '9')
         {
             break;
         }
         if (x >= (long.MaxValue - 10) / 10)
         {
             // overflow
             throw new OverflowException(s.ToString());
         }
         x = x * 10 + (c - '0');
     }
     s = s.Slc(i);
     return x;
 }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:24,代码来源:Time.cs

示例7: Dump

        public static void Dump(Transaction tx, string path, Page start, int showNodesEvery = 25)
        {
            using (var writer = File.CreateText(path))
            {
                writer.WriteLine(@"
            digraph structs {
            node [shape=Mrecord]
            rankdir=LR;
            bgcolor=transparent;
            ");

                var stack = new Stack<Page>();
                stack.Push(start);
                var references = new StringBuilder();
                while (stack.Count > 0)
                {
                    var p = stack.Pop();

                    writer.WriteLine(@"
            subgraph cluster_p_{0} {{
            label=""Page #{0}"";
            color={3};
            p_{0} [label=""Page: {0}|{1}|Entries: {2:#,#} | {4:p} : {5:p} utilization""];

            ", p.PageNumber, p.Flags, p.NumberOfEntries, p.IsLeaf ? "black" : "blue",
            Math.Round(((AbstractPager.PageSize - p.SizeLeft) / (double)AbstractPager.PageSize), 2),
            Math.Round(((AbstractPager.PageSize - p.CalcSizeLeft()) / (double)AbstractPager.PageSize), 2));
                    MemorySlice key = new Slice(SliceOptions.Key);
                    if (p.IsLeaf && showNodesEvery > 0)
                    {
                        writer.WriteLine("		p_{0}_nodes [label=\" Entries:", p.PageNumber);
                        for (int i = 0; i < p.NumberOfEntries; i += showNodesEvery)
                        {
                            if (i != 0 && showNodesEvery >= 5)
                            {
                                writer.WriteLine(" ... {0:#,#} keys redacted ...", showNodesEvery - 1);
                            }
                            var node = p.GetNode(i);
                            key = p.GetNodeKey(node);
                            writer.WriteLine("{0} - {2} {1:#,#}", MaxString(key.ToString(), 25),
                                node->DataSize, node->Flags == NodeFlags.Data ? "Size" : "Page");
                        }
                        if (p.NumberOfEntries < showNodesEvery)
                        {
                            writer.WriteLine(" ... {0:#,#} keys redacted ...", p.NumberOfEntries - 1);
                        }
                        writer.WriteLine("\"];");
                    }
                    else if (p.IsBranch)
                    {
                        writer.Write("		p_{0}_refs [label=\"", p.PageNumber);
                        for (int i = 0; i < p.NumberOfEntries; i++)
                        {
                            var node = p.GetNode(i);

                            writer.Write("{3}<{2}> {0}  / to page {1}", GetBranchNodeString(i, key, p, node), node->PageNumber,
                                i, i == 0 ? "" : "|");
                        }
                        writer.WriteLine("\"];");
                        var prev = -1L;
                        for (int i = 0; i < p.NumberOfEntries; i++)
                        {
                            var node = p.GetNode(i);
                            if (node->PageNumber < 0 || node->PageNumber > tx.State.NextPageNumber)
                            {
                                writer.Write("		p_{0}_refs [label=\"CORRUPTED\"; Color=RED];", p.PageNumber);
                                stack.Clear();
                                break;
                            }
                            var child = tx.GetReadOnlyPage(node->PageNumber);
                            stack.Push(child);

                            references.AppendFormat("	p_{0}_refs:{3} -> p_{1} [label=\"{2}\"];", p.PageNumber, child.PageNumber, GetBranchNodeString(i, key, p, node), i).AppendLine();
                            if (prev > -1)
                                references.AppendFormat("	p_{0} -> p_{1} [style=\"invis\"];", child.PageNumber, prev);

                            prev = child.PageNumber;
                        }
                    }
                    writer.WriteLine("	}");
                }
                writer.WriteLine(references.ToString());

                writer.WriteLine("}");
            }
        }
开发者ID:mattwarren,项目名称:LinqToMemory,代码行数:86,代码来源:TreeDumper.cs

示例8: TestToString

        public void TestToString()
        {
            var s = new Slice<string>(0);
            Assert.AreEqual(s.ToString(), "Slice<String>[]");

            var i = Slice.Make(0, 1, 2, 3);
            Assert.AreEqual(i.ToString(), "Slice<Int32>[0, 1, 2, 3]");
        }
开发者ID:katis,项目名称:csharp-slice,代码行数:8,代码来源:SliceTest.cs

示例9: GetBranchNodeString

 private static unsafe string GetBranchNodeString(int i, Slice key, Page p, NodeHeader* node)
 {
     string keyStr;
     if (i == 0 && key.Size == 0)
     {
         key.Set(p.GetNode(1));
         keyStr = "(lt " + key + ")";
     }
     else
     {
         key.Set(node);
         keyStr = key.ToString();
     }
     return MaxString(keyStr, 25);
 }
开发者ID:ReginaBricker,项目名称:ravendb,代码行数:15,代码来源:TreeDumper.cs

示例10: TestToStringOnSliceInt

        public void TestToStringOnSliceInt()
        {
            Slice<int> x = new Slice<int>(new[] { 1, 2, 3, 4 });
            string actual = x.ToString();

            Assert.AreEqual("[ 1 2 3 4 ]", actual);
        }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:7,代码来源:SliceTest.cs

示例11: TestSlcHasNoSideEffects

        public void TestSlcHasNoSideEffects()
        {
            Slice<char> x = new Slice<char>("hello world");
            x.Slc(2, 8);

            Assert.AreEqual("hello world".Length, x.Len());
            Assert.AreEqual("hello world", x.ToString());
        }
开发者ID:yonglehou,项目名称:NsqSharp,代码行数:8,代码来源:SliceTest.cs


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