Пример #1
0
        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);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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]);
            }
        }
Пример #5
0
        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);
            }
        }
Пример #6
0
        /// <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);
            }
        }
Пример #7
0
        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;
            }
        }
Пример #8
0
 private void WriteClassMetadataIds(IWriteContext context, KeyValueHandlerPair handlers
                                    )
 {
     context.WriteInt(0);
     context.WriteInt(0);
 }