Exemplo n.º 1
0
        /// <summary>
        /// Loads the lookup list data from the reader
        /// </summary>
        protected override void LoadLookupListFromReader()
        {
            string options = _reader.GetAttribute("options");

            if (!string.IsNullOrEmpty(options))
            {
                string[] optionsArr = options.Split(new[] { '|' });
                foreach (string s in optionsArr)
                {
                    _displayValueDictionary.Add(s, s);
                }
            }
            _reader.Read();
            while (_reader.Name == "item")
            {
                string stringPart = _reader.GetAttribute("display");
                string valuePart  = _reader.GetAttribute("value");
                if (string.IsNullOrEmpty(stringPart))
                {
                    throw new InvalidXmlDefinitionException("An 'item' " +
                                                            "is missing a 'display' attribute that specifies the " +
                                                            "string to show to the user in a display.");
                }
                if (string.IsNullOrEmpty(valuePart))
                {
                    throw new InvalidXmlDefinitionException("An 'item' " +

                                                            "is missing a 'value' attribute that specifies the " +
                                                            "value to store for the given property.");
                }
                var  guidDataMapper = new GuidDataMapper();
                Guid newGuid;
                if (StringUtilities.GuidTryParse(valuePart, out newGuid))
                {
                    _displayValueDictionary.Add(stringPart, guidDataMapper.ConvertValueToString(newGuid));
                }
                else
                {
                    _displayValueDictionary.Add(stringPart, valuePart);
                }

                ReadAndIgnoreEndTag();
            }

            if (_displayValueDictionary.Count == 0)
            {
                throw new InvalidXmlDefinitionException("A 'simpleLookupList' " +
                                                        "element does not contain any 'item' elements or any items in the 'options' attribute.  It " +
                                                        "should contain one or more 'item' elements or one or more | separated options in the 'options' attribute that " +
                                                        "specify each of the available options in the lookup list.");
            }
        }
Exemplo n.º 2
0
        public void Test_DataMapper_ConvertValueToString_Null()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            string parsedValue = _dataMapper.ConvertValueToString(null);

            //---------------Test Result -----------------------
            Assert.AreEqual("", parsedValue);
        }