예제 #1
0
        protected override XmlElement AssertXml()
        {
            if (!Exists)
            {
                return(null);
            }

            if (Xml != null)
            {
                return(Xml);
            }

            if (nodeList != null)
            {
                throw new InvalidOperationException("Multiple items were found when only one was expected.");
            }

            var ex = Exception;

            if (ex != null)
            {
                throw ex;
            }

            throw AmlContext.NoItemsFoundException("?", default(Command));
        }
예제 #2
0
        /// <summary>
        /// Return an enumerable of items.  Throw an exception for any error including 'No items found'
        /// </summary>
        /// <returns></returns>
        public IEnumerable <IReadOnlyItem> AssertItems()
        {
            var items = Items();

            if (!items.Any())
            {
                throw AmlContext.NoItemsFoundException("?", default(Command));
            }
            return(items);
        }