コード例 #1
0
        public void TestEndsWithFilter()
        {
            EndsWithFilter v1 = new EndsWithFilter(ConnectorAttributeBuilder.Build("foo", "bar"));
            EndsWithFilter v2 = (EndsWithFilter)CloneObject(v1);

            Assert.AreEqual(v1.GetAttribute(), v2.GetAttribute());
        }
コード例 #2
0
        /// <summary>
        /// 得到所有的Sprite图集的地址
        /// </summary>
        public static List <string> GetAllSpritePath()
        {
            string[] files = Directory.GetFiles(ESpriteConst.ui_sprite_root_dir, "*.*", SearchOption.AllDirectories);

            EndsWithFilter suffix = new EndsWithFilter();

            suffix.AddSuffix(ESpriteConst.sprite_suffix);
            List <string> infos = SuffixHelper.Filter(files, suffix);

            return(infos);
        }
コード例 #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="p"></param>
        /// <param name="filter"></param>
        /// <returns></returns>
        public string VisitEndsWithFilter(Hashtable p, EndsWithFilter filter)
        {
            var name  = filter.GetName();
            var name2 = name as String;

            if (p.ContainsKey(name))
            {
                name2 = p[name] as String;
            }
            return(string.Format("{0} -like \"{1}{2}\"", name2, "*", filter.GetValue()));
        }
コード例 #4
0
        public void CanHaveNullValue()
        {
            var e = new SystemEvent {
                Message = "Message Ends"
            };
            var extendedProperties = new FakeExtendedProperties {
                { "property", "Message" }, { "value", null }
            };
            var filter = new EndsWithFilter(extendedProperties, Enumerable.Empty <ICreateFilterExpressions>());

            Assert.True(Filter.Compile(filter).Invoke(e));
        }
コード例 #5
0
        public void ReturnFalseIfStringDoesNotEndWithValue()
        {
            var e = new SystemEvent {
                Message = "Message Ends "
            };
            var extendedProperties = new FakeExtendedProperties {
                { "property", "Message" }, { "value", "Ends" }
            };
            var filter = new EndsWithFilter(extendedProperties, Enumerable.Empty <ICreateFilterExpressions>());

            Assert.False(Filter.Compile(filter).Invoke(e));
        }
コード例 #6
0
        public void AlwaysCaseInsensitive()
        {
            var e = new SystemEvent {
                Message = "Message ENDS"
            };
            var extendedProperties = new FakeExtendedProperties {
                { "property", "Message" }, { "value", "Ends" }
            };
            var filter = new EndsWithFilter(extendedProperties, Enumerable.Empty <ICreateFilterExpressions>());

            Assert.True(Filter.Compile(filter).Invoke(e));
        }
コード例 #7
0
            private IFilter CreateFilter(OperatorType operators, string propertyName, string propertyValue)
            {
                IFilter filter = null;

                switch (operators)
                {
                case OperatorType.eq:
                    filter = new EqualToFilter(propertyName, propertyValue);
                    break;

                case OperatorType.ne:
                    filter = new NotEqualToFilter(propertyName, propertyValue);
                    break;

                case OperatorType.startswith:
                    filter = new StartsWithFilter(propertyName, propertyValue);
                    break;

                case OperatorType.endswith:
                    filter = new EndsWithFilter(propertyName, propertyValue);
                    break;

                case OperatorType.substringof:
                    filter = new SubstringFilter(propertyName, propertyValue);
                    break;

                    /* currently not supported
                     * case OperatorType.lt:
                     *  filter = new LessThanFilter(propertyName, propertyValue);
                     *  break;
                     * case OperatorType.le:
                     *  filter = new LessThanOrEqualFilter(propertyName, propertyValue);
                     *  break;
                     * case OperatorType.gt:
                     *  filter = new GreaterThanFilter(propertyName, propertyValue);
                     *  break;
                     * case OperatorType.ge:
                     *  filter = new GreaterThanOrEqualFilter(propertyName, propertyValue);
                     *  break;
                     */
                }

                return(filter);
            }
