Exemple #1
0
        public static void Defragment(IDefragmentContext context, ArrayHandler handler)
        {
            int sourceAddress = context.SourceBuffer().ReadInt();
            int length        = context.SourceBuffer().ReadInt();

            if (sourceAddress == 0 && length == 0)
            {
                context.TargetBuffer().WriteInt(0);
                context.TargetBuffer().WriteInt(0);
                return;
            }
            Slot            slot         = context.AllocateMappedTargetSlot(sourceAddress, length);
            ByteArrayBuffer sourceBuffer = null;

            try
            {
                sourceBuffer = context.SourceBufferByAddress(sourceAddress, length);
            }
            catch (IOException exc)
            {
                throw new Db4oIOException(exc);
            }
            DefragmentContextImpl payloadContext = new DefragmentContextImpl(sourceBuffer, (DefragmentContextImpl
                                                                                            )context);

            handler.DefragmentSlot(payloadContext);
            payloadContext.WriteToTarget(slot.Address());
            context.TargetBuffer().WriteInt(slot.Address());
            context.TargetBuffer().WriteInt(length);
        }
 public PreparedArrayContainsComparison(IContext context, ArrayHandler arrayHandler
     , ITypeHandler4 typeHandler, object obj)
 {
     _arrayHandler = arrayHandler;
     _preparedComparison = Handlers4.PrepareComparisonFor(typeHandler, context, obj);
     _container = context.Transaction().Container();
 }
		public static void Defragment(IDefragmentContext context, ArrayHandler handler)
		{
			int sourceAddress = context.SourceBuffer().ReadInt();
			int length = context.SourceBuffer().ReadInt();
			if (sourceAddress == 0 && length == 0)
			{
				context.TargetBuffer().WriteInt(0);
				context.TargetBuffer().WriteInt(0);
				return;
			}
			Slot slot = context.AllocateMappedTargetSlot(sourceAddress, length);
			ByteArrayBuffer sourceBuffer = null;
			try
			{
				sourceBuffer = context.SourceBufferByAddress(sourceAddress, length);
			}
			catch (IOException exc)
			{
				throw new Db4oIOException(exc);
			}
			DefragmentContextImpl payloadContext = new DefragmentContextImpl(sourceBuffer, (DefragmentContextImpl
				)context);
			handler.DefragmentSlot(payloadContext);
			payloadContext.WriteToTarget(slot.Address());
			context.TargetBuffer().WriteInt(slot.Address());
			context.TargetBuffer().WriteInt(length);
		}
 public _IRunnable_80(ArrayHandler _enclosing, AbstractBufferContext context, ArrayInfo
                      info, IRunnable elementRunnable)
 {
     this._enclosing      = _enclosing;
     this.context         = context;
     this.info            = info;
     this.elementRunnable = elementRunnable;
 }
        public virtual object DeepClone(object context)
        {
            TypeHandlerCloneContext typeHandlerCloneContext = (TypeHandlerCloneContext)context;

            Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler original = (Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler
                                                                             )typeHandlerCloneContext.original;
            Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler cloned = (Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler
                                                                           )Reflection4.NewInstance(this);
            cloned._usePrimitiveClassReflector = original._usePrimitiveClassReflector;
            cloned._handler = typeHandlerCloneContext.CorrectHandlerVersion(original.DelegateTypeHandler
                                                                                ());
            return(cloned);
        }
 //int length = a_bytes.readInt();
 public override bool Equals(object obj)
 {
     if (!(obj is Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler))
     {
         return(false);
     }
     Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler other = (Db4objects.Db4o.Internal.Handlers.Array.ArrayHandler
                                                                   )obj;
     if (other.Identifier() != Identifier())
     {
         return(false);
     }
     if (_handler == null)
     {
         return(other._handler == null);
     }
     return(_handler.Equals(other._handler) && _usePrimitiveClassReflector == other._usePrimitiveClassReflector);
 }
 public virtual void TestCorrectHandlerVersion()
 {
     var openTypeHandler = new OpenTypeHandler(Container());
     AssertCorrectedHandlerVersion(typeof (OpenTypeHandler0), openTypeHandler, -1);
     AssertCorrectedHandlerVersion(typeof (OpenTypeHandler0), openTypeHandler, 0);
     AssertCorrectedHandlerVersion(typeof (OpenTypeHandler2), openTypeHandler, 1);
     AssertCorrectedHandlerVersion(typeof (OpenTypeHandler2), openTypeHandler, 2);
     AssertCorrectedHandlerVersion(typeof (OpenTypeHandler), openTypeHandler, HandlerRegistry
         .HandlerVersion);
     AssertCorrectedHandlerVersion(typeof (OpenTypeHandler), openTypeHandler, HandlerRegistry
         .HandlerVersion + 1);
     var stdReferenceHandler = new StandardReferenceTypeHandler
         (ItemClassMetadata());
     AssertCorrectedHandlerVersion(typeof (StandardReferenceTypeHandler0), stdReferenceHandler
         , 0);
     AssertCorrectedHandlerVersion(typeof (StandardReferenceTypeHandler), stdReferenceHandler
         , 2);
     var primitiveMetadata = new PrimitiveTypeMetadata(Container(),
         openTypeHandler, 0, null);
     AssertPrimitiveHandlerDelegate(typeof (OpenTypeHandler0), primitiveMetadata, 0);
     AssertPrimitiveHandlerDelegate(typeof (OpenTypeHandler2), primitiveMetadata, 1);
     AssertPrimitiveHandlerDelegate(typeof (OpenTypeHandler2), primitiveMetadata, 2);
     AssertPrimitiveHandlerDelegate(typeof (OpenTypeHandler), primitiveMetadata, HandlerRegistry
         .HandlerVersion);
     var arrayHandler = new ArrayHandler(openTypeHandler, false);
     AssertCorrectedHandlerVersion(typeof (ArrayHandler0), arrayHandler, 0);
     AssertCorrectedHandlerVersion(typeof (ArrayHandler1), arrayHandler, 1);
     AssertCorrectedHandlerVersion(typeof (ArrayHandler3), arrayHandler, 2);
     AssertCorrectedHandlerVersion(typeof (ArrayHandler3), arrayHandler, 3);
     AssertCorrectedHandlerVersion(typeof (ArrayHandler), arrayHandler, HandlerRegistry
         .HandlerVersion);
     ArrayHandler multidimensionalArrayHandler = new MultidimensionalArrayHandler(openTypeHandler
         , false);
     AssertCorrectedHandlerVersion(typeof (MultidimensionalArrayHandler0), multidimensionalArrayHandler
         , 0);
     AssertCorrectedHandlerVersion(typeof (MultidimensionalArrayHandler3), multidimensionalArrayHandler
         , 1);
     AssertCorrectedHandlerVersion(typeof (MultidimensionalArrayHandler3), multidimensionalArrayHandler
         , 2);
     AssertCorrectedHandlerVersion(typeof (MultidimensionalArrayHandler3), multidimensionalArrayHandler
         , 3);
     AssertCorrectedHandlerVersion(typeof (MultidimensionalArrayHandler), multidimensionalArrayHandler
         , HandlerRegistry.HandlerVersion);
 }
