Esempio n. 1
0
        /// <summary>Constructor, given a category as a string from the URI.</summary>
        public QueryCategory(string strCategory, QueryCategoryOperator op)
        {
            Tracing.TraceMsg("Depersisting category from: " + strCategory);
            _categoryOperator = op;
            strCategory       = FeedQuery.CleanPart(strCategory);

            // let's parse the string
            if (strCategory[0] == '-')
            {
                // negator
                _isExcluded = true;
                // remove him
                strCategory = strCategory.Substring(1, strCategory.Length - 1);
            }

            // let's extract the scheme if there is one...
            int     iStart = strCategory.IndexOf('{');
            int     iEnd   = strCategory.IndexOf('}');
            AtomUri scheme = null;

            if (iStart != -1 && iEnd != -1)
            {
                iEnd++;
                iStart++;
                scheme = new AtomUri(strCategory.Substring(iStart, iEnd - iStart - 1));
                // the rest is then
                strCategory = strCategory.Substring(iEnd, strCategory.Length - iEnd);
            }

            Tracing.TraceMsg("Category found: " + strCategory + " - scheme: " + scheme);

            _category = new AtomCategory(strCategory, scheme);
        }
Esempio n. 2
0
        //////////////////////////////////////////////////////////////////////
        /// <summary>Constructor, given a category as a string from the URI.</summary>
        //////////////////////////////////////////////////////////////////////
        public QueryCategory(string strCategory, QueryCategoryOperator op)
        {
            Tracing.TraceMsg("Depersisting category from: " + strCategory); 
            this.categoryOperator = op; 
            strCategory = FeedQuery.CleanPart(strCategory); 

            // let's parse the string
            if (strCategory[0] == '-')
            {
                // negator
                this.isExcluded = true; 
                // remove him
                strCategory = strCategory.Substring(1, strCategory.Length-1); 
            }

            // let's extract the scheme if there is one...
            int iStart = strCategory.IndexOf('{') ; 
            int iEnd = strCategory.IndexOf('}') ; 
            AtomUri scheme = null; 
            if (iStart != -1 && iEnd != -1)
            {
                // 
                iEnd++;
                iStart++;
                scheme = new AtomUri(strCategory.Substring(iStart, iEnd- iStart-1)); 
                // the rest is then
                strCategory = strCategory.Substring(iEnd, strCategory.Length - iEnd); 

            }

            Tracing.TraceMsg("Category found: " + strCategory + " - scheme: " + scheme); 

            this.category = new AtomCategory(strCategory, scheme);
        }
        public void QueryCategoryConstructorTest()
        {
            string strCategory           = "TestValue"; // TODO: Initialize to an appropriate value
            QueryCategoryOperator op     = QueryCategoryOperator.OR;
            QueryCategory         target = new QueryCategory(strCategory, op);

            Assert.IsNotNull(target);
            Assert.AreEqual(target.Operator, op);
        }
        public void OperatorTest()
        {
            AtomCategory          category = new AtomCategory("term");
            QueryCategory         target   = new QueryCategory(category); // TODO: Initialize to an appropriate value
            QueryCategoryOperator expected = QueryCategoryOperator.AND;
            QueryCategoryOperator actual;

            target.Operator = expected;
            actual          = target.Operator;
            Assert.AreEqual(expected, actual);
        }
Esempio n. 5
0
        /// <summary>
        /// this will take one category part and parse it
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        private void ParseCategoryString(string category)
        {
            // take the string, and create some category objects out of it...

            // replace the curly braces and the or operator | so that we can tokenize better
            category = category.Replace("%7B", "{");
            category = category.Replace("%7D", "}");
            category = category.Replace("%7C", "|");
            category = Utilities.UrlDecodedValue(category);

            // let's see if it's the only one...
            TokenCollection tokens = new TokenCollection(category, new char[1] {
                '|'
            });
            QueryCategoryOperator op = QueryCategoryOperator.AND;

            foreach (String token in tokens)
            {
                // each one is a category
                QueryCategory cat = new QueryCategory(token, op);
                this.Categories.Add(cat);
                op = QueryCategoryOperator.OR;
            }
        }
Esempio n. 6
0
 //////////////////////////////////////////////////////////////////////
 /// <summary>Constructor, given a category.</summary>
 //////////////////////////////////////////////////////////////////////
 public QueryCategory(AtomCategory category)
 {
     this.category = category;
     this.categoryOperator = QueryCategoryOperator.AND; 
 }
Esempio n. 7
0
 /// <summary>Constructor, given a category.</summary>
 public QueryCategory(AtomCategory category)
 {
     _category         = category;
     _categoryOperator = QueryCategoryOperator.AND;
 }
 //////////////////////////////////////////////////////////////////////
 /// <summary>Constructor, given a category.</summary>
 //////////////////////////////////////////////////////////////////////
 public QueryCategory(AtomCategory category)
 {
     this.category         = category;
     this.categoryOperator = QueryCategoryOperator.AND;
 }