コード例 #1
0
        public static void LinksBasedFrequencyStoredOptimalVariantSequenceTest()
        {
            using (var scope = new TempLinksTestScope(useSequences: false))
            {
                var links     = scope.Links;
                var constants = links.Constants;

                links.UseUnicode();

                var sequence = UnicodeMap.FromStringToLinkArray(_sequenceExample);

                var meaningRoot             = links.CreatePoint();
                var unaryOne                = links.CreateAndUpdate(meaningRoot, constants.Itself);
                var frequencyMarker         = links.CreateAndUpdate(meaningRoot, constants.Itself);
                var frequencyPropertyMarker = links.CreateAndUpdate(meaningRoot, constants.Itself);

                var unaryNumberToAddressConverter = new UnaryNumberToAddressAddOperationConverter <ulong>(links, unaryOne);
                var unaryNumberIncrementer        = new UnaryNumberIncrementer <ulong>(links, unaryOne);
                var frequencyIncrementer          = new FrequencyIncrementer <ulong>(links, frequencyMarker, unaryOne, unaryNumberIncrementer);
                var frequencyPropertyOperator     = new PropertyOperator <ulong>(links, frequencyPropertyMarker, frequencyMarker);
                var index = new FrequencyIncrementingSequenceIndex <ulong>(links, frequencyPropertyOperator, frequencyIncrementer);
                var linkToItsFrequencyNumberConverter        = new LinkToItsFrequencyNumberConveter <ulong>(links, frequencyPropertyOperator, unaryNumberToAddressConverter);
                var sequenceToItsLocalElementLevelsConverter = new SequenceToItsLocalElementLevelsConverter <ulong>(links, linkToItsFrequencyNumberConverter);
                var optimalVariantConverter = new OptimalVariantConverter <ulong>(links, sequenceToItsLocalElementLevelsConverter);

                var sequences = new Sequences.Sequences(links, new SequencesOptions <ulong>()
                {
                    Walker = new LeveledSequenceWalker <ulong>(links)
                });

                ExecuteTest(sequences, sequence, sequenceToItsLocalElementLevelsConverter, index, optimalVariantConverter);
            }
        }
コード例 #2
0
ファイル: QueryExtensions.cs プロジェクト: 569550384/Rafy
 /// <summary>
 /// 为查询添加一个对应的约束条件,并以 And 与原条件进行连接。
 /// </summary>
 /// <param name="query">查询.</param>
 /// <param name="property">要约束的属性.</param>
 /// <param name="op">约束条件操作符.</param>
 /// <param name="value">对比的值。</param>
 /// <returns></returns>
 public static IQuery AddConstraint(this IQuery query, IManagedProperty property, PropertyOperator op, object value)
 {
     var source = query.MainTable;
     if (!property.OwnerType.IsAssignableFrom(source.EntityRepository.EntityType))
     {
         source = query.From.FindTable(property.OwnerType);
     }
     return AddConstraint(query, property, op, value, source);
 }
コード例 #3
0
        public static PropertyOperator Reverse(PropertyOperator op)
        {
            switch (op)
            {
            case PropertyOperator.Equal:
                return(PropertyOperator.NotEqual);

            case PropertyOperator.NotEqual:
                return(PropertyOperator.Equal);

            case PropertyOperator.Greater:
                return(PropertyOperator.LessEqual);

            case PropertyOperator.GreaterEqual:
                return(PropertyOperator.Less);

            case PropertyOperator.Less:
                return(PropertyOperator.GreaterEqual);

            case PropertyOperator.LessEqual:
                return(PropertyOperator.Greater);

            case PropertyOperator.Like:
                return(PropertyOperator.NotLike);

            case PropertyOperator.NotLike:
                return(PropertyOperator.Like);

            case PropertyOperator.Contains:
                return(PropertyOperator.NotContains);

            case PropertyOperator.NotContains:
                return(PropertyOperator.Contains);

            case PropertyOperator.StartsWith:
                return(PropertyOperator.NotStartsWith);

            case PropertyOperator.NotStartsWith:
                return(PropertyOperator.StartsWith);

            case PropertyOperator.EndsWith:
                return(PropertyOperator.NotEndsWith);

            case PropertyOperator.NotEndsWith:
                return(PropertyOperator.EndsWith);

            case PropertyOperator.In:
                return(PropertyOperator.NotIn);

            case PropertyOperator.NotIn:
                return(PropertyOperator.In);

            default:
                throw new NotSupportedException();
            }
        }
