Exemplo n.º 1
0
		/// <exception cref="System.Exception"></exception>
		public virtual void TestRetrieve()
		{
			Hashtable4 uuidCache = new Hashtable4();
			AssertItemsCanBeRetrievedByUUID(uuidCache);
			Reopen();
			AssertItemsCanBeRetrievedByUUID(uuidCache);
		}
Exemplo n.º 2
0
 public virtual void TestByteArrayKeys()
 {
     byte[] key1 = {1, 2, 3};
     byte[] key2 = {3, 2, 1};
     byte[] key3 = {3, 2, 1};
     // same values as key2
     var table = new Hashtable4(2);
     table.Put(key1, "foo");
     table.Put(key2, "bar");
     Assert.AreEqual("foo", table.Get(key1));
     Assert.AreEqual("bar", table.Get(key2));
     Assert.AreEqual(2, CountKeys(table));
     Assert.AreEqual(2, table.Size());
     table.Put(key3, "baz");
     Assert.AreEqual("foo", table.Get(key1));
     Assert.AreEqual("baz", table.Get(key2));
     Assert.AreEqual(2, CountKeys(table));
     Assert.AreEqual(2, table.Size());
     Assert.AreEqual("baz", table.Remove(key2));
     Assert.AreEqual(1, CountKeys(table));
     Assert.AreEqual(1, table.Size());
     Assert.AreEqual("foo", table.Remove(key1));
     Assert.AreEqual(0, CountKeys(table));
     Assert.AreEqual(0, table.Size());
 }
Exemplo n.º 3
0
 public virtual void TestToString()
 {
     var table = new Hashtable4();
     table.Put("foo", "bar");
     table.Put("bar", "baz");
     Assert.AreEqual(Iterators.Join(table.Iterator(), "{", "}", ", "), table.ToString(
         ));
 }
Exemplo n.º 4
0
		static KnownClassesRepository()
		{
			Primitives = new Hashtable4();
			Type[] primitiveArray = Platform4.PrimitiveTypes();
			for (int primitiveIndex = 0; primitiveIndex < primitiveArray.Length; ++primitiveIndex)
			{
				Type primitive = primitiveArray[primitiveIndex];
				RegisterPrimitive(primitive);
			}
		}
		public ClientTransactionPool(LocalObjectContainer mainContainer)
		{
			// Transaction -> ContainerCount
			// String -> ContainerCount
			ClientTransactionPool.ContainerCount mainEntry = new ClientTransactionPool.ContainerCount
				(mainContainer, 1);
			_transaction2Container = new Hashtable4();
			_fileName2Container = new Hashtable4();
			_fileName2Container.Put(mainContainer.FileName(), mainEntry);
			_mainContainer = mainContainer;
		}
Exemplo n.º 6
0
 public virtual void TestClear()
 {
     var table = new Hashtable4();
     for (var i = 0; i < 2; ++i)
     {
         table.Clear();
         Assert.AreEqual(0, table.Size());
         table.Put("foo", "bar");
         Assert.AreEqual(1, table.Size());
         AssertIterator(table, new object[] {"foo"});
     }
 }
Exemplo n.º 7
0
 public virtual void TestContainsKey()
 {
     var table = new Hashtable4();
     Assert.IsFalse(table.ContainsKey(null));
     Assert.IsFalse(table.ContainsKey("foo"));
     table.Put("foo", null);
     Assert.IsTrue(table.ContainsKey("foo"));
     table.Put("bar", "baz");
     Assert.IsTrue(table.ContainsKey("bar"));
     Assert.IsFalse(table.ContainsKey("baz"));
     Assert.IsTrue(table.ContainsKey("foo"));
     table.Remove("foo");
     Assert.IsTrue(table.ContainsKey("bar"));
     Assert.IsFalse(table.ContainsKey("foo"));
 }
Exemplo n.º 8
0
		public virtual void Test()
		{
			Hashtable4 ht = new Hashtable4();
			ObjectContainerBase container = Container();
			container.ShowInternalClasses(true);
			IQuery q = Db().Query();
			q.Constrain(typeof(Db4oDatabase));
			IObjectSet objectSet = q.Execute();
			while (objectSet.HasNext())
			{
				Db4oDatabase identity = (Db4oDatabase)objectSet.Next();
				Assert.IsFalse(ht.ContainsKey(identity.i_signature));
				ht.Put(identity.i_signature, string.Empty);
			}
			container.ShowInternalClasses(false);
		}
