public void AddOrReplaceAcceptsNullValue()
        {
            KeyValueList <string, string> list = new KeyValueList <string, string>();

            list.AddOrReplace("one", null);
            Assert.AreEqual(1, list.Count);
            Assert.IsNull(list[0].Value);

            list.AddOrReplace(null, "twice");
            Assert.IsNull(list[1].Key);
        }
        public void AddOrReplaceWorksReplacesEntry()
        {
            KeyValueList <string, string> list = new KeyValueList <string, string>();

            Assert.AreEqual(0, list.Count);

            list.AddOrReplace("one", "once");
            list.AddOrReplace("one", "twice");
            Assert.AreEqual("one", list[0].Key);
            Assert.AreEqual("twice", list[0].Value);
        }
        public void GetterAcceptsNull()
        {
            KeyValueList <string, string> list = new KeyValueList <string, string>();

            string result;

            result = list[null];
            Assert.IsNull(result);

            list.AddOrReplace(null, "none");
            result = list[null];
            Assert.AreEqual("none", result);
        }
示例#4
0
        private KeyValueList <object, string> ReadColumnDomainValues(IField field)
        {
            ICodedValueDomain codedValueDomain = field?.Domain as ICodedValueDomain;

            if (codedValueDomain == null)
            {
                return(null);
            }

            var result = new KeyValueList <object, string>();

            for (var index = 0; index < codedValueDomain.CodeCount; index++)
            {
                result.AddOrReplace(codedValueDomain.Value[index], codedValueDomain.Name[index]);
            }
            return(result);
        }
示例#5
0
        private static KeyValueList <int, string> ReadSubtypeDomainValues(IFeature feature)
        {
            ISubtypes    subtypes    = feature.Class as ISubtypes;
            IEnumSubtype enumSubtype = subtypes?.Subtypes;

            if (enumSubtype == null)
            {
                return(null);
            }

            var result = new KeyValueList <int, string>();

            enumSubtype.Reset();
            int subtypeCode;

            string description = enumSubtype.Next(out subtypeCode);

            while (description != null)
            {
                result.AddOrReplace(subtypeCode, description);
                description = enumSubtype.Next(out subtypeCode);
            }
            return(result);
        }