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, this.GetType().Name); throw new BsonSerializationException(message); } var bsonType = bsonReader.CurrentBsonType; if (bsonType == BsonType.Document) { TriggerKey item; bsonReader.ReadStartDocument(); item = new TriggerKey( 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, IBsonSerializationOptions options) { CalendarWrapper 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) { 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")); IJobDetail jobDetail = new JobDetailImpl( bsonReader.ReadString("Name"), bsonReader.ReadString("Group"), jobType, bsonReader.ReadBoolean("RequestRecovery"), bsonReader.ReadBoolean("Durable")); 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, Type actualType, IBsonSerializationOptions options) { if (nominalType != typeof(JobDataMap) || actualType != typeof(JobDataMap)) { var message = string.Format("Can't deserialize a {0} with {1}.", nominalType.FullName, this.GetType().Name); throw new BsonSerializationException(message); } var bsonType = bsonReader.CurrentBsonType; if (bsonType == BsonType.Document) { JobDataMap item = new JobDataMap(); bsonReader.ReadStartDocument(); while (bsonReader.ReadBsonType() != BsonType.EndOfDocument) { string key = bsonReader.ReadName(); object value = BsonSerializer.Deserialize<object>(bsonReader); item.Add(key, value); } 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); } }