Exemplo n.º 9
0
 protected virtual Db4objects.Db4o.Foundation.Hashtable4 DeepCloneInternal(Db4objects.Db4o.Foundation.Hashtable4
                                                                           ret, object obj)
 {
     ret._mask        = _mask;
     ret._maximumSize = _maximumSize;
     ret._size        = _size;
     ret._tableSize   = _tableSize;
     ret._table       = new HashtableIntEntry[_tableSize];
     for (int i = 0; i < _tableSize; i++)
     {
         if (_table[i] != null)
         {
             ret._table[i] = (HashtableIntEntry)_table[i].DeepClone(obj);
         }
     }
     return(ret);
 }
Exemplo n.º 10
0
		protected virtual void AssertItemsCanBeRetrievedByUUID(Hashtable4 uuidCache)
		{
			IQuery q = NewItemQuery();
			IObjectSet objectSet = q.Execute();
			while (objectSet.HasNext())
			{
				UUIDTestCase.Item item = (UUIDTestCase.Item)objectSet.Next();
				Db4oUUID uuid = Uuid(item);
				Assert.IsNotNull(uuid);
				Assert.AreSame(item, Db().GetByUUID(uuid));
				Db4oUUID cached = (Db4oUUID)uuidCache.Get(item.name);
				if (cached != null)
				{
					Assert.AreEqual(cached, uuid);
				}
				else
				{
					uuidCache.Put(item.name, uuid);
				}
			}
		}
Exemplo n.º 11
0
 protected virtual Hashtable4 DeepCloneInternal(Hashtable4
     ret, object obj)
 {
     ret._mask = _mask;
     ret._maximumSize = _maximumSize;
     ret._size = _size;
     ret._tableSize = _tableSize;
     ret._table = new HashtableIntEntry[_tableSize];
     for (var i = 0; i < _tableSize; i++)
     {
         if (_table[i] != null)
         {
             ret._table[i] = (HashtableIntEntry) _table[i].DeepClone(obj);
         }
     }
     return ret;
 }
Exemplo n.º 12
0
		public MemoryIoAdapter()
		{
			_memoryFiles = new Hashtable4();
			_growBy = 10000;
		}
Exemplo n.º 13
0
		private Hashtable4 ExceptionalFields()
		{
			Hashtable4 exceptionalFieldsCollection = ExceptionalFieldsOrNull();
			if (exceptionalFieldsCollection == null)
			{
				exceptionalFieldsCollection = new Hashtable4(16);
				_config.Put(ExceptionalFieldsKey, exceptionalFieldsCollection);
			}
			return exceptionalFieldsCollection;
		}
Exemplo n.º 14
0
		public HashSet4(int count)
		{
			_map = new Hashtable4(count);
		}
Exemplo n.º 15
0
     private static void InitNullValues()
     {
 	    _nullValues = new Hashtable4();
         _nullValues.Put(typeof(int), 0);
         _nullValues.Put(typeof(uint), (uint)0);
         _nullValues.Put(typeof(byte), (byte)0);
 	    _nullValues.Put(typeof(short), (short)0);
 	    _nullValues.Put(typeof(float), (float)0);
 	    _nullValues.Put(typeof(double), (double)0);
         _nullValues.Put(typeof(ulong), (ulong)0);
         _nullValues.Put(typeof(long), (long)0);
 	    _nullValues.Put(typeof(bool), false);
         _nullValues.Put(typeof(char), (char)0);
         _nullValues.Put(typeof(sbyte), (sbyte)0);
         _nullValues.Put(typeof(decimal), (decimal)0);
         _nullValues.Put(typeof(ushort), (ushort)0);
         _nullValues.Put(typeof(DateTime), DateTime.MinValue);
     	
     }
Exemplo n.º 16
0
		public NoDuplicatesQueue(IQueue4 queue)
		{
			_queue = queue;
			_seen = new Hashtable4();
		}
Exemplo n.º 17
0
		private Hashtable4 SafeConfigurationItems()
		{
			Hashtable4 items = ConfigurationItems();
			if (items == null)
			{
				items = new Hashtable4(16);
				_config.Put(ConfigurationItemsKey, items);
			}
			return items;
		}
Exemplo n.º 18
0
		public IndexedNodeCollector(QCandidates candidates)
		{
			_nodes = new Collection4();
			_nodeCache = new Hashtable4();
			CollectIndexedNodes(candidates);
		}