Exemple #8
0
 internal virtual IPreparedComparison PrepareComparison(ObjectContainerBase container
     , object constraint)
 {
     var context = container.Transaction.Context();
     if (_fieldMetadata != null)
     {
         return _fieldMetadata.PrepareComparison(context, constraint);
     }
     if (_classMetadata != null)
     {
         return _classMetadata.PrepareComparison(context, constraint);
     }
     IReflector reflector = container.Reflector();
     ClassMetadata classMetadata = null;
     if (_bytes != null)
     {
         classMetadata = container.ProduceClassMetadata(reflector.ForObject(constraint));
     }
     else
     {
         if (_member != null)
         {
             classMetadata = container.ClassMetadataForReflectClass(reflector.ForObject(_member
                 ));
         }
     }
     if (classMetadata != null)
     {
         if (_member != null && _member.GetType().IsArray)
         {
             var arrayElementTypehandler = classMetadata.TypeHandler();
             if (reflector.Array().IsNDimensional(MemberClass()))
             {
                 var mah = new MultidimensionalArrayHandler(arrayElementTypehandler
                     , false);
                 return mah.PrepareComparison(context, _member);
             }
             var ya = new ArrayHandler(arrayElementTypehandler, false);
             return ya.PrepareComparison(context, _member);
         }
         return classMetadata.PrepareComparison(context, constraint);
     }
     return null;
 }
			public _IRunnable_127(ArrayHandler _enclosing, IDeleteContext context)
			{
				this._enclosing = _enclosing;
				this.context = context;
			}
			public _IRunnable_80(ArrayHandler _enclosing, AbstractBufferContext context, ArrayInfo
				 info, IRunnable elementRunnable)
			{
				this._enclosing = _enclosing;
				this.context = context;
				this.info = info;
				this.elementRunnable = elementRunnable;
			}
Exemple #11
0
		private void RegisterCompositeHandlerVersions()
		{
			RegisterHandlerVersion(new StandardReferenceTypeHandler(), 0, new StandardReferenceTypeHandler0
				());
			ArrayHandler arrayHandler = new ArrayHandler();
			RegisterHandlerVersion(arrayHandler, 0, new ArrayHandler0());
			RegisterHandlerVersion(arrayHandler, 1, new ArrayHandler1());
			RegisterHandlerVersion(arrayHandler, 3, new ArrayHandler3());
			RegisterHandlerVersion(arrayHandler, 5, new ArrayHandler5());
			MultidimensionalArrayHandler multidimensionalArrayHandler = new MultidimensionalArrayHandler
				();
			RegisterHandlerVersion(multidimensionalArrayHandler, 0, new MultidimensionalArrayHandler0
				());
			RegisterHandlerVersion(multidimensionalArrayHandler, 3, new MultidimensionalArrayHandler3
				());
		}
 public _IRunnable_127(ArrayHandler _enclosing, IDeleteContext context)
 {
     this._enclosing = _enclosing;
     this.context    = context;
 }