public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options) { if (nominalType != typeof(JobKey) || actualType != typeof(JobKey)) { throw new BsonSerializationException( string.Format("Can't deserialize a {0} from {1}.", nominalType.FullName, GetType().Name)); } var bsonType = bsonReader.CurrentBsonType; switch (bsonType) { case BsonType.Document: bsonReader.ReadStartDocument(); var item = new JobKey(bsonReader.ReadString("Name"), bsonReader.ReadString("Group")); bsonReader.ReadEndDocument(); return(item); case BsonType.Null: bsonReader.ReadNull(); return(null); default: throw new BsonSerializationException( string.Format("Can't deserialize a {0} from BsonType {1}.", nominalType.FullName, bsonType)); } }
public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options) { if (nominalType != typeof(JobKey) || actualType != typeof(JobKey)) { var message = string.Format("Can't deserialize a {0} from {1}.", nominalType.FullName, this.GetType().Name); throw new BsonSerializationException(message); } var bsonType = bsonReader.CurrentBsonType; if (bsonType == BsonType.Document) { JobKey item; bsonReader.ReadStartDocument(); item = new JobKey( bsonReader.ReadString("Name"), bsonReader.ReadString("Group")); bsonReader.ReadEndDocument(); return(item); } else if (bsonType == BsonType.Null) { bsonReader.ReadNull(); return(null); } else { var message = string.Format("Can't deserialize a {0} from BsonType {1}.", nominalType.FullName, bsonType); throw new BsonSerializationException(message); } }
public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options) { if (nominalType != typeof(TriggerKey) || actualType != typeof(TriggerKey)) { var message = string.Format("Can't deserialize a {0} from {1}.", nominalType.FullName, GetType().Name); throw new BsonSerializationException(message); } var bsonType = bsonReader.CurrentBsonType; switch (bsonType) { case BsonType.Document: bsonReader.ReadStartDocument(); string name = bsonReader.ReadString("Name"); string group = bsonReader.ReadString("Group"); bsonReader.ReadEndDocument(); return(new TriggerKey(name, group)); case BsonType.Null: bsonReader.ReadNull(); return(null); default: var message = string.Format("Can't deserialize a {0} from BsonType {1}.", nominalType.FullName, bsonType); throw new BsonSerializationException(message); } }
public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options) { if (!nominalType.IsAssignableFrom(typeof(JobDetailImpl)) || actualType != typeof(JobDetailImpl)) { var message = string.Format("Can't deserialize a {0} with {1}.", nominalType.FullName, this.GetType().Name); throw new BsonSerializationException(message); } var bsonType = bsonReader.GetCurrentBsonType(); if (bsonType == BsonType.Document) { bsonReader.ReadStartDocument(); BsonSerializer.Deserialize(bsonReader, typeof(JobKey)); bsonReader.ReadString("_t"); Assembly assembly = Assembly.Load(bsonReader.ReadString("_assembly")); Type jobType = assembly.GetType(bsonReader.ReadString("_class")); string name = bsonReader.ReadString("Name"); string group = bsonReader.ReadString("Group"); bool requestRecovery = bsonReader.ReadBoolean("RequestRecovery"); bool durable = bsonReader.ReadBoolean("Durable"); IJobDetail jobDetail = new JobDetailImpl(name, group, jobType, durable, requestRecovery); bsonReader.ReadBsonType(); JobDataMap map = (JobDataMap)BsonSerializer.Deserialize(bsonReader, typeof(JobDataMap)); /*bsonReader.ReadBsonType(); * string description = (string)BsonSerializer.Deserialize(bsonReader, typeof(string));*/ jobDetail = jobDetail.GetJobBuilder() .UsingJobData(map) /*.WithDescription(description)*/ .Build(); bsonReader.ReadEndDocument(); return(jobDetail); } else if (bsonType == BsonType.Null) { bsonReader.ReadNull(); return(null); } else { var message = string.Format("Can't deserialize a {0} from BsonType {1}.", nominalType.FullName, bsonType); throw new BsonSerializationException(message); } }
public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, IBsonSerializationOptions options) { var item = new CalendarWrapper(); bsonReader.ReadStartDocument(); item.Name = bsonReader.ReadString("_id"); var binaryData = bsonReader.ReadBinaryData("ContentStream"); item.Calendar = (ICalendar) new BinaryFormatter().Deserialize(new MemoryStream(binaryData.Bytes)); bsonReader.ReadEndDocument(); return(item); }
public object Deserialize(global::MongoDB.Bson.IO.BsonReader bsonReader, Type nominalType, Type actualType, IBsonSerializationOptions options) { string message; if (nominalType != typeof(JobDataMap) || actualType != typeof(JobDataMap)) { message = string.Format("Can't deserialize a {0} with {1}.", nominalType.FullName, GetType().Name); throw new BsonSerializationException(message); } var bsonType = bsonReader.CurrentBsonType; switch (bsonType) { case BsonType.Document: var item = new JobDataMap(); bsonReader.ReadStartDocument(); while (bsonReader.ReadBsonType() != BsonType.EndOfDocument) { string key = bsonReader.ReadName(); var value = BsonSerializer.Deserialize <object>(bsonReader); item.Add(key, value); } bsonReader.ReadEndDocument(); return(item); case BsonType.Null: bsonReader.ReadNull(); return(null); default: message = string.Format("Can't deserialize a {0} from BsonType {1}.", nominalType.FullName, bsonType); throw new BsonSerializationException(message); } }