コード例 #8
0
        protected override String CreateEndsWithExpression(EndsWithFilter filter,
                                                           Boolean not)
        {
            String[] attrNames = GetLdapNamesForAttribute(filter.GetAttribute());
            if (attrNames == null)
            {
                return(null);
            }

            StringBuilder builder = new StringBuilder();

            if (not)
            {
                builder.Append("(!");
            }
            if (attrNames.Length == 1)
            {
                builder.Append('(');
                builder.Append(attrNames[0]);
                builder.Append("=*");
                GetLdapFilterValue(builder, attrNames[0], filter.GetValue());
                builder.Append(')');
            }
            else
            {
                builder.Append("(|");
                foreach (String attrName in attrNames)
                {
                    builder.Append('(');
                    builder.Append(attrName);
                    builder.Append("=*");
                    GetLdapFilterValue(builder, attrName, filter.GetValue());
                    builder.Append(')');
                }
                builder.Append(')');
            }
            if (not)
            {
                builder.Append(')');
            }
            return(builder.ToString());
        }
コード例 #9
0
        public void EnsureImplicitAndFilter()
        {
            // Arrange
            var client = this.GetShareFileClient(true);
            var query  = client.Items.GetChildren(client.Items.GetAlias("fileId"));

            // Act
            var endsWithFilter   = new EndsWithFilter("Property", "value");
            var startsWithFilter = new StartsWithFilter("Property", "value");

            query = query.Filter(endsWithFilter).Filter(startsWithFilter);

            var odataQuery = query as Query <ODataFeed <Item> >;
            var filter     = odataQuery.GetFilter();

            // Assert
            filter.Should().BeOfType <AndFilter>();
            (filter as AndFilter).Left.Should().Be(endsWithFilter);
            (filter as AndFilter).Right.Should().Be(startsWithFilter);
        }
コード例 #10
0
 protected override IDictionary <String, Object> CreateEndsWithExpression(EndsWithFilter filter, Boolean not)
 {
     return(CreateFilter("ENDSWITH", filter, not));
 }
コード例 #11
0
        public void NotCompositeExpression()
        {
            var filter = new EndsWithFilter(new FakeExtendedProperties(), Enumerable.Empty <ICreateFilterExpressions>());

            Assert.False(filter.CompositeExpression);
        }
コード例 #12
0
 public void TestEndsWithFilter()
 {
     EndsWithFilter v1 = new EndsWithFilter(ConnectorAttributeBuilder.Build("foo", "bar"));
     EndsWithFilter v2 = (EndsWithFilter)CloneObject(v1);
     Assert.AreEqual(v1.GetAttribute(), v2.GetAttribute());
 }
コード例 #13
0
        public void EndsWithFilter(bool isEqual)
        {
            var filter = new EndsWithFilter("Name", "ShareFile", isEqual);

            filter.ToString().Should().Be("endswith(Name, 'ShareFile') eq " + isEqual.ToLowerString());
        }
コード例 #14
0
 protected override Filter CreateEndsWithExpression(EndsWithFilter filter, bool not)
 {
     return(not ? FilterBuilder.Not(filter) : filter);
 }
コード例 #15
0
 public string VisitEndsWithFilter(Hashtable p, EndsWithFilter filter)
 {
     throw new NotImplementedException();
 }
コード例 #16
0
        protected override String CreateEndsWithExpression(EndsWithFilter filter, bool not)
        {
            String rv = "( ENDS-WITH " + filter.GetName() + " " + filter.GetValue() + " )";

            return(Not(rv, not));
        }
コード例 #17
0
 protected override String CreateEndsWithExpression(EndsWithFilter filter, bool not)
 {
     return(null);
 }
コード例 #18
0
 public Dictionary <string, object> VisitEndsWithFilter(Hashtable p, EndsWithFilter filter)
 {
     return(CreateMap("ENDSWITH", filter.GetName(), filter.GetValue()));
 }