当前位置: 首页>>代码示例>>C#>>正文


C# KeyRange类代码示例

本文整理汇总了C#中KeyRange的典型用法代码示例。如果您正苦于以下问题:C# KeyRange类的具体用法?C# KeyRange怎么用?C# KeyRange使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


KeyRange类属于命名空间,在下文中一共展示了KeyRange类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetNextValue

        public int GetNextValue(string entity)
        {
            lock (_d)
            {
                KeyRange kr;
                if (_d.TryGetValue(entity, out kr))
                {
                    kr.Current++;
                    if (kr.Current < kr.Max)
                    {
                        return kr.Current;
                    }
                    _d.Remove(entity);
                }

                var res = Db.GetCollection("hilo").FindAndModify(
                    MongoQueryBuilder.DynQuery(x => x._id == entity),
                    SortBy.Ascending("_id"),
                    Update.Inc("cnt", Range), false, true);
                if (!res.Ok) throw new Exception(res.ErrorMessage);
                var d = res.ModifiedDocument;
                kr = new KeyRange();
                kr.Current = d.GetValue("cnt", MongoDB.Bson.BsonValue.Create(0)).AsInt32;
                kr.Max = kr.Current + Range;
                _d[entity] = kr;
                return kr.Current;
            }
        }
开发者ID:lafar6502,项目名称:cogmon,代码行数:28,代码来源:MongoKeyGen.cs

