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


C# BsonInt32类代码示例

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


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

示例1: getValue

 /// <summary>
 /// 使用属性会发生一些MONO上的移植问题
 /// </summary>
 /// <returns></returns>
 public BsonValue getValue()
 {
     BsonValue mValue = null;
     switch (cmbDataType.SelectedIndex)
     {
         case 0:
             mValue = new BsonString(txtBsonValue.Text);
             break;
         case 1:
             mValue = new BsonInt32(Convert.ToInt32(NumberPick.Value));
             break;
         case 2:
             mValue = new BsonDateTime(dateTimePicker.Value);
             break;
         case 3:
             if (radTrue.Checked)
             {
                 mValue = BsonBoolean.True;
             }
             else
             {
                 mValue = BsonBoolean.False;
             }
             break;
         case 4:
             mValue = mBsonArray;
             break;
         case 5:
             mValue = mBsonDocument;
             break;
     }
     return mValue;
 }
开发者ID:huchao007,项目名称:MagicMongoDBTool,代码行数:37,代码来源:ctlBsonValue.cs

示例2: TestSetDocumentIdBsonValue

 public void TestSetDocumentIdBsonValue()
 {
     var document = new BsonDocument { { "x", "abc" } };
     var id = new BsonInt32(1);
     ((IBsonIdProvider)BsonDocumentSerializer.Instance).SetDocumentId(document, id);
     Assert.IsTrue(document["_id"].IsInt32);
     Assert.AreEqual(1, document["_id"].AsInt32);
 }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:8,代码来源:CSharp446Tests.cs

