本文整理汇总了C#中SolrDocumentSerializer.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# SolrDocumentSerializer.Serialize方法的具体用法?C# SolrDocumentSerializer.Serialize怎么用?C# SolrDocumentSerializer.Serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SolrDocumentSerializer
的用法示例。
在下文中一共展示了SolrDocumentSerializer.Serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SupportsDateTime
public void SupportsDateTime() {
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<TestDocWithDate>(mapper, new DefaultFieldSerializer());
var doc = new TestDocWithDate {Date = new DateTime(2001, 1, 2, 3, 4, 5)};
string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
Assert.AreEqual("<doc><field name=\"Date\">2001-01-02T03:04:05Z</field></doc>", fs);
}
示例2: EscapesStrings
public void EscapesStrings() {
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
var doc = new SampleDoc {Id = "<quote\""};
string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
Assert.AreEqual("<doc><field name=\"Id\"><quote\"</field><field name=\"Flower\">0</field></doc>", fs);
}
示例3: AcceptsEmptyCollections
public void AcceptsEmptyCollections() {
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<TestDocWithCollections>(mapper, new DefaultFieldSerializer());
var doc = new TestDocWithCollections { coll = new string[] { null, null } };
string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
Assert.AreEqual("<doc />", fs);
}
示例4: AcceptsSparseCollections
public void AcceptsSparseCollections() {
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<TestDocWithCollections>(mapper, new DefaultFieldSerializer());
var doc = new TestDocWithCollections { coll = new[] { "one", null, "two" } };
string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
Assert.AreEqual("<doc><field name=\"coll\">one</field><field name=\"coll\">two</field></doc>", fs);
}
示例5: SupportsBoolTrue
public void SupportsBoolTrue() {
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<TestDocWithBool>(mapper, new DefaultFieldSerializer());
var doc = new TestDocWithBool {B = true};
string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
Assert.AreEqual("<doc><field name=\"B\">true</field></doc>", fs);
}
示例6: AcceptsNullObjects
public void AcceptsNullObjects()
{
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
var doc = new SampleDoc {Id = null};
ser.Serialize(doc, null).ToString();
}
示例7: FieldBoost
public void FieldBoost()
{
var mapper = new AttributesMappingManager();
ISolrDocumentSerializer<TestDocWithBoostedString> ser = new SolrDocumentSerializer<TestDocWithBoostedString>(mapper, new DefaultFieldSerializer());
var doc = new TestDocWithBoostedString {
Desc = "hello"
};
string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
Assert.AreEqual(@"<doc><field name=""Desc"" boost=""1.45"">hello</field></doc>", fs);
}
示例8: Serializes
public void Serializes()
{
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
var doc = new SampleDoc {Id = "id", Dd = 23.5m};
string fs = ser.Serialize(doc, null).OuterXml;
var xml = new XmlDocument();
xml.LoadXml(fs);
Assert.AreEqual("<doc><field name=\"Id\">id</field><field name=\"Flower\">23.5</field></doc>", fs);
}
示例9: AcceptsNullObjects
public void AcceptsNullObjects()
{
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
var doc = new SampleDoc {Id = null};
string fs = ser.Serialize(doc, null).OuterXml;
Console.WriteLine(fs);
var xml = new XmlDocument();
xml.LoadXml(fs);
}
示例10: EscapesStrings
public void EscapesStrings()
{
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<SampleDoc>(mapper, new DefaultFieldSerializer());
var doc = new SampleDoc {Id = "<quote\""};
string fs = ser.Serialize(doc, null).OuterXml;
Console.WriteLine(fs);
var xml = new XmlDocument();
xml.LoadXml(fs);
Assert.AreEqual("<doc><field name=\"Id\"><quote\"</field><field name=\"Flower\">0</field></doc>", fs);
}
示例11: DocumentBoost
public void DocumentBoost()
{
var mapper = new AttributesMappingManager();
ISolrDocumentSerializer<TestDocWithString> ser = new SolrDocumentSerializer<TestDocWithString>(mapper, new DefaultFieldSerializer());
var doc = new TestDocWithString {
Desc = "hello"
};
string fs = ser.Serialize(doc, 2.1).OuterXml;
var xml = new XmlDocument();
xml.LoadXml(fs);
Console.WriteLine(fs);
Assert.AreEqual(@"<doc boost=""2.1""><field name=""Desc"">hello</field></doc>", fs);
}
示例12: Inheritance
public void Inheritance()
{
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<TestDocWithString>(mapper, new DefaultFieldSerializer());
var doc = new InheritedDoc {
Desc = "Description",
Desc1 = "Description1"
};
string fs = ser.Serialize(doc, null).OuterXml;
var xml = new XmlDocument();
xml.LoadXml(fs);
Console.WriteLine(fs);
Assert.AreEqual(@"<doc><field name=""Desc1"">Description1</field><field name=""Desc"">Description</field></doc>", fs);
}
示例13: Location
public void Location() {
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<TestDocWithLocation>(mapper, new DefaultFieldSerializer());
var testDoc = new TestDocWithLocation { Loc = new Location(12.2, -12.3) };
string fs = ser.Serialize(testDoc, null).ToString(SaveOptions.DisableFormatting);
Assert.AreEqual(@"<doc><field name=""location"">12.2,-12.3</field></doc>", fs);
}
示例14: PropertyWithoutGetter
public void PropertyWithoutGetter() {
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<TestDocWithoutGetter>(mapper, new DefaultFieldSerializer());
string fs = ser.Serialize(new TestDocWithoutGetter(), null).ToString();
}
示例15: Inheritance
public void Inheritance() {
var mapper = new AttributesMappingManager();
var ser = new SolrDocumentSerializer<TestDocWithString>(mapper, new DefaultFieldSerializer());
var doc = new InheritedDoc {
Desc = "Description",
Desc1 = "Description1"
};
string fs = ser.Serialize(doc, null).ToString(SaveOptions.DisableFormatting);
Assert.AreEqual(@"<doc><field name=""Desc1"">Description1</field><field name=""Desc"">Description</field></doc>", fs);
}