public void SerializeToBSON(BSONSerializer serializer, BSONDocument doc, IBSONSerializable parent, ref object context) { serializer.AddTypeIDField(doc, parent, this, context); var skipNull = (serializer.Flags ^ BSONSerializationFlags.KeepNull) == 0; doc.Add(serializer.PKFieldName, m_Guid, required: true) .Add(BSON_FLD_RELATED_TO, m_RelatedTo, skipNull) .Add(BSON_FLD_TYPE, m_Type.ToString(), skipNull, required: true) .Add(BSON_FLD_SOURCE, m_Source, skipNull) .Add(BSON_FLD_TIMESTAMP, m_TimeStamp.ToUniversalTime(), skipNull) .Add(BSON_FLD_HOST, m_Host, skipNull) .Add(BSON_FLD_FROM, m_From, skipNull) .Add(BSON_FLD_TOPIC, m_Topic, skipNull) .Add(BSON_FLD_TEXT, m_Text, skipNull) .Add(BSON_FLD_PARAMETERS, m_Parameters, skipNull) .Add(BSON_FLD_ARCHIVE_DIMENSIONS, m_ArchiveDimensions, skipNull) .Add(BSON_FLD_CHANNEL, m_Channel, skipNull); if (m_Exception == null) { return; } var we = m_Exception as WrappedException; if (we == null) { we = WrappedException.ForException(m_Exception); } doc.Add(BSON_FLD_EXCEPTION, serializer.Serialize(we, parent: this), skipNull); }
public override void SerializeToBSON(BSONSerializer serializer, BSONDocument doc, IBSONSerializable parent, ref object context) { base.SerializeToBSON(serializer, doc, parent, ref context); doc.Add(BSON_FLD_ENTITY, m_Entity); doc.Add(BSON_FLD_G_SHARD, m_G_Shard.ToString()); doc.Add(BSON_FLD_G_ENTITY, m_G_Entity.ToString()); doc.Add(BSON_FLD_DIMS, m_Dimensions); }
public virtual void SerializeToBSON(BSONSerializer serializer, BSONDocument doc, IBSONSerializable parent, ref object context) { serializer.AddTypeIDField(doc, parent, this, context); doc.Add(BSON_FLD_COUNT, m_Count) .Add(BSON_FLD_TIME, m_UTCTime); if (m_Count > 0) { doc.Add(BSON_FLD_END_TIME, m_UTCEndTime); } if ((serializer.Flags & BSONSerializationFlags.UIOnly) == 0) { doc.Add(BSON_FLD_SOURCE, Source); } }
public void SerializeToBSON(BSONSerializer serializer, BSONDocument doc, IBSONSerializable parent, ref object context) { serializer.AddTypeIDField(doc, parent, this, context); doc.Add(serializer.PKFieldName, Guid, required: true); doc.Add(BSON_FLD_TRUE, True); doc.Add(BSON_FLD_FALSE, False); doc.Add(BSON_FLD_CHARMIN, CharMin); doc.Add(BSON_FLD_CHARMAX, CharMax); doc.Add(BSON_FLD_SBYTEMIN, SByteMin); doc.Add(BSON_FLD_SBYTEMAX, SByteMax); doc.Add(BSON_FLD_BYTEMIN, ByteMin); doc.Add(BSON_FLD_BYTEMAX, ByteMax); doc.Add(BSON_FLD_INT16MIN, Int16Min); doc.Add(BSON_FLD_INT16MAX, Int16Max); doc.Add(BSON_FLD_UINT16MIN, UInt16Min); doc.Add(BSON_FLD_UINT16MAX, UInt16Max); doc.Add(BSON_FLD_INT32MIN, Int32Min); doc.Add(BSON_FLD_INT32MAX, Int32Max); doc.Add(BSON_FLD_UINT32MIN, UInt32Min); doc.Add(BSON_FLD_UINT32MAX, UInt32Max); doc.Add(BSON_FLD_INT64MIN, Int64Min); doc.Add(BSON_FLD_INT64MAX, Int64Max); doc.Add(BSON_FLD_UINT64MIN, UInt64Min); doc.Add(BSON_FLD_UINT64MAX, UInt64Max); doc.Add(BSON_FLD_SINGLEEPS, SingleEps); doc.Add(BSON_FLD_SINGLEMIN, SingleMin); doc.Add(BSON_FLD_SINGLEMAX, SingleMax); doc.Add(BSON_FLD_SINGLENAN, SingleNaN); doc.Add(BSON_FLD_SINGLEPOSINF, SinglePosInf); doc.Add(BSON_FLD_SINGLENEGINF, SingleNegInf); doc.Add(BSON_FLD_DOUBLEEPS, DoubleEps); doc.Add(BSON_FLD_DOUBLEMIN, DoubleMin); doc.Add(BSON_FLD_DOUBLEMAX, DoubleMax); doc.Add(BSON_FLD_DOUBLENAN, DoubleNaN); doc.Add(BSON_FLD_DOUBLEPOSINF, DoublePosInf); doc.Add(BSON_FLD_DOUBLENEGINF, DoubleNegInf); doc.Add(BSON_FLD_DECIMALMIN, DecimalMin); doc.Add(BSON_FLD_DECIMALMAX, DecimalMax); doc.Add(BSON_FLD_DECIMALZERO, DecimalZero); doc.Add(BSON_FLD_DECIMALONE, DecimalOne); doc.Add(BSON_FLD_DECIMALMONE, DecimalMOne); doc.Add(BSON_FLD_DATETIMEMIN, DateTimeMin); doc.Add(BSON_FLD_DATETIMEMAX, DateTimeMax); doc.Add(BSON_FLD_DATETIMENOW, DateTimeNow); doc.Add(BSON_FLD_DATETIMEUTC, DateTimeUtc); doc.Add(BSON_FLD_TIMESPANMIN, TimeSpanMin); doc.Add(BSON_FLD_TIMESPANMAX, TimeSpanMax); doc.Add(BSON_FLD_STRINGEMPTY, StringEmpty); doc.Add(BSON_FLD_STRINGNULL, StringNull); doc.Add(BSON_FLD_STRING, String); }
public override void SerializeToBSON(BSONSerializer serializer, BSONDocument doc, IBSONSerializable parent, ref object context) { base.SerializeToBSON(serializer, doc, parent, ref context); doc.Add(BSON_FLD_VALUE, m_Value); }
public override object Visit(BinaryExpression binary) { binary.NonNull(nameof(binary)); if (!binary.Operator.NonBlank(nameof(binary.Operator)).IsOneOf(Translator.BinaryOperators)) { throw new ASTException(StringConsts.AST_UNSUPPORTED_BINARY_OPERATOR_ERROR.Args(binary.Operator)); } var op = MapBinaryOperator(binary.Operator); var left = binary.LeftOperand .NonNull(nameof(binary.LeftOperand)) .Accept(this); var isNull = (binary.RightOperand == null || binary.RightOperand is ValueExpression ve && ve.Value == null); if (left is string identifier) //{identifier: {$lt: value} } { if (isNull) { return(new BSONDocumentElement(identifier, new BSONDocument().Set(new BSONNullElement(op)))); } var value = binary.RightOperand.Accept(this); var right = new BSONDocument(); if (value is IEnumerable vie) { //todo: need to handle array // var arr = vie.Cast<object>().Select( e => new BSONElement(e)); // right.Set(new BSONArrayElement(op, arr)); } else { try { right.Add(op, value, false, true); } catch { throwSyntaxErrorNear(binary, "unsupported RightOperand value `{0}`".Args(value == null ? "<null>" : value.GetType().Name)); } } return(new BSONDocumentElement(identifier, right)); } if (left is BSONElement complex) { BSONElement right = null; if (isNull) { throwSyntaxErrorNear(binary, "unexpected null in compound statement"); } else { right = binary.RightOperand.Accept(this) as BSONElement; if (right == null) { throwSyntaxErrorNear(binary, "unsupported RightOperand value"); } } return(new BSONArrayElement(op, new[] { complex, right })); } return(throwSyntaxErrorNear(binary, "unsupported construct")); }
public override void SerializeToBSON(BSONSerializer serializer, BSONDocument doc, IBSONSerializable parent, ref object context) { base.SerializeToBSON(serializer, doc, parent, ref context); doc.Add(BSON_FLD_EXCEPTION_TYPE, m_ExceptionType); }