コード例 #4
0
        public TreeNode CheckForSpecialProperty(string name, string value, PropertyOperator op, bool excluded)
        {
            PropertyKeyword propertyKeyword;
            KindKeyword     kindKeyword;

            if (this.errors != null && this.keywordMapping.TryGetPropertyKeyword(name, out propertyKeyword) && propertyKeyword == PropertyKeyword.Kind && !this.keywordMapping.TryGetKindKeyword(value, out kindKeyword))
            {
                this.errors.Add(new ParserErrorInfo(ParserErrorCode.InvalidKindFormat));
            }
            return(null);
        }
コード例 #5
0
ファイル: QueryFactory.cs プロジェクト: yungtau/oea
        /// <summary>
        /// 构造一个属性的约束条件节点。
        /// </summary>
        /// <param name="column">要对比的属性。</param>
        /// <param name="op">对比操作符</param>
        /// <param name="value">要对比的值。</param>
        /// <returns></returns>
        public IConstraint Constraint(
            IColumnNode column,
            PropertyOperator op,
            object value
            )
        {
            IColumnConstraint res = new Impl.ColumnConstraint();

            res.Column   = column;
            res.Operator = op;
            res.Value    = value;
            return(res);
        }
コード例 #6
0
        public static void StringAndUnicodeSequenceConvertersTest()
        {
            using (var scope = new TempLinksTestScope())
            {
                var links = scope.Links;

                var itself = links.Constants.Itself;

                var meaningRoot             = links.CreatePoint();
                var unaryOne                = links.CreateAndUpdate(meaningRoot, itself);
                var unicodeSymbolMarker     = links.CreateAndUpdate(meaningRoot, itself);
                var unicodeSequenceMarker   = links.CreateAndUpdate(meaningRoot, itself);
                var frequencyMarker         = links.CreateAndUpdate(meaningRoot, itself);
                var frequencyPropertyMarker = links.CreateAndUpdate(meaningRoot, itself);

                var powerOf2ToUnaryNumberConverter = new PowerOf2ToUnaryNumberConverter <ulong>(links, unaryOne);
                var addressToUnaryNumberConverter  = new AddressToUnaryNumberConverter <ulong>(links, powerOf2ToUnaryNumberConverter);
                var charToUnicodeSymbolConverter   = new CharToUnicodeSymbolConverter <ulong>(links, addressToUnaryNumberConverter, unicodeSymbolMarker);

                var unaryNumberToAddressConverter = new UnaryNumberToAddressOrOperationConverter <ulong>(links, powerOf2ToUnaryNumberConverter);
                var unaryNumberIncrementer        = new UnaryNumberIncrementer <ulong>(links, unaryOne);
                var frequencyIncrementer          = new FrequencyIncrementer <ulong>(links, frequencyMarker, unaryOne, unaryNumberIncrementer);
                var frequencyPropertyOperator     = new PropertyOperator <ulong>(links, frequencyPropertyMarker, frequencyMarker);
                var index = new FrequencyIncrementingSequenceIndex <ulong>(links, frequencyPropertyOperator, frequencyIncrementer);
                var linkToItsFrequencyNumberConverter        = new LinkToItsFrequencyNumberConveter <ulong>(links, frequencyPropertyOperator, unaryNumberToAddressConverter);
                var sequenceToItsLocalElementLevelsConverter = new SequenceToItsLocalElementLevelsConverter <ulong>(links, linkToItsFrequencyNumberConverter);
                var optimalVariantConverter = new OptimalVariantConverter <ulong>(links, sequenceToItsLocalElementLevelsConverter);

                var stringToUnicodeSequenceConverter = new StringToUnicodeSequenceConverter <ulong>(links, charToUnicodeSymbolConverter, index, optimalVariantConverter, unicodeSequenceMarker);

                var originalString = "Hello";

                var unicodeSequenceLink = stringToUnicodeSequenceConverter.Convert(originalString);

                var unicodeSymbolCriterionMatcher = new TargetMatcher <ulong>(links, unicodeSymbolMarker);
                var unicodeSymbolToCharConverter  = new UnicodeSymbolToCharConverter <ulong>(links, unaryNumberToAddressConverter, unicodeSymbolCriterionMatcher);

                var unicodeSequenceCriterionMatcher = new TargetMatcher <ulong>(links, unicodeSequenceMarker);

                var sequenceWalker = new LeveledSequenceWalker <ulong>(links, unicodeSymbolCriterionMatcher.IsMatched);

                var unicodeSequenceToStringConverter = new UnicodeSequenceToStringConverter <ulong>(links, unicodeSequenceCriterionMatcher, sequenceWalker, unicodeSymbolToCharConverter);

                var resultingString = unicodeSequenceToStringConverter.Convert(unicodeSequenceLink);

                Assert.Equal(originalString, resultingString);
            }
        }
