Пример #1
0
		private static TransportObjectContainer NewTransportObjectContainer(ObjectContainerBase
			 serviceProvider, MemoryBin memoryBin)
		{
			TransportObjectContainer container = new TransportObjectContainer(serviceProvider
				, memoryBin);
			container.DeferredOpen();
			return container;
		}
Пример #2
0
 public TransportObjectContainer(ObjectContainerBase parent, MemoryBin memoryFile)
     : base(parent.Config())
 {
     _memoryBin = memoryFile;
     _parent = parent;
     _lock = parent.Lock();
     _showInternalClasses = parent._showInternalClasses;
     Open();
 }
Пример #3
0
        /// <exception cref="System.IO.IOException"></exception>
        public virtual void Rename(string oldUri, string newUri)
        {
            MemoryBin bin = ((MemoryBin)Sharpen.Collections.Remove(_bins, oldUri));

            if (bin == null)
            {
                throw new IOException("Bin not found: " + oldUri);
            }
            _bins[newUri] = bin;
        }
Пример #4
0
		public static SerializedGraph Marshall(ObjectContainerBase serviceProvider, object
			 obj)
		{
			MemoryBin memoryBin = new MemoryBin(223, GrowthStrategy());
			TransportObjectContainer carrier = NewTransportObjectContainer(serviceProvider, memoryBin
				);
			carrier.ProduceClassMetadata(carrier.Reflector().ForObject(obj));
			carrier.Store(obj);
			int id = (int)carrier.GetID(obj);
			carrier.Close();
			return new SerializedGraph(id, memoryBin.Data());
		}
Пример #5
0
		private IBin ProduceStorage(BinConfiguration config)
		{
			IBin storage = Bin(config.Uri());
			if (null != storage)
			{
				return storage;
			}
			MemoryBin newStorage = new MemoryBin(new byte[(int)config.InitialLength()], _growthStrategy
				);
			_bins[config.Uri()] = newStorage;
			return newStorage;
		}
Пример #6
0
        private IBin ProduceStorage(BinConfiguration config)
        {
            IBin storage = Bin(config.Uri());

            if (null != storage)
            {
                return(storage);
            }
            MemoryBin newStorage = new MemoryBin(new byte[(int)config.InitialLength()], _growthStrategy
                                                 );

            _bins[config.Uri()] = newStorage;
            return(newStorage);
        }
Пример #7
0
		public static object Unmarshall(ObjectContainerBase serviceProvider, byte[] bytes
			, int id)
		{
			if (id <= 0)
			{
				return null;
			}
			MemoryBin memoryBin = new MemoryBin(bytes, GrowthStrategy());
			TransportObjectContainer carrier = NewTransportObjectContainer(serviceProvider, memoryBin
				);
			object obj = carrier.GetByID(id);
			carrier.Activate(carrier.Transaction, obj, new FullActivationDepth());
			carrier.Close();
			return obj;
		}
Пример #8
0
 public virtual void Test()
 {
     var origStorage = new MemoryStorage();
     var origConfig = Config(origStorage);
     IObjectContainer origDb = Db4oEmbedded.OpenFile(origConfig, BinUri);
     origDb.Store(new Item(ItemName));
     origDb.Close();
     var origBin = origStorage.Bin(BinUri);
     var data = origBin.Data();
     Assert.AreEqual(data.Length, origBin.Length());
     var newBin = new MemoryBin(data, new DoublingGrowthStrategy());
     var newStorage = new MemoryStorage();
     newStorage.Bin(BinUri, newBin);
     IObjectContainer newDb = Db4oEmbedded.OpenFile(Config(newStorage), BinUri);
     var result = newDb.Query(typeof (Item));
     Assert.AreEqual(1, result.Count);
     Assert.AreEqual(ItemName, ((Item) result.Next())._name
         );
     newDb.Close();
 }
		public virtual void Test()
		{
			MemoryStorage origStorage = new MemoryStorage();
			IEmbeddedConfiguration origConfig = Config(origStorage);
			IObjectContainer origDb = Db4oEmbedded.OpenFile(origConfig, BinUri);
			origDb.Store(new MemoryBinIsReusableTestCase.Item(ItemName));
			origDb.Close();
			MemoryBin origBin = origStorage.Bin(BinUri);
			byte[] data = origBin.Data();
			Assert.AreEqual(data.Length, origBin.Length());
			MemoryBin newBin = new MemoryBin(data, new DoublingGrowthStrategy());
			MemoryStorage newStorage = new MemoryStorage();
			newStorage.Bin(BinUri, newBin);
			IObjectContainer newDb = Db4oEmbedded.OpenFile(Config(newStorage), BinUri);
			IObjectSet result = newDb.Query(typeof(MemoryBinIsReusableTestCase.Item));
			Assert.AreEqual(1, result.Count);
			Assert.AreEqual(ItemName, ((MemoryBinIsReusableTestCase.Item)result.Next())._name
				);
			newDb.Close();
		}
Пример #10
0
		private void Write(MemoryBin bin, int pos, int count, int expectedSize)
		{
			bin.Write(pos, new byte[count], count);
			Assert.AreEqual(expectedSize, bin.BufferSize());
		}
Пример #11
0
		/// <summary>Registers the given bin for this storage with the given URI.</summary>
		/// <remarks>Registers the given bin for this storage with the given URI.</remarks>
		public virtual void Bin(string uri, MemoryBin bin)
		{
			_bins[uri] = bin;
		}
Пример #12
0
 /// <summary>Registers the given bin for this storage with the given URI.</summary>
 /// <remarks>Registers the given bin for this storage with the given URI.</remarks>
 public virtual void Bin(string uri, MemoryBin bin)
 {
     _bins[uri] = bin;
 }