/// <summary>Serialize a given Object to VelocyPack.</summary> /// <remarks> /// Serialize a given Object to VelocyPack. This method is for serialization of types with generic parameter like /// Collection, List, Map. /// </remarks> /// <param name="entity">The Object to serialize</param> /// <param name="type">The source type of the Object.</param> /// <param name="serializeNullValues">Whether or not null values should be excluded from serialization. /// </param> /// <returns>the serialized VelocyPack</returns> /// <exception cref="ArangoDBException"/> public virtual VPackSlice Serialize(object entity, global::System.Type type, bool serializeNullValues) { try { VPack vp = serializeNullValues ? this.vpackerNull : this.vpacker; return(vp.serialize(entity, type)); } catch (VPackException e) { throw new ArangoDBException(e); } }
/// <summary>Serialize a given Object to VelocyPack</summary> /// <param name="entity">The Object to serialize. If it is from type String, it will be handled as a Json. /// </param> /// <param name="serializeNullValues">Whether or not null values should be excluded from serialization. /// </param> /// <returns>the serialized VelocyPack</returns> /// <exception cref="ArangoDBException"/> public virtual VPackSlice Serialize(object entity, bool serializeNullValues) { try { VPackSlice vpack; if (entity is string || typeof(string).IsCastableTo(entity.GetType()) || typeof(string).IsCastableTo(entity.GetType(), true)) { vpack = this.vpackParser.fromJson((string)entity, serializeNullValues); } else { VPack vp = serializeNullValues ? this.vpackerNull : this.vpacker; vpack = vp.serialize(entity); } return(vpack); } catch (VPackException e) { throw new ArangoDBException(e); } }