示例2: TestSample9

 public void TestSample9()
 {
     // Regression test for:
     //   KeyRange is too small.
     //   Expression:
     //     x => Not(((2137 >= x.Key) && Not((-3611 = x.Key))))
     KeyRange<int> actual =
         KeyValueExpressionEvaluator<int, int>.GetKeyRange(
             x => !((2137 >= x.Key) && !(-3611 == x.Key)));
     KeyRange<int> expected = new KeyRange<int>(Key<int>.CreateKey(-3611, true), null);
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:12,代码来源:KeyValueExpressionEvaluatorTests.cs

示例3: TestNullableBoolExpression

 public void TestNullableBoolExpression()
 {
     Func<bool?> f = () => false;
     var expected = new KeyRange<bool>(Key<bool>.CreateKey(false, true), Key<bool>.CreateKey(false, true));
     var actual = KeyValueExpressionEvaluator<bool, string>.GetKeyRange(x => x.Key == f());
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:7,代码来源:KeyValueExpressionEvaluatorTests.cs

示例4: KeyRangeIsSufficient

        /// <summary>
        /// Determine if the given range matches at least the records described
        /// by the min/max values.
        /// </summary>
        /// <param name="keyRange">The key range.</param>
        /// <param name="min">The minimum value.</param>
        /// <param name="max">The maximum value.</param>
        /// <returns>True if the KeyRange is a superset of the values.</returns>
        private static bool KeyRangeIsSufficient(KeyRange<int> keyRange, int min, int max)
        {
            bool minIsSufficient =
                (null == keyRange.Min)
                || (keyRange.Min.Value == min && keyRange.Min.IsInclusive)
                || keyRange.Min.Value < min;

            bool maxIsSufficient =
                (null == keyRange.Max)
                || (keyRange.Max.Value == max && keyRange.Max.IsInclusive)
                || keyRange.Max.Value > max;

            return minIsSufficient && maxIsSufficient;
        }
开发者ID:925coder,项目名称:ravendb,代码行数:22,代码来源:RandomInt32RangeExpressionTests.cs

示例5: VerifyNotOfGeGivesLt

 public void VerifyNotOfGeGivesLt()
 {
     KeyRange<int> actual = KeyValueExpressionEvaluator<int, string>.GetKeyRange(x => !(x.Key >= 4));
     KeyRange<int> expected = new KeyRange<int>(null, Key<int>.CreateKey(4, false));
 }
开发者ID:925coder,项目名称:ravendb,代码行数:5,代码来源:KeyValueExpressionEvaluatorTests.cs

示例6: VerifyComparisonWithComplexNullable

 public void VerifyComparisonWithComplexNullable()
 {
     int? min = -99;
     int? max = 1;
     KeyRange<int> actual = KeyValueExpressionEvaluator<int, string>.GetKeyRange(x => min < x.Key && x.Key < max + 8);
     KeyRange<int> expected = new KeyRange<int>(Key<int>.CreateKey(-99, false), Key<int>.CreateKey(9, false));
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:KeyValueExpressionEvaluatorTests.cs

示例7: ConstantFoldingHelper

 /// <summary>
 /// Common test for constant folding tests.
 /// </summary>
 /// <param name="expression">
 /// An expression which should come out to x.Key LE 32
 /// </param>
 private static void ConstantFoldingHelper(Expression<Predicate<KeyValuePair<int, long>>> expression)
 {
     KeyRange<int> actual = KeyValueExpressionEvaluator<int, long>.GetKeyRange(expression);
     KeyRange<int> expected = new KeyRange<int>(null, Key<int>.CreateKey(32, true));
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:12,代码来源:KeyValueExpressionEvaluatorTests.cs

示例8: TestSample12

 public void TestSample12()
 {
     Expression<Predicate<int>> expression = x => x >= -1 && x < 101;
     KeyRange<int> actual = PredicateExpressionEvaluator<int>.GetKeyRange(expression.Body, null);
     KeyRange<int> expected = new KeyRange<int>(Key<int>.CreateKey(-1, true), Key<int>.CreateKey(101, false));
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:7,代码来源:KeyValueExpressionEvaluatorTests.cs

示例9: TestNullableTimeSpanExpression

 public void TestNullableTimeSpanExpression()
 {
     TimeSpan? min = TimeSpan.MinValue;
     Func<TimeSpan?> fmax = () => TimeSpan.MaxValue;
     var expected = new KeyRange<TimeSpan>(Key<TimeSpan>.CreateKey(TimeSpan.MinValue, true), Key<TimeSpan>.CreateKey(TimeSpan.MaxValue, false));
     var actual = KeyValueExpressionEvaluator<TimeSpan, string>.GetKeyRange(x => min <= x.Key && x.Key < fmax());
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:KeyValueExpressionEvaluatorTests.cs

示例10: TestNullDateTimeExpression

 public void TestNullDateTimeExpression()
 {
     DateTime? min = null;
     Func<DateTime?> fmax = () => DateTime.MaxValue;
     var expected = new KeyRange<DateTime>(null, Key<DateTime>.CreateKey(DateTime.MaxValue, false));
     var actual = KeyValueExpressionEvaluator<DateTime, string>.GetKeyRange(x => min <= x.Key && x.Key < fmax());
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:KeyValueExpressionEvaluatorTests.cs

示例11: TestNullableDoubleExpression

 public void TestNullableDoubleExpression()
 {
     double? min = 1;
     Func<double?> fmax = () => 8;
     var expected = new KeyRange<double>(Key<double>.CreateKey(1, true), Key<double>.CreateKey(8, false));
     var actual = KeyValueExpressionEvaluator<double, string>.GetKeyRange(x => min <= x.Key && x.Key < fmax());
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:KeyValueExpressionEvaluatorTests.cs

示例12: TestIntNullableLongExpression

 public void TestIntNullableLongExpression()
 {
     long? min = 1;
     Func<long?> fmax = () => 8;
     var expected = new KeyRange<int>(Key<int>.CreateKey(1, true), Key<int>.CreateKey(8, false));
     var actual = KeyValueExpressionEvaluator<int, string>.GetKeyRange(x => min <= x.Key && x.Key < fmax());
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:KeyValueExpressionEvaluatorTests.cs

示例13: TestNullIntExpression

 public void TestNullIntExpression()
 {
     int? min = 1;
     Func<int?> fmax = () => null;
     var expected = new KeyRange<int>(Key<int>.CreateKey(1, true), null);
     var actual = KeyValueExpressionEvaluator<int, string>.GetKeyRange(x => min <= x.Key && x.Key < fmax());
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:KeyValueExpressionEvaluatorTests.cs

示例14: TestNullableUShortExpression

 public void TestNullableUShortExpression()
 {
     ushort? min = 1;
     Func<ushort?> fmax = () => 8;
     var expected = new KeyRange<ushort>(Key<ushort>.CreateKey(1, true), Key<ushort>.CreateKey(8, false));
     var actual = KeyValueExpressionEvaluator<ushort, string>.GetKeyRange(x => min <= x.Key && x.Key < fmax());
     Assert.AreEqual(expected, actual, "ushort to int? promotion not supported");
 }
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:KeyValueExpressionEvaluatorTests.cs

示例15: TestSample10

 public void TestSample10()
 {
     // Regression test for:
     //   Assert.IsTrue failed.
     //   Error at entry 21. Not enough entries in actual.
     //   First missing entry is [ibh, ibh]
     //    expression = x => (x.Key.StartsWith("i") || (x.Key.Equals("ibg") || ("f" = x.Key)))
     KeyRange<string> actual =
         KeyValueExpressionEvaluator<string, string>.GetKeyRange(
             x => (x.Key.StartsWith("i") || (x.Key.Equals("ibg") || ("f" == x.Key))));
     KeyRange<string> expected = new KeyRange<string>(Key<string>.CreateKey("f", true), Key<string>.CreatePrefixKey("i"));
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:13,代码来源:KeyValueExpressionEvaluatorTests.cs


注:本文中的KeyRange类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。