Пример #1
0
        /// <summary>
        /// Selects single node from passed XmlNode and returns corresponding DefaultOperator, if the node is not found the given defaultvalue is returned
        /// </summary>
        /// <param name="xpath">Expression to select node containing setting value</param>
        /// <param name="selectionNode">Node to apply xpath expression on</param>
        /// <param name="defaultValue">Value to return if node is not found or not possible to parse as a PCAxis.Search.DefaultOperator</param>
        /// <returns>Setting value as PCAxis.Search.DefaultOperator</returns>
        public static PCAxis.Search.DefaultOperator GetSettingValue(string xpath, XmlNode selectionNode, PCAxis.Search.DefaultOperator defaultValue)
        {
            PCAxis.Search.DefaultOperator returnValue = defaultValue;
            XmlNode node = null;

            if (selectionNode != null)
            {
                node = selectionNode.SelectSingleNode(xpath);
            }
            if (node != null)
            {
                switch (node.InnerText)
                {
                case "AND":
                    returnValue = PCAxis.Search.DefaultOperator.AND;
                    break;

                case "OR":
                    returnValue = PCAxis.Search.DefaultOperator.OR;
                    break;

                default:
                    returnValue = PCAxis.Search.DefaultOperator.OR;
                    break;
                }
            }
            return(returnValue);
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="menuNode">XML-node for the Search settings</param>
        public SearchSettings(XmlNode searchNode)
        {
            string xpath;

            xpath     = "./cacheTime";
            CacheTime = SettingsHelper.GetSettingValue(xpath, searchNode, 60);

            xpath            = "./resultListLength";
            ResultListLength = SettingsHelper.GetSettingValue(xpath, searchNode, 250);

            xpath           = "./defaultOperator";
            DefaultOperator = SettingsHelper.GetSettingValue(xpath, searchNode, PCAxis.Search.DefaultOperator.OR);
        }