private void DeserializeDictionary(Type K, Type T, IDictionary dict, BsonDocument value) { foreach (var el in value.GetElements()) { var k = K.IsEnum ? Enum.Parse(K, el.Key) : Convert.ChangeType(el.Key, K); var v = this.Deserialize(T, el.Value); dict.Add(k, v); } }
private void DeserializeDictionary(Type K, Type T, IDictionary dict, BsonDocument value) { var isKEnum = K.GetTypeInfo().IsEnum; foreach (var el in value.GetElements()) { var k = isKEnum ? Enum.Parse(K, el.Key) : K == typeof(Uri) ? new Uri(el.Key) : Convert.ChangeType(el.Key, K); var v = this.Deserialize(T, el.Value); dict.Add(k, v); } }
private void WriteObject(BsonDocument obj) { var length = obj.Keys.Count(); var hasData = length > 0; this.WriteStartBlock("{", hasData); var index = 0; foreach (var el in obj.GetElements()) { this.WriteKeyValue(el.Key, el.Value, index++ < length - 1); } this.WriteEndBlock("}", hasData); }