本文整理汇总了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);
}
示例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));
}
示例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());
}
示例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());
}
示例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());
}
示例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
}
示例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());
}
示例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());
}
示例9: ShouldInsertRevisionPropertyInSpecificOrder
public void ShouldInsertRevisionPropertyInSpecificOrder(string initialJson, string expectedJson)
{
var document = new Document(initialJson);
document.Revision = "2-42";
Assert.Equal(expectedJson, document.ToString());
}
示例10: ShouldInsertIdPropertyInSpecificOrder
public void ShouldInsertIdPropertyInSpecificOrder(string initialJson, string expectedJson)
{
var document = new Document(initialJson);
document.Id = "3849D9BC";
Assert.Equal(expectedJson, document.ToString());
}
示例11: ShouldInsertTypePropertyInSpecificOrder
public void ShouldInsertTypePropertyInSpecificOrder(string initialJson, string expectedJson)
{
var document = new Document(initialJson);
document.Type = "complexEntity";
Assert.Equal(expectedJson, document.ToString());
}
示例12: DocumentToJson
public static String DocumentToJson(Document doc)
{
return doc.ToString();
}
示例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());
}
示例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));
}
}
示例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
}