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


C# Document.ToString方法代码示例

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


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

示例1: TestBuilderSetsAllProperties

        public void TestBuilderSetsAllProperties()
        {
            var query = new Document().Add("x", 1);
            var scope = new Document().Add("y", 2);
            var sort = new Document().Add("z", 3);
            var mrb = _collection.MapReduce();
            mrb.Map(MapFunc)
                .Reduce(ReduceFunc)
                .KeepTemp(true)
                .Limit(5)
                .Out("outtest")
                .Query(query)
                .Scope(scope)
                .Sort(sort)
                .Verbose(false);

            var mr = mrb.Command;
            Assert.AreEqual(query.ToString(), mr.Query.ToString());
            Assert.AreEqual(scope.ToString(), mr.Scope.ToString());
            Assert.AreEqual(sort.ToString(), mr.Sort.ToString());
            Assert.AreEqual(true, mr.KeepTemp);
            Assert.AreEqual(5, mr.Limit);
            Assert.AreEqual("outtest", mr.Out);
            Assert.AreEqual(false, mr.Verbose);
        }
开发者ID:jango2015,项目名称:MongoDB_Client_.Net,代码行数:25,代码来源:TestMapReduce.cs

示例2: GetDocUri_NON_FUNZIONA

 /*
 public static Stream GetDocUri_NON_FUNZIONA(DocumentsRequest request, Document doc, Document.DownloadType type)
 {
     // NON FUNZIONA (porca putt...!)
     string docID = doc.ResourceId.Replace("document:", "");
     string uriS = "http://docs.google.com/feeds/download/documents/Export?" +
         "docID=" + docID +
         "&exportFormat=" + type.ToString();
     Uri target = new Uri(uriS);
     return request.Service.Query(target);
 }
 */
 public static Stream GetDocExportStream(DocumentsRequest request, Document doc, Document.DownloadType downloadtype)
 {
     // Questa funziona ma mi pare na stronz...
     string format = downloadtype.ToString();
     string url =
         doc.DocumentEntry.Content.AbsoluteUri +
         "&exportFormat=" + format + "&format=" + format;
     return request.Service.Query(new Uri(url));
 }
开发者ID:superhafnium,项目名称:gdocbackup,代码行数:21,代码来源:Mandrakata.cs

示例3: TestEmptyArray

        public void TestEmptyArray()
        {
            Object[] arr = new Object[0];
            Document expected = new Document(){{"arr", arr}};
            Document read = WriteAndRead(expected);

            string json = @"{ ""arr"": [  ] }";
            Assert.AreEqual(json, expected.ToString());
            Assert.IsTrue(read["arr"] is IEnumerable<Object>, "Empty array wasn't returned as IEnumerable<Object>");
            Assert.AreEqual(json, read.ToString());
        }
开发者ID:kvnsmth,项目名称:mongodb-csharp,代码行数:11,代码来源:TestRoundTrips.cs

示例4: TestRoundTrip

        public void TestRoundTrip(){
            var idoc = new Document{{"b", new Binary(new[]{(byte)1, (byte)2})}};

            var stream = new MemoryStream();
            var writer = new BsonWriter(stream, new BsonDocumentDescriptor());
            writer.WriteObject(idoc);

            stream.Seek(0, SeekOrigin.Begin);
            var reader = new BsonReader(stream,new BsonDocumentBuilder());
            var odoc = reader.Read();

            Assert.AreEqual(idoc.ToString(), odoc.ToString());
        }
开发者ID:gaoninggn,项目名称:mongodb-csharp,代码行数:13,代码来源:TestBsonBinary.cs

示例5: TestMixedArrayContents

        public void TestMixedArrayContents()
        {
            Object[] arr = new Object[]{new string[]{"one", "two"},
                                        new string[]{"three", "four"},
                                        new Document(){{"id", "six"}}};
            Document expected = new Document(){{"arr", arr}};
            Document read = WriteAndRead(expected);

            string json = @"{ ""arr"": [ [ ""one"", ""two"" ], [ ""three"", ""four"" ], { ""id"": ""six"" } ] }";
            Assert.AreEqual(json, expected.ToString());

            Assert.IsTrue(read["arr"] is Object[], "Mixed array wasn't returned as Object[]");

            Assert.AreEqual(json, read.ToString());
        }
开发者ID:sdether,项目名称:mongodb-csharp,代码行数:15,代码来源:TestRoundTrips.cs

