예제 #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);
        }
예제 #3
0
 public void ToAml(XmlWriter writer, AmlWriterSettings settings)
 {
     if (Settings?.ModifyQuery == null)
     {
         QueryItem.ToAml(writer, settings);
     }
     else
     {
         var item = AmlContext.FromXml(QueryItem).AssertItem();
         Settings.ModifyQuery.Invoke(item);
         item.ToAml(writer, settings);
     }
 }