Beispiel #1
0
        // ------------------------------------------------------------------------------------
        // Name:   DoLike
        // Goal:   Perform the "Like" function using the pattern (or patterns) stored in [strPattern]
        //         There can be more than 1 pattern in [strPattern], which must be separated
        //         by a vertical bar: |
        // History:
        // 17-06-2010  ERK Created
        // ------------------------------------------------------------------------------------
        private bool DoLike(string strText, string strPattern)
        {
            string[] arPattern = null;
            // Array of patterns
            int intI = 0;

            // Counter

            try {
                // Reduce the [strPattern]
                strPattern = strPattern.Trim();
                // ============== DEBUG ==============
                // If (strPattern = "a") Then Stop
                // ===================================
                // SPlit the [strPattern] into different ones
                arPattern = strPattern.Split(new string[] { "|" }, StringSplitOptions.None);
                // Perform the "Like" operation for all needed patterns
                for (intI = 0; intI < arPattern.Length; intI++)
                {
                    // See if something positive comes out of this comparison
                    if (strText.IsLike(strPattern))
                    {
                        return(true);
                    }
                }
                // No match has happened, so return false
                return(false);
            } catch (Exception ex) {
                // Show error
                errHandle.DoError("XpathExt/DoLike", ex);
                // Return failure
                return(false);
            }
        }
Beispiel #2
0
 // ----------------------------------------------------------------------------------------------------------
 // Name :  AddEtreeChild
 // Goal :  Add an <eTree> child under [ndxParent]
 // History:
 // 26-04-2011  ERK Created
 // ----------------------------------------------------------------------------------------------------------
 public XmlNode AddEtreeChild(ref XmlNode ndxParent, int intId, string strLabel, int intSt, int intEn)
 {
     try {
         // Add the child
         return(oXmlTools.AddXmlChild(ndxParent, "eTree",
                                      "Id", intId.ToString(), "attribute",
                                      "Label", strLabel, "attribute",
                                      "from", intSt.ToString(), "attribute",
                                      "to", intEn.ToString(), "attribute"));
     } catch (Exception ex) {
         // Warn the user
         errHandle.DoError("modXmlNode/AddEtreeChild", ex);
         // Return failure
         return(null);
     }
 }
Beispiel #3
0
        // ------------------------------------------------------------------------------------
        // Name:   AddXmlChild
        // Goal:   Make a new XmlNode element of type [strTag] using the [arValue] values
        //         These values consist of:
        //         (a) itemname
        //         (b) itemvalue
        //         (c) itemtype: "attribute" or "child"
        //         Append this node as child under [ndxParent]
        // Return: The XmlNode element that has been made is returned
        // History:
        // 22-09-2010  ERK Created
        // ------------------------------------------------------------------------------------
        public XmlNode AddXmlChild(XmlNode ndxParent, string strTag, params string[] arValue)
        {
            XmlNode      ndxThis  = null; // Working node
            XmlNode      ndxChild = null; // Child node
            XmlAttribute atxChild = null; // The attribute we are looking for
            int          intI     = 0;    // Counter

            try
            {
                // Validate (NB: we DO allow empty parents)
                if ((string.IsNullOrEmpty(strTag)) || (pdxDoc == null))
                {
                    return(null);
                }
                // Make a new XmlNode in the local XML document
                if (string.IsNullOrEmpty(strNs))
                {
                    ndxThis = pdxDoc.CreateNode(XmlNodeType.Element, strTag, null);
                }
                else
                {
                    ndxThis = pdxDoc.CreateNode(XmlNodeType.Element, strTag, strNs);
                }
                // Validate
                if (ndxThis == null)
                {
                    return(null);
                }
                // Do we have a parent?
                if (ndxParent == null)
                {
                    // Take the document as starting point
                    pdxDoc.AppendChild(ndxThis);
                }
                else
                {
                    // Just append it
                    ndxParent.AppendChild(ndxThis);
                }
                // Walk through the values
                for (intI = 0; intI <= arValue.GetUpperBound(0); intI += 3)
                {
                    // Action depends on the type of value
                    switch (arValue[intI + 2])
                    {
                    case "attribute":
                        // Create attribute
                        atxChild = pdxDoc.CreateAttribute(arValue[intI]);
                        // Fillin value of this attribute
                        atxChild.Value = arValue[intI + 1];
                        // Append attribute to this node
                        ndxThis.Attributes.Append(atxChild);
                        break;

                    case "child":
                        // Create this node
                        if (string.IsNullOrEmpty(strNs))
                        {
                            ndxChild = pdxDoc.CreateNode(XmlNodeType.Element, arValue[intI], null);
                        }
                        else
                        {
                            ndxChild = pdxDoc.CreateNode(XmlNodeType.Element, arValue[intI], strNs);
                        }
                        // Fill in the value of this node
                        ndxChild.InnerText = arValue[intI + 1];
                        // Append this node as child
                        ndxThis.AppendChild(ndxChild);
                        break;

                    default:
                        // There is no other option yet, so return failure
                        return(null);
                    }
                }
                // Return the new node
                return(ndxThis);
            } catch (Exception ex) {
                // Warn user
                errHandle.DoError("modXmlNode/AddXmlChild", ex);
                // Return failure
                return(null);
            }
        }