public virtual void Write(IWriteContext context, object obj) { IDictionary map = (IDictionary)obj; KeyValueHandlerPair handlers = DetectKeyValueTypeHandlers(Container(context), map ); WriteClassMetadataIds(context, handlers); WriteElementCount(context, map); WriteElements(context, map, handlers); }
public virtual void Defragment(IDefragmentContext context) { KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context); int elementCount = context.ReadInt(); for (int i = elementCount; i > 0; i--) { context.Defragment(handlers._keyHandler); context.Defragment(handlers._valueHandler); } }
public virtual void CollectIDs(QueryingReadContext context) { KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context); int elementCount = context.ReadInt(); for (int i = 0; i < elementCount; i++) { context.ReadId(handlers._keyHandler); context.SkipId(handlers._valueHandler); } }
private void WriteElements(IWriteContext context, IDictionary map, KeyValueHandlerPair handlers) { IEnumerator elements = map.Keys.GetEnumerator(); while (elements.MoveNext()) { object key = elements.Current; context.WriteObject(handlers._keyHandler, key); context.WriteObject(handlers._valueHandler, map[key]); } }
private void WriteElements(IWriteContext context, IDictionary map, KeyValueHandlerPair handlers) { IEnumerator elements = map.GetEnumerator(); while (elements.MoveNext()) { DictionaryEntry entry = (DictionaryEntry)elements.Current; context.WriteObject(handlers._keyHandler, entry.Key); context.WriteObject(handlers._valueHandler, entry.Value); } }
/// <exception cref="Db4objects.Db4o.Ext.Db4oIOException"></exception> public virtual void Delete(IDeleteContext context) { if (!context.CascadeDelete()) { return; } KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context); int elementCount = context.ReadInt(); for (int i = elementCount; i > 0; i--) { handlers._keyHandler.Delete(context); handlers._valueHandler.Delete(context); } }
public virtual void Activate(IReferenceActivationContext context) { UnmarshallingContext unmarshallingContext = (UnmarshallingContext)context; IDictionary map = (IDictionary)unmarshallingContext.PersistentObject(); map.Clear(); KeyValueHandlerPair handlers = ReadKeyValueTypeHandlers(context, context); int elementCount = context.ReadInt(); for (int i = 0; i < elementCount; i++) { object key = unmarshallingContext.ReadFullyActivatedObjectForKeys(handlers._keyHandler ); if (key == null && !unmarshallingContext.LastReferenceReadWasReallyNull()) { continue; } object value = context.ReadObject(handlers._valueHandler); map[key] = value; } }
private void WriteClassMetadataIds(IWriteContext context, KeyValueHandlerPair handlers ) { context.WriteInt(0); context.WriteInt(0); }