private ClassMetadata ReadObjectHeader()
        {
            _objectHeader = new ObjectHeader(Container(), ByteArrayBuffer());
            ClassMetadata classMetadata = _objectHeader.ClassMetadata();

            if (classMetadata == null)
            {
                return(null);
            }
            return(classMetadata);
        }
Exemplo n.º 2
0
		public static Db4objects.Db4o.Internal.Marshall.ObjectHeader Defrag(DefragmentContextImpl
			 context)
		{
			ByteArrayBuffer source = context.SourceBuffer();
			ByteArrayBuffer target = context.TargetBuffer();
			Db4objects.Db4o.Internal.Marshall.ObjectHeader header = new Db4objects.Db4o.Internal.Marshall.ObjectHeader
				(context.Services().SystemTrans().Container(), null, source);
			int newID = context.Mapping().StrictMappedID(header.ClassMetadata().GetID());
			Db4objects.Db4o.Internal.Marshall.SlotFormat slotFormat = header.SlotFormat();
			slotFormat.WriteObjectClassID(target, newID);
			slotFormat.SkipMarshallerInfo(target);
			slotFormat.ReadHeaderAttributes(target);
			return header;
		}
Exemplo n.º 3
0
		public override ITypeHandler4 ReadCandidateHandler(QueryingReadContext context)
		{
			int id = 0;
			int offset = context.Offset();
			try
			{
				id = context.ReadInt();
			}
			catch (Exception)
			{
			}
			context.Seek(offset);
			if (id != 0)
			{
				StatefulBuffer reader = context.Container().ReadStatefulBufferById(context.Transaction
					(), id);
				if (reader != null)
				{
					ObjectHeader oh = new ObjectHeader(context.Container(), reader);
					try
					{
						if (oh.ClassMetadata() != null)
						{
							context.Buffer(reader);
							return oh.ClassMetadata().SeekCandidateHandler(context);
						}
					}
					catch (Exception e)
					{
					}
				}
			}
			// TODO: Check Exception Types
			// Errors typically occur, if classes don't match
			return null;
		}
Exemplo n.º 4
0
        public static Db4objects.Db4o.Internal.Marshall.ObjectHeader Defrag(DefragmentContextImpl
                                                                            context)
        {
            ByteArrayBuffer source = context.SourceBuffer();
            ByteArrayBuffer target = context.TargetBuffer();

            Db4objects.Db4o.Internal.Marshall.ObjectHeader header = new Db4objects.Db4o.Internal.Marshall.ObjectHeader
                                                                        (context.Services().SystemTrans().Container(), null, source);
            int newID = context.Mapping().StrictMappedID(header.ClassMetadata().GetID());

            Db4objects.Db4o.Internal.Marshall.SlotFormat slotFormat = header.SlotFormat();
            slotFormat.WriteObjectClassID(target, newID);
            slotFormat.SkipMarshallerInfo(target);
            slotFormat.ReadHeaderAttributes(target);
            return(header);
        }
Exemplo n.º 5
0
 public virtual Db4objects.Db4o.Internal.ClassMetadata ClassMetadata()
 {
     return(_objectHeader.ClassMetadata());
 }
Exemplo n.º 6
0
		public static void CollectIdsInternal(CollectIdContext context, ITypeHandler4 handler
			, int linkLength, bool doWithSlotIndirection)
		{
			if (!(IsCascading(handler)))
			{
				IReadBuffer buffer = context.Buffer();
				buffer.Seek(buffer.Offset() + linkLength);
				return;
			}
			if (handler is StandardReferenceTypeHandler)
			{
				context.AddId();
				return;
			}
			LocalObjectContainer container = (LocalObjectContainer)context.Container();
			SlotFormat slotFormat = context.SlotFormat();
			if (HandleAsObject(handler))
			{
				// TODO: Code is similar to QCandidate.readArrayCandidates. Try to refactor to one place.
				int collectionID = context.ReadInt();
				ByteArrayBuffer collectionBuffer = container.ReadBufferById(context.Transaction()
					, collectionID);
				ObjectHeader objectHeader = new ObjectHeader(container, collectionBuffer);
				QueryingReadContext subContext = new QueryingReadContext(context.Transaction(), context
					.HandlerVersion(), collectionBuffer, collectionID, context.Collector());
				objectHeader.ClassMetadata().CollectIDs(subContext);
				return;
			}
			QueryingReadContext queryingReadContext = new QueryingReadContext(context.Transaction
				(), context.HandlerVersion(), context.Buffer(), 0, context.Collector());
			IClosure4 collectIDsFromQueryingContext = new _IClosure4_263(handler, queryingReadContext
				);
			if (doWithSlotIndirection)
			{
				slotFormat.DoWithSlotIndirection(queryingReadContext, handler, collectIDsFromQueryingContext
					);
			}
			else
			{
				collectIDsFromQueryingContext.Run();
			}
		}
