本文整理汇总了C#中MongoDB.Bson.IO.BsonWriter.WriteString方法的典型用法代码示例。如果您正苦于以下问题:C# BsonWriter.WriteString方法的具体用法?C# BsonWriter.WriteString怎么用?C# BsonWriter.WriteString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB.Bson.IO.BsonWriter
的用法示例。
在下文中一共展示了BsonWriter.WriteString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
if (value == null)
throw new PBException("serialize OXmlSimpleFieldElement value is null");
if (_trace)
pb.Trace.WriteLine("OXmlSimpleFieldElementSerializer.Serialize()");
OXmlSimpleFieldElement element = (OXmlSimpleFieldElement)value;
bsonWriter.WriteStartDocument();
bsonWriter.WriteString("Type", "SimpleField");
bsonWriter.WriteString("Instruction", element.Instruction);
bsonWriter.WriteEndDocument();
}
示例2: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
if (value == null)
throw new PBException("serialize OXmlOpenHeader value is null");
if (_trace)
pb.Trace.WriteLine("OXmlOpenHeaderElementSerializer.Serialize()");
OXmlOpenHeaderElement element = (OXmlOpenHeaderElement)value;
bsonWriter.WriteStartDocument();
bsonWriter.WriteString("Type", "OpenHeader");
bsonWriter.WriteString("HeaderType", element.HeaderType.ToString());
bsonWriter.WriteEndDocument();
}
示例3: Serialize
public void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
var method = (MethodInfo)value;
bsonWriter.WriteStartDocument();
bsonWriter.WriteName("Type");
bsonWriter.WriteString(method.DeclaringType.AssemblyQualifiedName);
bsonWriter.WriteName("Method");
bsonWriter.WriteString(GetMethodSignature(method));
bsonWriter.WriteEndDocument();
}
示例4: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
if (value == null)
throw new PBException("serialize OXmlParagraphElement value is null");
if (_trace)
pb.Trace.WriteLine("OXmlParagraphElementSerializer.Serialize()");
OXmlParagraphElement paragraph = (OXmlParagraphElement)value;
bsonWriter.WriteStartDocument();
bsonWriter.WriteString("Type", "Paragraph");
if (paragraph.Style != null)
bsonWriter.WriteString("Style", paragraph.Style);
bsonWriter.WriteEndDocument();
}
示例5: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
if (value == null)
throw new PBException("serialize OXmlTextElement value is null");
if (_trace)
pb.Trace.WriteLine("OXmlTextElementSerializer.Serialize()");
OXmlTextElement element = (OXmlTextElement)value;
bsonWriter.WriteStartDocument();
bsonWriter.WriteString("Type", "Text");
if (element.Text != null)
bsonWriter.WriteString("Text", element.Text);
if (element.PreserveSpace)
bsonWriter.WriteBoolean("PreserveSpace", element.PreserveSpace);
bsonWriter.WriteEndDocument();
}
示例6: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
var c = (C)value;
bsonWriter.WriteStartDocument();
bsonWriter.WriteString("nominalType", nominalType.Name);
bsonWriter.WriteInt32("X", c.X);
bsonWriter.WriteEndDocument();
}
示例7: Serialize
public override void Serialize(
BsonWriter bsonWriter,
Type nominalType,
object value,
IBsonSerializationOptions options
) {
var dateTime = (DateTime) value;
bsonWriter.WriteString(dateTime.ToString("yyyy-MM-dd"));
}
示例8: Serialize
public override void Serialize(
BsonWriter bsonWriter,
Type nominalType,
object value,
IBsonSerializationOptions options
)
{
var type = (Type)value;
bsonWriter.WriteString(type.AssemblyQualifiedName);
}
示例9: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType,
object value, IBsonSerializationOptions options)
{
if (value != null)
{
bsonWriter.WriteString(value.ToString());
}
else
{
bsonWriter.WriteNull();
}
}
示例10: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
if (value == null)
{
bsonWriter.WriteNull();
}
else
{
var crs = (GeoJsonLinkedCoordinateReferenceSystem)value;
bsonWriter.WriteStartDocument();
SerializeType(bsonWriter, crs.Type);
bsonWriter.WriteStartDocument("properties");
bsonWriter.WriteString("href", crs.HRef);
if (crs.HRefType != null)
{
bsonWriter.WriteString("type", crs.HRefType);
}
bsonWriter.WriteEndDocument();
bsonWriter.WriteEndDocument();
}
}
开发者ID:pwelter34,项目名称:mongo-csharp-driver,代码行数:22,代码来源:GeoJsonLinkedCoordinateReferenceSystemSerializer.cs
示例11: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
// when entry is null, do not throw, just write null
if (value == null)
{
bsonWriter.WriteNull();
return;
}
if (_failOnSerialize)
throw new InvalidOperationException();
bsonWriter.WriteString((string)value);
}
示例12: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
if (value == null)
{
throw new PBException("error serialize UrlImage value is null");
}
//bsonWriter.WriteString(((WebImage)value).Url);
string url = ((WebImage)value).Url;
if (url != null)
bsonWriter.WriteString(url);
else
bsonWriter.WriteNull();
}
示例13: Serialize
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
var identity = (Identity)value;
var objectId = new ObjectId(identity.ToArray());
BsonType bsonType = options == null ? BsonType.ObjectId : ((RepresentationSerializationOptions)options).Representation;
switch (bsonType)
{
case BsonType.String:
bsonWriter.WriteString(objectId.ToString());
break;
case BsonType.ObjectId:
bsonWriter.WriteObjectId(objectId.Timestamp, objectId.Machine, objectId.Pid, objectId.Increment);
break;
default:
throw new BsonSerializationException(string.Format("'{0}' is not a valid representation for type 'Identity'", bsonType));
}
}
示例14: Serialize
public override void Serialize(
BsonWriter bsonWriter,
Type nominalType,
object value,
IBsonSerializationOptions options
)
{
var nvc = (NameValueCollection)value;
bsonWriter.WriteStartDocument();
if (nvc != null && nvc.Count > 0)
{
foreach (var key in nvc.AllKeys)
{
bsonWriter.WriteString(key.Replace(".", "__period__"), nvc[key]);
}
}
bsonWriter.WriteEndDocument();
}
示例15: Serialize
/// <summary>
/// Serializes an object to a BsonWriter.
/// </summary>
/// <param name="bsonWriter">The BsonWriter.</param>
/// <param name="nominalType">The nominal type.</param>
/// <param name="value">The object.</param>
/// <param name="options">The serialization options.</param>
public override void Serialize(BsonWriter bsonWriter, Type nominalType, object value, IBsonSerializationOptions options)
{
if (_trace)
pb.Trace.WriteLine("ZStringSerializer.Serialize()");
if (value == null)
{
//throw new ArgumentNullException("value");
throw new PBException("error serialize ZString value is null");
}
string stringValue = ((ZString)value).Value;
if (stringValue == null)
bsonWriter.WriteNull();
else
bsonWriter.WriteString(stringValue);
}