Exemplo n.º 19
0
		private static Prototypes.IntegerConverter IntegerConverterforClassName(IReflector
			 reflector, string className)
		{
			if (_integerConverters == null)
			{
				_integerConverters = new Hashtable4();
				Prototypes.IntegerConverter[] converters = new Prototypes.IntegerConverter[] { new 
					_IntegerConverter_211(), new _IntegerConverter_215(), new _IntegerConverter_219(
					), new _IntegerConverter_223(), new _IntegerConverter_227(), new _IntegerConverter_231
					(), new _IntegerConverter_235(), new _IntegerConverter_239() };
				for (int converterIndex = 0; converterIndex < converters.Length; ++converterIndex)
				{
					Prototypes.IntegerConverter converter = converters[converterIndex];
					_integerConverters.Put(converter.PrimitiveName(), converter);
					if (!converter.PrimitiveName().Equals(converter.WrapperName(reflector)))
					{
						_integerConverters.Put(converter.WrapperName(reflector), converter);
					}
				}
			}
			return (Prototypes.IntegerConverter)_integerConverters.Get(className);
		}
Exemplo n.º 20
0
		internal void CreateConfigAndConstructor(Hashtable4 a_byteHashTable, IReflectClass
			 claxx)
		{
			SetName(ResolveName(claxx));
			SetConfig(ConfigImpl().ConfigClass(GetName()));
			if (claxx == null)
			{
				ResolveClassReflector(GetName());
			}
			else
			{
				ClassReflector(claxx);
			}
			//            createConstructor(true);
			if (i_nameBytes != null)
			{
				a_byteHashTable.Remove(i_nameBytes);
				i_nameBytes = null;
			}
		}
Exemplo n.º 21
0
 public CustomClassRepository()
 {
     // fields must be public so test works on less capable runtimes
     _classes = new Hashtable4();
 }
 private SynchronizedHashtable4(Hashtable4 delegate_)
 {
     _delegate = delegate_;
 }
Exemplo n.º 23
0
		internal Db4oSignatureMap(IInternalObjectContainer stream)
		{
			_stream = stream;
			_identities = new Hashtable4();
		}
Exemplo n.º 24
0
 private Hashtable4 TableFromKeys(object[] keys)
 {
     var ht = new Hashtable4();
     for (var i = 0; i < keys.Length; i++)
     {
         ht.Put(keys[i], keys[i]);
     }
     return ht;
 }
Exemplo n.º 25
0
		public Hashtable4 ExceptionalClasses()
		{
			Hashtable4 exceptionalClasses = (Hashtable4)_config.Get(ExceptionalClassesKey);
			if (exceptionalClasses == null)
			{
				exceptionalClasses = new Hashtable4(16);
				_config.Put(ExceptionalClassesKey, exceptionalClasses);
			}
			return exceptionalClasses;
		}
		internal void InitTables(int size)
		{
			_classes = new Collection4();
			_classMetadataByBytes = new Hashtable4(size);
			if (size < 16)
			{
				size = 16;
			}
			_classMetadataByClass = new Hashtable4(size);
			_classMetadataByName = new Hashtable4(size);
			_classMetadataByID = new Hashtable4(size);
			_creating = new Hashtable4(1);
		}
Exemplo n.º 27
0
 public HashSet4(int count)
 {
     _map = new Hashtable4(count);
 }
Exemplo n.º 28
0
		public Set4()
		{
			_table = new Hashtable4();
		}
Exemplo n.º 29
0
		internal LRULongCache(int size)
		{
			_maxSize = size;
			_slots = new Hashtable4(size);
		}
Exemplo n.º 30
0
		public Set4(int size)
		{
			_table = new Hashtable4(size);
		}
Exemplo n.º 31
0
        private static void InitPrimitive2Wrapper()
        {
    	    _primitive2Wrapper = new Hashtable4();

        	foreach (Type type in PRIMITIVE_TYPES)
        	{
				_primitive2Wrapper.Put(type, ConcreteNullableTypeFor(type));
        	}
        }
Exemplo n.º 32
0
		private SynchronizedHashtable4(Hashtable4 delegate_)
		{
			_delegate = delegate_;
		}
Exemplo n.º 33
0
 public NoDuplicatesQueue(IQueue4 queue)
 {
     _queue = queue;
     _seen  = new Hashtable4();
 }
		public void MapQueryResultToID(LazyClientObjectSetStub stub, int queryResultID)
		{
			if (_queryResults == null)
			{
				_queryResults = new Hashtable4();
			}
			_queryResults.Put(queryResultID, stub);
		}