コード例 #7
0
ファイル: QueryExtensions.cs プロジェクト: 569550384/Rafy
        /// <summary>
        /// 为查询添加一个对应的约束条件,并以 And 与原条件进行连接。
        /// </summary>
        /// <param name="query">查询.</param>
        /// <param name="property">要约束的属性.</param>
        /// <param name="op">约束条件操作符.</param>
        /// <param name="value">对比的值。</param>
        /// <param name="propertySource">指定该属性所属的实体数据源。</param>
        /// <returns></returns>
        public static IQuery AddConstraint(this IQuery query, IManagedProperty property, PropertyOperator op, object value, ITableSource propertySource)
        {
            var f = QueryFactory.Instance;

            var propertyNode = propertySource.Column(property);

            var where = f.Constraint(propertyNode, op, value);
            if (query.Where == null)
            {
                query.Where = where;
            }
            else
            {
                query.Where = f.And(query.Where, where);
            }

            return query;
        }
コード例 #8
0
ファイル: PropertyOperator.cs プロジェクト: 569550384/Rafy
 public static PropertyOperator Reverse(PropertyOperator op)
 {
     switch (op)
     {
         case PropertyOperator.Equal:
             return PropertyOperator.NotEqual;
         case PropertyOperator.NotEqual:
             return PropertyOperator.Equal;
         case PropertyOperator.Greater:
             return PropertyOperator.LessEqual;
         case PropertyOperator.GreaterEqual:
             return PropertyOperator.Less;
         case PropertyOperator.Less:
             return PropertyOperator.GreaterEqual;
         case PropertyOperator.LessEqual:
             return PropertyOperator.Greater;
         case PropertyOperator.Like:
             return PropertyOperator.NotLike;
         case PropertyOperator.NotLike:
             return PropertyOperator.Like;
         case PropertyOperator.Contains:
             return PropertyOperator.NotContains;
         case PropertyOperator.NotContains:
             return PropertyOperator.Contains;
         case PropertyOperator.StartsWith:
             return PropertyOperator.NotStartsWith;
         case PropertyOperator.NotStartsWith:
             return PropertyOperator.StartsWith;
         case PropertyOperator.EndsWith:
             return PropertyOperator.NotEndsWith;
         case PropertyOperator.NotEndsWith:
             return PropertyOperator.EndsWith;
         case PropertyOperator.In:
             return PropertyOperator.NotIn;
         case PropertyOperator.NotIn:
             return PropertyOperator.In;
         default:
             throw new NotSupportedException();
     }
 }
コード例 #9
0
ファイル: QueryFactory.cs プロジェクト: yungtau/oea
        /// <summary>
        /// 构造一个两个属性进行对比的约束条件节点。
        /// </summary>
        /// <param name="leftColumn">第一个需要对比的列。</param>
        /// <param name="op">对比条件。</param>
        /// <param name="rightColumn">第二个需要对比的列。</param>
        /// <returns></returns>
        /// <exception cref="System.ArgumentNullException">
        /// leftProperty
        /// or
        /// rightProperty
        /// </exception>
        public IConstraint Constraint(
            IColumnNode leftColumn,
            PropertyOperator op,
            IColumnNode rightColumn
            )
        {
            if (leftColumn == null)
            {
                throw new ArgumentNullException("leftProperty");
            }
            if (rightColumn == null)
            {
                throw new ArgumentNullException("rightProperty");
            }

            IColumnsComparison res = new Impl.ColumnsComparison();

            res.LeftColumn  = leftColumn;
            res.RightColumn = rightColumn;
            res.Operator    = op;
            return(res);
        }
コード例 #10
0
ファイル: CommonQueryCriteria.cs プロジェクト: zhuwansu/Rafy
 public PropertyMatch(string property, PropertyOperator op, object value)
 {
     this.PropertyName = property;
     this.Operator     = op;
     this.Value        = value;
 }