示例6: Run

        public static void Run()
        {
            // ExStart:ExtractTextOnly
            Document doc = new Document();

            // Enter a dummy field into the document.
            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertField("MERGEFIELD Field");

            // GetText will retrieve all field codes and special characters
            Console.WriteLine("GetText() Result: " + doc.GetText());

            // ToString will export the node to the specified format. When converted to text it will not retrieve fields code 
            // Or special characters, but will still contain some natural formatting characters such as paragraph markers etc. 
            // This is the same as "viewing" the document as if it was opened in a text editor.
            Console.WriteLine("ToString() Result: " + doc.ToString(SaveFormat.Text));
            // ExEnd:ExtractTextOnly            
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:18,代码来源:ExtractTextOnly.cs

示例7: TestSingleContentTypeArray

        public void TestSingleContentTypeArray()
        {
            string[] arr = new string[]{"one", "two", "three", "four"};

            Document expected = new Document(){{"arr", arr}};
            Document read = WriteAndRead(expected);

            string json = @"{ ""arr"": [ ""one"", ""two"", ""three"", ""four"" ] }";
            Assert.AreEqual(json, expected.ToString());

            Assert.IsTrue(read["arr"] is IEnumerable<string>, "Array wasn't returned as IEnumerable<string>");

            Assert.AreEqual(json, read.ToString());
        }
开发者ID:kvnsmth,项目名称:mongodb-csharp,代码行数:14,代码来源:TestRoundTrips.cs

示例8: TestMultiDimensionalArray

        public void TestMultiDimensionalArray()
        {
            int[][] arr = new int[3][];
            for(int a = 0; a < arr.Length; a++){
                int x = a + 1;
                arr[a] = new int[]{x * 1, x * 2, x * 3};
            }

            Document expected = new Document(){{"arr", arr}};
            Document read = WriteAndRead(expected);

            Assert.AreEqual(expected.ToString(), read.ToString());
        }
开发者ID:kvnsmth,项目名称:mongodb-csharp,代码行数:13,代码来源:TestRoundTrips.cs

示例9: ShouldInsertRevisionPropertyInSpecificOrder

 public void ShouldInsertRevisionPropertyInSpecificOrder(string initialJson, string expectedJson)
 {
     var document = new Document(initialJson);
     document.Revision = "2-42";
     Assert.Equal(expectedJson, document.ToString());
 }
开发者ID:artikh,项目名称:CouchDude,代码行数:6,代码来源:DocumentTests.cs

示例10: ShouldInsertIdPropertyInSpecificOrder

 public void ShouldInsertIdPropertyInSpecificOrder(string initialJson, string expectedJson)
 {
     var document = new Document(initialJson);
     document.Id = "3849D9BC";
     Assert.Equal(expectedJson, document.ToString());
 }
开发者ID:artikh,项目名称:CouchDude,代码行数:6,代码来源:DocumentTests.cs

示例11: ShouldInsertTypePropertyInSpecificOrder

 public void ShouldInsertTypePropertyInSpecificOrder(string initialJson, string expectedJson)
 {
     var document = new Document(initialJson);
     document.Type = "complexEntity";
     Assert.Equal(expectedJson, document.ToString());
 }
开发者ID:artikh,项目名称:CouchDude,代码行数:6,代码来源:DocumentTests.cs

示例12: DocumentToJson

 public static String DocumentToJson(Document doc)
 {
     return doc.ToString();
 }
开发者ID:almostEric,项目名称:DotNetRDF-4.0,代码行数:4,代码来源:MongoDBHelper.cs

示例13: TestInsertOfArray

        public void TestInsertOfArray()
        {
            var ogen = new OidGenerator();
            var inserts = DB["inserts"];
            var album = new Document();
            album["_id"] = ogen.Generate();
            album["artist"] = "Popa Chubby";
            album["title"] = "Deliveries After Dark";
            album["songs"] = new[]
            {
                new Document().Add("title", "Let The Music Set You Free").Add("length", "5:15").Add("_id", ogen.Generate()),
                new Document().Add("title", "Sally Likes to Run").Add("length", "4:06").Add("_id", ogen.Generate()),
                new Document().Add("title", "Deliveries After Dark").Add("length", "4:17").Add("_id", ogen.Generate()),
                new Document().Add("title", "Theme From The Godfather").Add("length", "3:06").Add("_id", ogen.Generate()),
                new Document().Add("title", "Grown Man Crying Blues").Add("length", "8:09").Add("_id", ogen.Generate()),
            };
            inserts.Insert(album);

            var result = inserts.FindOne(new Document().Add("songs.title", "Deliveries After Dark"));
            Assert.IsNotNull(result);

            Assert.AreEqual(album.ToString(), result.ToString());
        }
开发者ID:nisbus,项目名称:mongodb-csharp,代码行数:23,代码来源:TestCollection.cs

示例14: GetDocExportStream

 /// <summary>
 /// Instead of DocumentsRequest.Download ; that function keeps returning a 404.
 /// </summary>
 /// <param name="doc"></param>
 /// <param name="downloadtype"></param>
 /// <returns></returns>
 private Stream GetDocExportStream(Document doc, Document.DownloadType downloadtype)
 {
     using (MiniProfiler.Current.Step("GoogleDocs.GetDocExportStream"))
     {
         string format = downloadtype.ToString();
         string url = doc.DocumentEntry.Content.AbsoluteUri + "&exportFormat=" + format + "&format=" + format;
         return m_request.Service.Query(new Uri(url));
     }
 }
开发者ID:overeemm,项目名称:gdocerous,代码行数:15,代码来源:GoogleDocs.cs

示例15: DocumentGetText_ToString

        public void DocumentGetText_ToString()
        {
            //ExStart
            //ExFor:CompositeNode.GetText
            //ExFor:Node.ToString(SaveFormat)
            //ExId:NodeTxtExportDifferences
            //ExSummary:Shows the difference between calling the GetText and ToString methods on a node.
            Document doc = new Document();

            // Enter a dummy field into the document.
            DocumentBuilder builder = new DocumentBuilder(doc);
            builder.InsertField("MERGEFIELD Field");

            // GetText will retrieve all field codes and special characters
            Console.WriteLine("GetText() Result: " + doc.GetText());

            // ToString will export the node to the specified format. When converted to text it will not retrieve fields code 
            // or special characters, but will still contain some natural formatting characters such as paragraph markers etc. 
            // This is the same as "viewing" the document as if it was opened in a text editor.
            Console.WriteLine("ToString() Result: " + doc.ToString(SaveFormat.Text));
            //ExEnd
        }
开发者ID:aspose-words,项目名称:Aspose.Words-for-.NET,代码行数:22,代码来源:ExDocument.cs


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