本文整理汇总了C#中Lucene.Net.Documents.Field.IsBinary方法的典型用法代码示例。如果您正苦于以下问题:C# Field.IsBinary方法的具体用法?C# Field.IsBinary怎么用?C# Field.IsBinary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Lucene.Net.Documents.Field
的用法示例。
在下文中一共展示了Field.IsBinary方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestBinaryField
public virtual void TestBinaryField()
{
Document doc = new Document();
Fieldable stringFld = new Field("string", binaryVal, Field.Store.YES, Field.Index.NO);
Fieldable binaryFld = new Field("binary", System.Text.UTF8Encoding.UTF8.GetBytes(binaryVal), Field.Store.YES);
Fieldable binaryFld2 = new Field("binary", System.Text.UTF8Encoding.UTF8.GetBytes(binaryVal2), Field.Store.YES);
doc.Add(stringFld);
doc.Add(binaryFld);
Assert.AreEqual(2, doc.fields_ForNUnit.Count);
Assert.IsTrue(binaryFld.IsBinary());
Assert.IsTrue(binaryFld.IsStored());
Assert.IsFalse(binaryFld.IsIndexed());
Assert.IsFalse(binaryFld.IsTokenized());
System.String binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(doc.GetBinaryValue("binary")));
Assert.IsTrue(binaryTest.Equals(binaryVal));
System.String stringTest = doc.Get("string");
Assert.IsTrue(binaryTest.Equals(stringTest));
doc.Add(binaryFld2);
Assert.AreEqual(3, doc.fields_ForNUnit.Count);
byte[][] binaryTests = doc.GetBinaryValues("binary");
Assert.AreEqual(2, binaryTests.Length);
binaryTest = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[0]));
System.String binaryTest2 = new System.String(System.Text.UTF8Encoding.UTF8.GetChars(binaryTests[1]));
Assert.IsFalse(binaryTest.Equals(binaryTest2));
Assert.IsTrue(binaryTest.Equals(binaryVal));
Assert.IsTrue(binaryTest2.Equals(binaryVal2));
doc.RemoveField("string");
Assert.AreEqual(2, doc.fields_ForNUnit.Count);
doc.RemoveFields("binary");
Assert.AreEqual(0, doc.fields_ForNUnit.Count);
}
示例2: CreateProperty
private static KeyValuePair<string, RavenJToken> CreateProperty(Field fld, Document document)
{
if(fld.IsBinary())
return new KeyValuePair<string, RavenJToken>(fld.Name(), fld.GetBinaryValue());
var stringValue = fld.StringValue();
if (document.GetField(fld.Name() + "_ConvertToJson") != null)
{
var val = RavenJToken.Parse(fld.StringValue()) as RavenJObject;
return new KeyValuePair<string, RavenJToken>(fld.Name(), val);
}
if (stringValue == Constants.NullValue)
stringValue = null;
if (stringValue == Constants.EmptyString)
stringValue = string.Empty;
return new KeyValuePair<string, RavenJToken>(fld.Name(), stringValue);
}