コード例 #1
0
        public void SupportedClasses()
        {
            KeyCollection keys = new KeyCollection(null, new Type[] { typeof(Int32Key), typeof(GuidKey) });

            keys.Add(Int32Key.Create(1, "Product"));
            keys.Add(GuidKey.Create(Guid.NewGuid(), "Category"));
        }
コード例 #2
0
        public void SupportedTypes()
        {
            KeyCollection keys = new KeyCollection(new string[] { "Product", "Category" });

            keys.Add(Int32Key.Create(1, "Product"));
            keys.Add(GuidKey.Create(Guid.NewGuid(), "Category"));
        }
コード例 #3
0
        public void AllSupportedKeyTypesAndClasses()
        {
            KeyCollection keys = new KeyCollection();

            keys.Add(Int32Key.Create(1, "Product"));
            keys.Add(GuidKey.Create(Guid.NewGuid(), "Category"));
        }
コード例 #4
0
        public void EmptyKeyIsIgnored()
        {
            KeyCollection keys = new KeyCollection();

            keys.Add(Int32Key.Empty("Product"));
            Assert.AreEqual(0, keys.Count);
        }
        private static bool TryGetInt32Key(IReadOnlyKeyValueCollection parameters, out Int32Key key)
        {
            if (parameters.TryGet("Type", out string type) && parameters.TryGet("ID", out int id))
            {
                key = Int32Key.Create(id, type);
                return(true);
            }

            key = null;
            return(false);
        }
コード例 #6
0
        public static Int32Key FindInt32KeyWithoutType(this KeyToParametersConverter converter, IReadOnlyKeyValueCollection parameters, string keyType)
        {
            Ensure.NotNull(converter, "converter");
            Int32Key key;

            if (converter.TryGetWithoutType(parameters, keyType, out key))
            {
                return(key);
            }

            return(Int32Key.Empty(keyType));
        }
コード例 #7
0
        public void NotSupportedTypes()
        {
            KeyCollection keys = new KeyCollection(new string[] { "Product", "Category" });

            keys.Add(Int32Key.Create(1, "PriceList"));
        }