public void BasicTest()
        {
            DualKeyDictionary<int, string, string> dictionary = new DualKeyDictionary<int, string, string>();

            // Adding "Zero" to dictionary with primary int key of 0
            dictionary.Add(0, "Zero");
            Assert.AreEqual(1, dictionary.Count);

            // Associating binary sub-key of "0000" with primary int key of 0
            dictionary.Associate("0000", 0);

            // Adding "Three" to dictionary with primary int key of 3 and a binary sub-key of "0011"
            dictionary.Add(3, "0011", "Three");
            Assert.AreEqual(2, dictionary.Count);

            // Getting value for binary sub-key "0000"
            string value = dictionary["0000"]; // value will be "Zero"
            Assert.AreEqual("Zero", value);

            // Getting value for binary sub-key "0011"
            value = dictionary["0011"]; // value will be "Three"
            Assert.AreEqual("Three", value);

            // Getting value for int primary key 3
            value = dictionary[3]; // value will be "Three"
            Assert.AreEqual("Three", value);
        }
        public void BasicTest()
        {
            DualKeyDictionary <int, string, string> dictionary = new DualKeyDictionary <int, string, string>();

            // Adding "Zero" to dictionary with primary int key of 0
            dictionary.Add(0, "Zero");
            Assert.AreEqual(1, dictionary.Count);

            // Associating binary sub-key of "0000" with primary int key of 0
            dictionary.Associate("0000", 0);

            // Adding "Three" to dictionary with primary int key of 3 and a binary sub-key of "0011"
            dictionary.Add(3, "0011", "Three");
            Assert.AreEqual(2, dictionary.Count);

            // Getting value for binary sub-key "0000"
            string value = dictionary["0000"]; // value will be "Zero"

            Assert.AreEqual("Zero", value);

            // Getting value for binary sub-key "0011"
            value = dictionary["0011"]; // value will be "Three"
            Assert.AreEqual("Three", value);

            // Getting value for int primary key 3
            value = dictionary[3]; // value will be "Three"
            Assert.AreEqual("Three", value);
        }
Exemplo n.º 3
0
        public static void TestAdd()
        {
            DualKeyDictionary <int, int, string> dict = new DualKeyDictionary <int, int, string>();

            dict.Add(0, 0, "0,0");
            dict.Add(0, 1, "0,1");
            dict.Add(1, 0, "1,0");
            dict.Add(1, 1, "1,1");

            Assert.AreEqual(dict.Count, 4);
            Assert.IsTrue(dict.ContainsKey(1, 1));
            Assert.AreEqual(dict[1, 1], "1,1");
        }
    private static void Main()
    {
        DualKeyDictionary<int, string, string> dictionary = new DualKeyDictionary<int, string, string>();

        // Adding "Zero" to dictionary with primary int key of 0
        dictionary.Add(0, "Zero");
        // Associating binary sub-key of "0000" with primary int key of 0
        dictionary.Associate("0000", 0);

        // Adding "Three" to dictionary with primary int key of 3 and a binary sub-key of "0011"
        dictionary.Add(3, "0011", "Three");

        // Getting value for binary sub-key "0000"
        string value = dictionary["0000"]; // value will be "Zero"
        Console.WriteLine(value);
        // Getting value for int primary key 0
        value = dictionary[0]; // val will be "Zero"
        Console.WriteLine(value);
    }
Exemplo n.º 5
0
    private static void Main()
    {
        DualKeyDictionary <int, string, string> dictionary = new DualKeyDictionary <int, string, string>();

        // Adding "Zero" to dictionary with primary int key of 0
        dictionary.Add(0, "Zero");
        // Associating binary sub-key of "0000" with primary int key of 0
        dictionary.Associate("0000", 0);

        // Adding "Three" to dictionary with primary int key of 3 and a binary sub-key of "0011"
        dictionary.Add(3, "0011", "Three");

        // Getting value for binary sub-key "0000"
        string value = dictionary["0000"]; // value will be "Zero"

        Console.WriteLine(value);
        // Getting value for int primary key 0
        value = dictionary[0]; // val will be "Zero"
        Console.WriteLine(value);
    }
Exemplo n.º 6
0
        public void Register(IDataModelDescriptor entitySchemaModel)
        {
            bool exists = false;

            if (!(exists = entities.ContainsKey2(entitySchemaModel.EntityType)))
            {
                lock (dlock)
                {
                    if (!(exists = entities.ContainsKey2(entitySchemaModel.EntityType)))
                    {
                        entities.Add(entitySchemaModel.EntityType.Name, entitySchemaModel.EntityType, entitySchemaModel);
                    }
                }
            }

            if (exists)
            {
                throw new Exception("Type " + entitySchemaModel.EntityType.Name + " has already been registerd");
            }
        }