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


C# BsonClassMap.GetMemberMap方法代码示例

本文整理汇总了C#中BsonClassMap.GetMemberMap方法的典型用法代码示例。如果您正苦于以下问题:C# BsonClassMap.GetMemberMap方法的具体用法?C# BsonClassMap.GetMemberMap怎么用?C# BsonClassMap.GetMemberMap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BsonClassMap的用法示例。


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

示例1: TestCamelCaseElementNameConvention

 public void TestCamelCaseElementNameConvention()
 {
     var convention = new CamelCaseElementNameConvention();
     var classMap = new BsonClassMap<TestClass>();
     convention.Apply(classMap.MapMember(x => x.FirstName));
     convention.Apply(classMap.MapMember(x => x.Age));
     convention.Apply(classMap.MapMember(x => x._DumbName));
     convention.Apply(classMap.MapMember(x => x.lowerCase));
     Assert.AreEqual("firstName", classMap.GetMemberMap(x => x.FirstName).ElementName);
     Assert.AreEqual("age", classMap.GetMemberMap(x => x.Age).ElementName);
     Assert.AreEqual("_DumbName", classMap.GetMemberMap(x => x._DumbName).ElementName);
     Assert.AreEqual("lowerCase", classMap.GetMemberMap(x => x.lowerCase).ElementName);
 }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:13,代码来源:ElementNameConventionsTests.cs

示例2: TestMapField

 public void TestMapField() {
     var classMap = new BsonClassMap<C>(cm => cm.MapField("f"));
     var memberMap = classMap.GetMemberMap("f");
     Assert.IsNotNull(memberMap);
     Assert.AreEqual("f", memberMap.ElementName);
     Assert.AreEqual("f", memberMap.MemberName);
 }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonClassMapTests.cs

示例3: TestIsReadOnlyPropertyOfAField

        public void TestIsReadOnlyPropertyOfAField()
        {
            var classMap = new BsonClassMap<TestClass>(cm => cm.AutoMap());
            var memberMap = classMap.GetMemberMap("Field");

            Assert.IsFalse(memberMap.IsReadOnly);
        }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:7,代码来源:BsonMemberMapTests.cs

示例4: TestSettingAProperty

        public void TestSettingAProperty() {
            var instance = new TestClass();
            var classMap = new BsonClassMap<TestClass>(cm => cm.AutoMap());
            var memberMap = classMap.GetMemberMap("Property");

            memberMap.Setter(instance, 42);

            Assert.AreEqual(42, instance.Property);
        }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonMemberMapTests.cs

示例5: TestGettingAProperty

        public void TestGettingAProperty() {
            var instance = new TestClass { Property = 42 };
            var classMap = new BsonClassMap<TestClass>(cm => cm.AutoMap());
            var memberMap = classMap.GetMemberMap("Property");

            int value = (int)memberMap.Getter(instance);

            Assert.AreEqual(42, value);
        }
开发者ID:redforks,项目名称:mongo-csharp-driver,代码行数:9,代码来源:BsonMemberMapTests.cs

示例6: TestOptsInMembers

        public void TestOptsInMembers()
        {
            var convention = AttributeConventionPack.Instance;
            var classMap = new BsonClassMap<TestClass>();
            new ConventionRunner(convention).Apply(classMap);

            Assert.AreEqual(1, classMap.DeclaredMemberMaps.Count());
            Assert.AreEqual("fn", classMap.GetMemberMap("_firstName").ElementName);
        }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:9,代码来源:AttributeConventionPackTests.cs

示例7: TestConventionProfileStillUsesDefaults

        public void TestConventionProfileStillUsesDefaults()
        {
            var classMap = new BsonClassMap<A>();
            classMap.AutoMap();

            var memberMap = classMap.GetMemberMap(x => x.S);

            Assert.IsNotNull(memberMap);
        }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:9,代码来源:CSharp728Tests.cs