示例3: CompareTo_BsonDouble_should_return_expected_result

        public void CompareTo_BsonDouble_should_return_expected_result(int int32Value, double otherDoubleValue, int expectedResult)
        {
            var subject = new BsonInt32(int32Value);
            var other = new BsonDouble(otherDoubleValue);

            var result = subject.CompareTo(other);

            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonInt32Tests.cs

示例4: CompareTo_BsonInt32_should_return_expected_result

        public void CompareTo_BsonInt32_should_return_expected_result(long int64Value, int otherInt32Value, int expectedResult)
        {
            var subject = new BsonInt64(int64Value);
            var other = new BsonInt32(otherInt32Value);

            var result = subject.CompareTo(other);

            result.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonInt64Tests.cs

示例5: TestCompareOneAndTwo

 public void TestCompareOneAndTwo()
 {
     var n1 = new BsonInt32(1);
     var n2 = new BsonInt32(2);
     Assert.IsTrue(n1 < n2);
     Assert.IsTrue(n1 <= n2);
     Assert.IsTrue(n1 != n2);
     Assert.IsFalse(n1 == n2);
     Assert.IsFalse(n1 > n2);
     Assert.IsFalse(n1 >= n2);
 }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:11,代码来源:BsonValueCompareToTests.cs

示例6: CompareTo_BsonInt32_should_return_expected_result

        public void CompareTo_BsonInt32_should_return_expected_result(int int32Value, int otherInt32Value, int expectedResult)
        {
            var subject = new BsonInt32(int32Value);
            var other = new BsonInt32(otherInt32Value);

            var result1 = subject.CompareTo((BsonInt32)other);
            var result2 = subject.CompareTo((BsonValue)other);

            result1.Should().Be(expectedResult);
            result2.Should().Be(expectedResult);
        }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:11,代码来源:BsonInt32Tests.cs

示例7: TestCompareDifferentTypeOnes

 public void TestCompareDifferentTypeOnes()
 {
     var n1 = new BsonInt32(1);
     var n2 = new BsonInt64(1);
     var n3 = new BsonDouble(1.0);
     Assert.IsTrue(n1 == n2);
     Assert.IsTrue(n1 == n3);
     Assert.IsTrue(n2 == n1);
     Assert.IsTrue(n2 == n3);
     Assert.IsTrue(n3 == n1);
     Assert.IsTrue(n3 == n2);
 }
开发者ID:kenegozi,项目名称:mongo-csharp-driver,代码行数:12,代码来源:BsonValueCompareToTests.cs

示例8: TestCompareDifferentTypeOnes

        public void TestCompareDifferentTypeOnes()
        {
            var n1 = new BsonInt32(1);
            var n2 = new BsonInt64(1);
            var n3 = new BsonDouble(1.0);
            Assert.IsTrue(n1 == n2);
            Assert.IsTrue(n1 == n3);
            Assert.IsTrue(n2 == n1);
            Assert.IsTrue(n2 == n3);
            Assert.IsTrue(n3 == n1);
            Assert.IsTrue(n3 == n2);

            var v1 = (BsonValue)new BsonInt32(1);
            var v2 = (BsonValue)new BsonInt64(1);
            var v3 = (BsonValue)new BsonDouble(1.0);
            Assert.IsTrue(v1 == v2);
            Assert.IsTrue(v1 == v3);
            Assert.IsTrue(v2 == v1);
            Assert.IsTrue(v2 == v3);
            Assert.IsTrue(v3 == v1);
            Assert.IsTrue(v3 == v2);
        }
开发者ID:kamaradclimber,项目名称:mongo-csharp-driver,代码行数:22,代码来源:BsonValueCompareToTests.cs

示例9: TestBsonInt32

 public void TestBsonInt32()
 {
     var value = new BsonInt32(1);
     Assert.AreSame(value, ((IConvertible)value).ToType(typeof(object), null));
     Assert.AreEqual(true, Convert.ToBoolean(value));
     Assert.AreEqual(1, Convert.ToByte(value));
     Assert.AreEqual(1, Convert.ToChar(value));
     Assert.Throws<InvalidCastException>(() => Convert.ToDateTime(value));
     Assert.AreEqual(1m, Convert.ToDecimal(value));
     Assert.AreEqual(1.0, Convert.ToDouble(value));
     Assert.AreEqual(1, Convert.ToInt16(value));
     Assert.AreEqual(1, Convert.ToInt32(value));
     Assert.AreEqual(1, Convert.ToInt64(value));
     Assert.AreEqual(1, Convert.ToSByte(value));
     Assert.AreEqual(1.0F, Convert.ToSingle(value));
     Assert.AreEqual("1", Convert.ToString(value));
     Assert.AreEqual(1, Convert.ToUInt16(value));
     Assert.AreEqual(1, Convert.ToUInt32(value));
     Assert.AreEqual(1, Convert.ToUInt64(value));
 }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:20,代码来源:BsonValueIConvertibleTests.cs

示例10: GetValue

 /// <summary>
 ///     使用属性会发生一些MONO上的移植问题
 /// </summary>
 /// <returns></returns>
 public BsonValue GetValue(BsonValueEx.BasicType DataType)
 {
     BsonValue mValue = null;
     switch (DataType)
     {
         case BsonValueEx.BasicType.BsonString:
             mValue = new BsonString(txtBsonValue.Text);
             break;
         case BsonValueEx.BasicType.BsonInt32:
             mValue = new BsonInt32(Convert.ToInt32(NumberPick.Value));
             break;
         case BsonValueEx.BasicType.BsonInt64:
             mValue = new BsonInt64(Convert.ToInt64(NumberPick.Value));
             break;
         case BsonValueEx.BasicType.BsonDecimal128:
             mValue = new BsonDecimal128(Convert.ToDecimal(NumberPick.Value));
             break;
         case BsonValueEx.BasicType.BsonDouble:
             mValue = new BsonDouble(Convert.ToDouble(txtBsonValue.Text));
             break;
         case BsonValueEx.BasicType.BsonDateTime:
             mValue = new BsonDateTime(dateTimePicker.Value);
             break;
         case BsonValueEx.BasicType.BsonBoolean:
             mValue = radTrue.Checked ? BsonBoolean.True : BsonBoolean.False;
             break;
         case BsonValueEx.BasicType.BsonArray:
         case BsonValueEx.BasicType.BsonLegacyPoint:
             mValue = _mBsonArray;
             break;
         case BsonValueEx.BasicType.BsonGeoJSON:
         case BsonValueEx.BasicType.BsonDocument:
             mValue = _mBsonDocument;
             break;
         case BsonValueEx.BasicType.BsonMaxKey:
             mValue = BsonMaxKey.Value;
             break;
         case BsonValueEx.BasicType.BsonMinKey:
             mValue = BsonMinKey.Value;
             break;
         case BsonValueEx.BasicType.BsonBinary:
             mValue = new BsonBinaryData(Encoding.Default.GetBytes(txtBsonValue.Text));
             break;
     }
     return mValue;
 }
开发者ID:magicdict,项目名称:MongoCola,代码行数:50,代码来源:ctlBsonValue.cs

示例11: EquivalentToIntegerNotMatch

 public void EquivalentToIntegerNotMatch()
 {
     BsonValue val1 = new BsonInt32(42);
     BsonValue val2 = new BsonInt32(-42);
     Assert.IsFalse(val1.EquivalentTo(val2));
 }
开发者ID:cgavieta,项目名称:WORKPAC2016-poc,代码行数:6,代码来源:BsonValueExtensionsTests.cs

示例12: TestIsNumeric

 public void TestIsNumeric()
 {
     BsonValue d128 = new BsonDecimal128(1.0M);
     BsonValue d = new BsonDouble(1.0);
     BsonValue i32 = new BsonInt32(1);
     BsonValue i64 = new BsonInt64(1L);
     BsonValue s = new BsonString("");
     Assert.True(d128.IsNumeric);
     Assert.True(d.IsNumeric);
     Assert.True(i32.IsNumeric);
     Assert.True(i64.IsNumeric);
     Assert.False(s.IsDecimal128);
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:13,代码来源:BsonValueTests.cs

示例13: GetBsonValue

 /// <summary>
 ///     还原BsonValue
 /// </summary>
 /// <returns></returns>
 public BsonValue GetBsonValue()
 {
     BsonValue value = new BsonString(string.Empty);
     switch (MBsonType)
     {
         case "BsonString":
             value = new BsonString(MBsonString);
             break;
         case "BsonInt32":
             value = new BsonInt32(MBsonInt32);
             break;
         case "BsonDateTime":
             value = new BsonDateTime(MBsonDateTime);
             break;
         case "BsonBoolean":
             value = MBsonBoolean ? BsonBoolean.True : BsonBoolean.False;
             break;
         case "BsonDouble":
             value = new BsonDouble(MBsonDouble);
             break;
     }
     return value;
 }
开发者ID:1287516153,项目名称:MongoCola,代码行数:27,代码来源:BsonValueEx.cs

示例14: DiffTwoDifferentBsonTypes

        public void DiffTwoDifferentBsonTypes()
        {
            // Arrange
            var a = new BsonInt32(100);
            var b = new BsonInt64(100);
            var expected = new BsonDocument("types differ", new BsonDocument {{"a", "Int32"}, {"b", "Int64"}});

            // Act
            var doc = a.Diff(b);

            // Assert
            Assert.That(doc, Is.EqualTo(expected));
        }
开发者ID:jvanzella,项目名称:ch-bson,代码行数:13,代码来源:Diff.cs

示例15: TestClass

 public TestClass(
     BsonInt32 value
 )
 {
     this.B = value;
     this.V = value;
 }
开发者ID:vshlos,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonValueSerializerTests.cs


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