예제 #1
0
        public static Search LoadSearch(XmlNode node)
        {
            String uuid = Helpers.GetXmlAttribute(node, "uuid");
            String name = Helpers.GetXmlAttribute(node, "name");
            int major_version = int.Parse(Helpers.GetXmlAttribute(node, "major_version"));
            //int minor_version = int.Parse(Helpers.GetXmlAttribute(node, "minor_version"));

            XmlAttribute expanded = node.Attributes["show_expanded"];
            if (expanded == null)
            {
                // Backwards compat.
                expanded = node.Attributes["showsearch"];
            }
            bool showQuery = expanded == null ? false : ParseBool(expanded.Value);

            if (major_version > CURRENT_SEARCH_MAJOR_VERSION)
                throw new SearchVersionException(major_version, CURRENT_SEARCH_MAJOR_VERSION);

            Query query;
            Object q = FromXmlNode(node.ChildNodes[0]);
            switch (major_version)
            {
                case 0:
                case 1:
                    QueryFilter filter = q as QueryFilter;
                    if (filter == null)
                        throw new I18NException(I18NExceptionType.XmlInvalid, node.OuterXml);
                    query = new Query(null, filter);
                    break;
                default:
                    query = q as Query;
                    if (query == null || query.QueryScope == null)  // query.QueryFilter == null is allowed
                        throw new I18NException(I18NExceptionType.XmlInvalid, node.OuterXml);
                    break;
            }

            Grouping grouping = null;
            Sort[] sorting = new Sort[] { };
            List<KeyValuePair<String, int>> columns = null;
            int i = 0;
            foreach (XmlNode child in node.ChildNodes)
            {
                if (i != 0)
                {
                    if (child.Name == "columns")
                    {
                        columns = LoadColumns(child);
                    }
                    else if (child.Name == "sorting")
                    {
                        sorting = LoadSorting(child);
                    }
                    else
                    {
                        grouping = (Grouping)FromXmlNode(child);
                    }
                }

                i++;
            }

            return new Search(query, grouping, showQuery, name, uuid, columns, sorting);
        }
예제 #2
0
        private void FilterAdd(Query query, IXenObject o)
        {
            if (query == null || !query.Match(o))
                return;

            Add(o);
        }
예제 #3
0
 private Search EverythingInFolders()
 {
     QueryScope scope = new QueryScope(ObjectTypes.AllIncFolders);
     QueryFilter filter = new NullQuery<Folder>(PropertyNames.folder, false);
     Query q = new Query(scope, filter);
     Grouping grouping = new FolderGrouping((Grouping)null);
     return new Search(q, grouping, false, "", null, false);
 }