示例8: TestGettingAField

        public void TestGettingAField()
        {
            var instance = new TestClass { Field = 42 };
            var classMap = new BsonClassMap<TestClass>(cm => cm.AutoMap());
            var memberMap = classMap.GetMemberMap("Field");

            int value = (int)memberMap.Getter(instance);

            Assert.Equal(42, value);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:10,代码来源:BsonMemberMapTests.cs

示例9: TestMappingUsesMemberSerializationOptionsConventionDoesNotMatchWrongProperty

        public void TestMappingUsesMemberSerializationOptionsConventionDoesNotMatchWrongProperty()
        {
            var pack = new ConventionPack();
            pack.Add(new MemberSerializationOptionsConvention(typeof(ObjectId), new RepresentationSerializationOptions(BsonType.JavaScriptWithScope)));
            ConventionRegistry.Register("test", pack, t => t == typeof(A));

            var classMap = new BsonClassMap<A>(cm => cm.AutoMap());

            var options = classMap.GetMemberMap("NoMatch").SerializationOptions;
            Assert.IsNull(options);
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:11,代码来源:BsonClassMapAutoMappingTests.cs

示例10: TestMappingUsesMemberDefaultValueConventionDoesNotMatchWrongProperty

        public void TestMappingUsesMemberDefaultValueConventionDoesNotMatchWrongProperty()
        {
            var pack = new ConventionPack();
            pack.Add(new MemberDefaultValueConvention(typeof(int), 1));
            ConventionRegistry.Register("test", pack, t => t == typeof(A));

            var classMap = new BsonClassMap<A>(cm => cm.AutoMap());

            var defaultValue = classMap.GetMemberMap("NoMatch").DefaultValue;
            Assert.Equal(0L, defaultValue);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:11,代码来源:MemberDefaultValueConventionTests.cs

示例11: TestMappingUsesMemberDefaultValueConvention

        public void TestMappingUsesMemberDefaultValueConvention()
        {
            var pack = new ConventionPack();
            pack.Add(new MemberDefaultValueConvention(typeof(int), 1));
            ConventionRegistry.Register("test", pack, t => t == typeof(A));

            var classMap = new BsonClassMap<A>(cm => cm.AutoMap());

            var defaultValue = classMap.GetMemberMap("Match").DefaultValue;
            Assert.IsInstanceOf<int>(defaultValue);
            Assert.AreEqual(1, defaultValue);
        }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:12,代码来源:MemberDefaultValueConventionTests.cs

示例12: TestMappingUsesMemberSerializationOptionsConventionDoesNotOverrideAttribute

        public void TestMappingUsesMemberSerializationOptionsConventionDoesNotOverrideAttribute()
        {
            var pack = new ConventionPack();
            pack.Add(new MemberSerializationOptionsConvention(typeof(ObjectId), new RepresentationSerializationOptions(BsonType.JavaScriptWithScope)));
            ConventionRegistry.Register("test", pack, t => t == typeof(B));

            var classMap = new BsonClassMap<B>(cm => cm.AutoMap());

            var options = classMap.GetMemberMap("Match").SerializationOptions;
            Assert.IsInstanceOf<RepresentationSerializationOptions>(options);
            Assert.AreEqual(BsonType.ObjectId, ((RepresentationSerializationOptions)options).Representation);
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:12,代码来源:BsonClassMapAutoMappingTests.cs

示例13: TestMappingUsesMemberDefaultValueConventionDoesNotOverrideAttribute

        public void TestMappingUsesMemberDefaultValueConventionDoesNotOverrideAttribute()
        {
            var pack = new ConventionPack();
            pack.Add(new MemberDefaultValueConvention(typeof(int), 1));
            ConventionRegistry.Register("test", pack, t => t == typeof(B));

            var classMap = new BsonClassMap<B>(cm => cm.AutoMap());

            var defaultValue = classMap.GetMemberMap("Match").DefaultValue;
            Assert.IsType<int>(defaultValue);
            Assert.Equal(2, defaultValue);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:12,代码来源:MemberDefaultValueConventionTests.cs

示例14: TestConventionProfileStillUsesDefaults

        public void TestConventionProfileStillUsesDefaults()
        {
#pragma warning disable 618 
            var conventions = new ConventionProfile();
            conventions.SetElementNameConvention(new CamelCaseElementNameConvention());
            BsonClassMap.RegisterConventions(conventions, t => t == typeof(A));
#pragma warning restore 618
            var classMap = new BsonClassMap<A>();
            classMap.AutoMap();

            var memberMap = classMap.GetMemberMap(x => x.S);

            Assert.IsNotNull(memberMap);
        }
开发者ID:einaregilsson,项目名称:mongo-csharp-driver,代码行数:14,代码来源:CSharp728Tests.cs

示例15: TestSetElementNameThrowsWhenElementNameIsNull

 public void TestSetElementNameThrowsWhenElementNameIsNull()
 {
     var classMap = new BsonClassMap<TestClass>(cm => cm.AutoMap());
     var memberMap = classMap.GetMemberMap("Property");
     Assert.Throws<ArgumentNullException>(() => { memberMap.SetElementName(null); });
 }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:6,代码来源:BsonMemberMapTests.cs


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