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())); }
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(); }