Ejemplo n.º 1
0
        private static SearchTerm <TSearchHeadEnum> Create(Func <SearchTerm <TSearchHeadEnum> > searchTermFactory, TSearchHeadEnum head, string value, Type type = null)
        {
            SearchTerm <TSearchHeadEnum> p;

            if (searchTermFactory == null)
            {
                p = new SearchTerm <TSearchHeadEnum>();
            }
            else
            {
                p = searchTermFactory();
            }

            if (type == null)
            {
                type = typeof(string);
            }

            p.Head      = head;
            p.Value     = value;
            p.ValueType = type;

            if (p.Value.EndsWith("*"))
            {
                p.Value = p.Value.Substring(0, value.Length - 1);
                p.WithWildcardSuffix = true;
            }

            if (p.Value.StartsWith("*"))
            {
                p.Value = p.Value.Substring(1);
                p.WithWildcardPrefix = true;
            }

            return(p);
        }
Ejemplo n.º 2
0
        public static void Add <TSearchHeadEnum, TValue>(this List <SearchTerm <TSearchHeadEnum> > target, TSearchHeadEnum head, TValue value) where TSearchHeadEnum : struct, IConvertible
        {
            var q = SearchTerm <TSearchHeadEnum> .Create(head, value);

            target.Add(q);
        }