Exemplo n.º 7
0
 public virtual ClassMetadata ClassMetadata()
 {
     return(_objectHeader.ClassMetadata());
 }
Exemplo n.º 8
0
 internal virtual ClassMetadata ReadClassMetadata()
 {
     if (_classMetadata == null)
     {
         Read();
         if (_bytes != null)
         {
             Seek(0);
             ObjectContainerBase stream = Container();
             var objectHeader = new ObjectHeader(stream, _bytes);
             _classMetadata = objectHeader.ClassMetadata();
             if (_classMetadata != null)
             {
                 if (stream._handlers.IclassCompare.IsAssignableFrom(_classMetadata.ClassReflector
                     ()))
                 {
                     ReadThis(false);
                 }
             }
         }
     }
     return _classMetadata;
 }
Exemplo n.º 9
0
 // Scrolls offset in passed reader to the offset the passed field should
 // be read at.
 public HandlerVersion SeekToField(Transaction trans, ByteArrayBuffer buffer, FieldMetadata
     field)
 {
     if (buffer == null)
     {
         return HandlerVersion.Invalid;
     }
     if (!StandardReferenceTypeHandlerIsUsed())
     {
         return HandlerVersion.Invalid;
     }
     buffer.Seek(0);
     var oh = new ObjectHeader(_container, buffer);
     var res = oh.ClassMetadata().SeekToField(new ObjectHeaderContext(trans, buffer,
         oh), field);
     if (!res)
     {
         return HandlerVersion.Invalid;
     }
     return new HandlerVersion(oh.HandlerVersion());
 }
Exemplo n.º 10
0
 public static ClassMetadata ReadClass(ObjectContainerBase
     stream, ByteArrayBuffer reader)
 {
     var oh = new ObjectHeader(stream, reader);
     return oh.ClassMetadata();
 }
Exemplo n.º 11
0
		public static Db4objects.Db4o.Internal.ClassMetadata ReadClass(ObjectContainerBase
			 stream, ByteArrayBuffer reader)
		{
			ObjectHeader oh = new ObjectHeader(stream, reader);
			return oh.ClassMetadata();
		}
Exemplo n.º 12
0
 public void Visit(object treeInt)
 {
     var id = ((TreeInt) treeInt)._key;
     var reader = stream.ReadStatefulBufferById(_enclosing._enclosing.
         _trans, id);
     if (reader != null)
     {
         var oh = new ObjectHeader(stream, reader);
         var context = new CollectIdContext(_enclosing._enclosing._trans
             , oh, reader);
         oh.ClassMetadata().CollectIDs(context, fieldName);
         Tree.Traverse(context.Ids(), new _IVisitor4_394(idsNew));
     }
 }
Exemplo n.º 13
0
				public void Visit(object treeInt)
				{
					int id = ((TreeInt)treeInt)._key;
					StatefulBuffer buffer = this._enclosing._container.ReadStatefulBufferById(this._enclosing
						._trans, id);
					if (buffer != null)
					{
						ObjectHeader oh = new ObjectHeader(this._enclosing._container, buffer);
						CollectIdContext context = new CollectIdContext(this._enclosing._trans, oh, buffer
							);
						oh.ClassMetadata().CollectIDs(context, fieldName);
						Tree.Traverse(context.Ids(), new _IVisitor4_516(idsNew));
					}
				}
Exemplo n.º 14
0
		private object ReadIndexEntryForRebuild(StatefulBuffer writer, ObjectHeader oh)
		{
			ClassMetadata classMetadata = oh.ClassMetadata();
			if (classMetadata == null)
			{
				return DefaultValueForFieldType();
			}
			ObjectIdContextImpl context = new ObjectIdContextImpl(writer.Transaction(), writer
				, oh, writer.GetID());
			if (!classMetadata.SeekToField(context, this))
			{
				return DefaultValueForFieldType();
			}
			try
			{
				return ReadIndexEntry(context);
			}
			catch (CorruptionException exc)
			{
				throw new FieldIndexException(exc, this);
			}
		}
		private ClassMetadata ReadObjectHeader()
		{
			_objectHeader = new ObjectHeader(Container(), ByteArrayBuffer());
			ClassMetadata classMetadata = _objectHeader.ClassMetadata();
			if (classMetadata == null)
			{
				return null;
			}
			return classMetadata;
		}