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


C# SolrDocumentSerializer类代码示例

本文整理汇总了C#中SolrDocumentSerializer的典型用法代码示例。如果您正苦于以下问题:C# SolrDocumentSerializer类的具体用法?C# SolrDocumentSerializer怎么用?C# SolrDocumentSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: 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);
		}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:7,代码来源:SolrDocumentSerializerTests.cs

示例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\">&lt;quote\"</field><field name=\"Flower\">0</field></doc>", fs);
		}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:7,代码来源:SolrDocumentSerializerTests.cs

示例3: 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);
		}
开发者ID:Jo1nes,项目名称:SolrNet,代码行数:7,代码来源:SolrDocumentSerializerTests.cs

示例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);
		}
开发者ID:FilipVV,项目名称:SolrNet,代码行数:7,代码来源:SolrDocumentSerializerTests.cs

示例5: 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);
		}
开发者ID:FilipVV,项目名称:SolrNet,代码行数:7,代码来源:SolrDocumentSerializerTests.cs

示例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();
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:7,代码来源:SolrDocumentSerializerTests.cs

示例7: Add

 public void Add()
 {
     var mocks = new MockRepository();
     var connection = mocks.StrictMock<ISolrConnection>();
     var executer = mocks.StrictMock<ISolrQueryExecuter<TestDocumentWithoutUniqueKey>>();
     var headerParser = mocks.StrictMock<ISolrHeaderResponseParser>();
     var docSerializer = new SolrDocumentSerializer<TestDocumentWithoutUniqueKey>(new AttributesMappingManager(), new DefaultFieldSerializer());
     With.Mocks(mocks)
         .Expecting(() => {
             Expect.On(connection)
                 .Call(connection.Post("/update", "<add><doc /></add>"))
                 .Repeat.Once()
                 .Return(EmbeddedResource.GetEmbeddedString(GetType(), "Resources.response.xml"));
             Expect.On(headerParser)
                 .Call(headerParser.Parse(null))
                 .IgnoreArguments()
                 .Return(new ResponseHeader());
         })
         .Verify(() => {
             var ops = new SolrBasicServer<TestDocumentWithoutUniqueKey>(connection, executer, docSerializer, null, headerParser, null, null, null);
             ops.AddWithBoost(new[] {
                 new KeyValuePair<TestDocumentWithoutUniqueKey, double?>(new TestDocumentWithoutUniqueKey(), null),
             }, null);
         });
 }
开发者ID:Cort01,项目名称:SolrNet,代码行数:25,代码来源:SolrOperationsTests.cs

示例8: 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);
 }
开发者ID:tkristiansen,项目名称:SolrNet,代码行数:10,代码来源:SolrDocumentSerializerTests.cs

示例9: 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);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:10,代码来源:SolrDocumentSerializerTests.cs

示例10: 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);
 }
开发者ID:tkristiansen,项目名称:SolrNet,代码行数:10,代码来源:SolrDocumentSerializerTests.cs

示例11: 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\">&lt;quote\"</field><field name=\"Flower\">0</field></doc>", fs);
 }
开发者ID:tkristiansen,项目名称:SolrNet,代码行数:11,代码来源:SolrDocumentSerializerTests.cs

示例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).ToString(SaveOptions.DisableFormatting);
     Assert.AreEqual(@"<doc><field name=""Desc1"">Description1</field><field name=""Desc"">Description</field></doc>", fs);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:11,代码来源:SolrDocumentSerializerTests.cs

示例13: DocumentAddParametersOverwriteSpecifiedTrue

 public void DocumentAddParametersOverwriteSpecifiedTrue()
 {
     var docSerializer = new SolrDocumentSerializer<TestDocWithString>(new AttributesMappingManager(), new DefaultFieldSerializer());
     var conn = new Mocks.MSolrConnection();
     conn.post = conn.post
         .Args("/update", "<add overwrite=\"true\"><doc boost=\"2.1\" /></add>");
     var docs = new[] { new KeyValuePair<TestDocWithString, double?>(new TestDocWithString(), 2.1) };
     var parameters = new AddParameters { Overwrite = true };
     var cmd = new AddCommand<TestDocWithString>(docs, docSerializer, parameters);
     cmd.Execute(conn);
     Assert.AreEqual(1, conn.post.Calls);
 }
开发者ID:nicholaspei,项目名称:SoleCloudNet,代码行数:12,代码来源:AddCommandTests.cs

示例14: 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);
 }
开发者ID:tkristiansen,项目名称:SolrNet,代码行数:13,代码来源:SolrDocumentSerializerTests.cs

示例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).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);
 }
开发者ID:7digital,项目名称:SolrNet,代码行数:14,代码来源:SolrDocumentSerializerTests.cs


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