• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# KeyRange类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: TestSample11

 public void TestSample11()
 {
     // Regression test for:
     //   Assert.IsTrue failed.
     //   Error at entry 0. Not enough entries in actual.
     //   First missing entry is [ggi, ggi] 
     //    expression = x => ((Compare("ggi", x.Key) <= 0) && (x.Key.Equals("fag") || x.Key.StartsWith("g")))
     KeyRange<string> actual =
         KeyValueExpressionEvaluator<string, string>.GetKeyRange(
             x => ((String.Compare("ggi", x.Key) <= 0) && (x.Key.Equals("fag") || x.Key.StartsWith("g"))));
     KeyRange<string> expected = new KeyRange<string>(
         Key<string>.CreateKey("ggi", true),
         Key<string>.CreatePrefixKey("g"));
     Assert.AreEqual(expected, actual);
     Assert.IsFalse(actual.IsEmpty);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:16,代码来源:KeyValueExpressionEvaluatorTests.cs


示例17: TestNullableGuidExpression

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


示例18: TestSample13

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


示例19: TestStringStartsWithIntersection

 public void TestStringStartsWithIntersection()
 {
     string s = "baz";
     KeyRange<string> actual = KeyValueExpressionEvaluator<string, string>.GetKeyRange(x => x.Key.StartsWith(s) && x.Key.CompareTo("z") < 0);
     var expected = new KeyRange<string>(Key<string>.CreateKey(s, true), Key<string>.CreatePrefixKey(s));
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:7,代码来源:KeyValueExpressionEvaluatorTests.cs


示例20: VerifyStaticMethodCallAccessIsOptimized

 public void VerifyStaticMethodCallAccessIsOptimized()
 {
     var expected = new KeyRange<int>(null, Key<int>.CreateKey(8, false));
     var actual =
         KeyValueExpressionEvaluator<int, string>.GetKeyRange(
             x => x.Key < Math.Min(8, 9));
     Assert.AreEqual(expected, actual);
 }
开发者ID:925coder,项目名称:ravendb,代码行数:8,代码来源:KeyValueExpressionEvaluatorTests.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# KeyType类代码示例发布时间:2022-05-24
下一篇:
C# KeyPressEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap