/// <summary>
 /// Make the Consignments enumerable according to the CREATE section of the doc.
 /// Then index the Consignments for each of the relevant sections.
 /// Assumption: The CREATE section exists, or we have no Consignments.
 /// </summary>
 private bool Initialize(IndexBy indexBy)
 {
     IdPropertyXPath = XPathExpression.Compile("./" + indexBy.ToString() + "/text()");
     //determine available sections
     hasCreate       = doc.NodeExists("/document/CREATE");
     hasBook         = doc.NodeExists("/document/BOOK");
     hasShip         = doc.NodeExists("/document/SHIP");
     hasPrint        = doc.NodeExists("/document/PRINT");
     hasError        = doc.NodeExists("//ERROR");
     hasRuntimeError = doc.NodeExists("/runtime_error");
     //prepare iterator and indexes
     if (doc.NodeExists("/document"))
     {
         if (hasCreate)
         {
             createEnum  = doc.GetChildEnumerable(XPathExpression.Compile("/document"), "CREATE");
             createIndex = doc.GetChildIndex(XPathExpression.Compile("/document"), "CREATE", IdPropertyXPath);
         }
         if (hasBook)
         {
             bookIndex = doc.GetChildIndex(XPathExpression.Compile("/document/BOOK"), "CONSIGNMENT", IdPropertyXPath);
         }
         if (hasShip)
         {
             shipIndex = doc.GetChildIndex(XPathExpression.Compile("/document/SHIP"), "CONSIGNMENT", IdPropertyXPath);
         }
         //...etc
         return(true);
     }
     else
     {
         return(false); //after all, not worthy of further investigation.
     }
 }
Esempio n. 2
0
        public int CompareTo(object obj)
        {
            IndexNode <TIndex, TRow> tmp = (IndexNode <TIndex, TRow>)obj;

            if (tmp == null)
            {
                throw new InvalidCastException(string.Format("Object is type: {0} , expected type: {1}", obj.GetType(),
                                                             this.GetType()));
            }

            Type inner = IndexBy.GetType();
            Type outer = tmp.IndexBy.GetType();

            //object value =  Convert.ChangeType(tmp.IndexBy, typeof (TIndex));

            return(IndexBy.CompareTo(tmp.IndexBy));
        }
        //...other activities...

        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="doc">MyXMLDocument that contains the TNT Result, XML already parsed</param>
        /// <param name="indexBy">Shall we index the document by ConRef or by ConNumber?</param>
        public TNTResult(MyXMLDocument doc, IndexBy indexBy)
        {
            this.doc = doc;
            this.OK  = Initialize(indexBy);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="reader">XmlReader that contains the TNT result</param>
 /// <param name="indexBy">Shall we index the document by ConRef or by ConNumber?</param>
 public TNTResult(XmlReader reader, IndexBy indexBy)
 {
     this.doc = new MyXMLDocument(reader, readOnly: true);
     this.OK  = Initialize(indexBy);
 }
Esempio n. 5
0
 public override string ToString()
 {
     return(IndexBy.ToString());
 }