Exemplo n.º 1
0
        private static void RegisterMapping(QueryKeywordMapping mapping)
        {
            // If multiple mapping as registered, create an OR query for them
            // Store the multiple matchings in a list
            if (property_table.Contains(mapping.Keyword))
            {
                object o = property_table [mapping.Keyword];
                if (o is ArrayList)
                {
                    ((ArrayList)o).Add(mapping);
                }
                else if (o is QueryKeywordMapping)
                {
                    ArrayList list = new ArrayList(2);
                    list.Add(o);
                    list.Add(mapping);
                    property_table [mapping.Keyword] = list;
                }
                return;
            }

            property_table.Add(mapping.Keyword, mapping);
        }
Exemplo n.º 2
0
        ////////////////////////////////////////////////////////

        // return false if property not found!
        public static bool GetMapping(string keyword, out int num, out string[] name, out PropertyType[] type)
        {
            num  = 0;
            name = null;
            type = null;

            if (!property_table.Contains(keyword))
            {
                return(false);
            }

            object o = property_table [keyword];

            if (o is ArrayList)
            {
                ArrayList list = (ArrayList)o;
                num  = list.Count;
                name = new string [num];
                type = new PropertyType [num];

                for (int i = 0; i < num; ++i)
                {
                    QueryKeywordMapping mapping = (QueryKeywordMapping)(list [i]);
                    name [i] = mapping.PropertyName;
                    type [i] = (mapping.IsKeyword ? PropertyType.Keyword : PropertyType.Text);
                }
            }
            else if (o is QueryKeywordMapping)
            {
                num      = 1;
                name     = new string [num];
                type     = new PropertyType [num];
                name [0] = ((QueryKeywordMapping)o).PropertyName;
                type [0] = (((QueryKeywordMapping)o).IsKeyword ? PropertyType.Keyword : PropertyType.Text);
            }
            return(true);
        }