コード例 #11
0
        /// <summary>
        /// 为查询添加一个对应的约束条件,并以 And 与原条件进行连接。
        /// </summary>
        /// <param name="query">查询.</param>
        /// <param name="property">要约束的属性.</param>
        /// <param name="op">约束条件操作符.</param>
        /// <param name="value">对比的值。</param>
        /// <returns></returns>
        public static IQuery AddConstraint(this IQuery query, IManagedProperty property, PropertyOperator op, object value)
        {
            var source = query.MainTable;

            if (!property.OwnerType.IsAssignableFrom(source.EntityRepository.EntityType))
            {
                source = query.From.FindTable(property.OwnerType);
            }
            return(AddConstraint(query, property, op, value, source));
        }
コード例 #12
0
        /// <summary>
        /// 如果提供的值是不可空的,则为查询添加一个对应的约束条件,并以 And 与原条件进行连接。
        /// </summary>
        /// <param name="query">查询.</param>
        /// <param name="property">要约束的属性.</param>
        /// <param name="op">约束条件操作符.</param>
        /// <param name="value">当 value 不可空时,才添加这个对比约束条件。</param>
        /// <param name="propertySource">指定该属性所属的实体数据源。</param>
        /// <returns></returns>
        public static IQuery AddConstraintIf(this IQuery query, IManagedProperty property, PropertyOperator op, object value, ITableSource propertySource)
        {
            if (DomainHelper.IsNotEmpty(value))
            {
                return(AddConstraint(query, property, op, value, propertySource));
            }

            return(query);
        }
コード例 #13
0
        /// <summary>
        /// 为查询添加一个对应的约束条件,并以 And 与原条件进行连接。
        /// </summary>
        /// <param name="query">查询.</param>
        /// <param name="property">要约束的属性.</param>
        /// <param name="op">约束条件操作符.</param>
        /// <param name="value">对比的值。</param>
        /// <param name="propertySource">指定该属性所属的实体数据源。</param>
        /// <returns></returns>
        public static IQuery AddConstraint(this IQuery query, IManagedProperty property, PropertyOperator op, object value, ITableSource propertySource)
        {
            var f = QueryFactory.Instance;

            var propertyNode = propertySource.Column(property);

            var where = f.Constraint(propertyNode, op, value);
            if (query.Where == null)
            {
                query.Where = where;
            }
            else
            {
                query.Where = f.And(query.Where, where);
            }

            return(query);
        }
コード例 #14
0
 /// <summary>
 /// 如果提供的值是不可空的,则为查询添加一个对应的约束条件,并以 And 与原条件进行连接。
 /// </summary>
 /// <param name="query">查询.</param>
 /// <param name="property">要约束的属性.</param>
 /// <param name="op">约束条件操作符.</param>
 /// <param name="value">当 value 不可空时,才添加这个对比约束条件。</param>
 /// <returns></returns>
 public static IQuery AddConstraintIf(this IQuery query, IManagedProperty property, PropertyOperator op, object value)
 {
     if (ConditionalSql.IsNotEmpty(value))
     {
         return(AddConstraint(query, property, op, value));
     }
     return(query);
 }
コード例 #15
0
ファイル: CommonQueryCriteria.cs プロジェクト: zhuwansu/Rafy
 public PropertyMatch(IManagedProperty property, PropertyOperator op, object value)
     : this(property.Name, op, value)
 {
 }
コード例 #16
0
ファイル: CommonQueryCriteria.cs プロジェクト: zhuwansu/Rafy
 /// <summary>
 /// 添加一个属性匹配条件到本组中。
 /// </summary>
 /// <param name="property">The property.</param>
 /// <param name="op">The op.</param>
 /// <param name="value">The value.</param>
 public void Add(IManagedProperty property, PropertyOperator op, object value)
 {
     this.Add(new PropertyMatch(property, op, value));
 }
コード例 #17
0
ファイル: QueryExtensions.cs プロジェクト: 569550384/Rafy
        /// <summary>
        /// 如果提供的值是不可空的,则为查询添加一个对应的约束条件,并以 And 与原条件进行连接。
        /// </summary>
        /// <param name="query">查询.</param>
        /// <param name="property">要约束的属性.</param>
        /// <param name="op">约束条件操作符.</param>
        /// <param name="value">当 value 不可空时,才添加这个对比约束条件。</param>
        /// <param name="propertySource">指定该属性所属的实体数据源。</param>
        /// <returns></returns>
        public static IQuery AddConstraintIf(this IQuery query, IManagedProperty property, PropertyOperator op, object value, ITableSource propertySource)
        {
            if (DomainHelper.IsNotEmpty(value))
            {
                return AddConstraint(query, property, op, value, propertySource);
            }

            return query;
        }