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


C# BsonClassMap.MapMember方法代码示例

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


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

示例1: TestConvention

 public void TestConvention(BsonType value)
 {
     var convention = new EnumRepresentationConvention(value);
     var classMap = new BsonClassMap<TestClass>();
     var nonEnumMemberMap = classMap.MapMember(x => x.NonEnum);
     var defaultEnumMemberMap = classMap.MapMember(x => x.DefaultEnum);
     var changedEnumMemberMap = classMap.MapMember(x => x.ChangedRepresentationEnum);
     convention.Apply(nonEnumMemberMap);
     convention.Apply(changedEnumMemberMap);
     Assert.AreEqual(value, ((IRepresentationConfigurable)(changedEnumMemberMap.GetSerializer())).Representation);
 }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:11,代码来源:EnumRepresentationConventionTests.cs

示例2: 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

示例3: TestConvention

 public void TestConvention(BsonType value)
 {
     var convention = new EnumRepresentationConvention(value);
     var classMap = new BsonClassMap<TestClass>();
     var nonEnumMemberMap = classMap.MapMember(x => x.NonEnum);
     var defaultEnumMemberMap = classMap.MapMember(x => x.DefaultEnum);
     var changedEnumMemberMap = classMap.MapMember(x => x.ChangedRepresentationEnum);
     convention.Apply(nonEnumMemberMap);
     convention.Apply(changedEnumMemberMap);
     Assert.IsNull(nonEnumMemberMap.SerializationOptions);
     Assert.IsNull(defaultEnumMemberMap.SerializationOptions);
     Assert.AreEqual(value, ((RepresentationSerializationOptions)changedEnumMemberMap.SerializationOptions).Representation);
 }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:13,代码来源:EnumRepresentationConventionTests.cs

示例4: TestShouldDowncaseOnlyFirstCharByDefault

        public void TestShouldDowncaseOnlyFirstCharByDefault()
        {
            var convention = new CamelCaseElementNameConvention();
            var classMap = new BsonClassMap<TestClass>();
            var firstName = classMap.MapMember(x => x.FirstName);
            var age = classMap.MapMember(x => x.Age);
            var allCaps = classMap.MapMember(x => x.ALLCAPS);

            convention.Apply(firstName);
            convention.Apply(age);
            convention.Apply(allCaps);

            Assert.AreEqual("firstName", firstName.ElementName);
            Assert.AreEqual("age", age.ElementName);
            Assert.AreEqual("aLLCAPS", allCaps.ElementName);
        }
开发者ID:vorou,项目名称:mongo-csharp-driver,代码行数:16,代码来源:CamelCaseElementNameConventionsTests.cs

示例5: TestConventionOverride

 public void TestConventionOverride()
 {
     var int64Convention = new EnumRepresentationConvention(BsonType.Int64);
     var strConvention = new EnumRepresentationConvention(BsonType.String);
     var classMap = new BsonClassMap<TestClass>();
     var memberMap = classMap.MapMember(x => x.ChangedRepresentationEnum);
     int64Convention.Apply(memberMap);
     strConvention.Apply(memberMap);
     Assert.AreEqual(BsonType.String, ((IRepresentationConfigurable)(memberMap.GetSerializer())).Representation);
 }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:10,代码来源:EnumRepresentationConventionTests.cs

示例6: TestApply

        public void TestApply(bool value)
        {
            var subject = new IgnoreIfDefaultConvention(value);
            var classMap = new BsonClassMap<TestClass>();
            var memberMap = classMap.MapMember(x => x.Id);

            subject.Apply(memberMap);

            Assert.AreEqual(value, memberMap.IgnoreIfDefault);
        }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:10,代码来源:IgnoreIfDefaultConventionsTests.cs

示例7: TestCamelCaseElementNameConvention

        public void TestCamelCaseElementNameConvention()
        {
            var convention = new CamelCaseElementNameConvention();
            var classMap = new BsonClassMap<TestClass>();
            var firstName = classMap.MapMember(x => x.FirstName);
            var age = classMap.MapMember(x => x.Age);
            var _dumbName = classMap.MapMember(x => x._DumbName);
            var lowerCase = classMap.MapMember(x => x.lowerCase);

            convention.Apply(firstName);
            convention.Apply(age);
            convention.Apply(_dumbName);
            convention.Apply(lowerCase);

            Assert.AreEqual("firstName", firstName.ElementName);
            Assert.AreEqual("age", age.ElementName);
            Assert.AreEqual("_DumbName", _dumbName.ElementName);
            Assert.AreEqual("lowerCase", lowerCase.ElementName);
        }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:19,代码来源:CamelCaseElementNameConventionsTests.cs

示例8: TestShouldHandleNameStartingWithNonLetter

        public void TestShouldHandleNameStartingWithNonLetter()
        {
            var convention = new CamelCaseElementNameConvention();
            var classMap = new BsonClassMap<TestClass>();
            var _dumbName = classMap.MapMember(x => x._dumbName);

            convention.Apply(_dumbName);

            Assert.AreEqual("_dumbName", _dumbName.ElementName);
        }
开发者ID:vorou,项目名称:mongo-csharp-driver,代码行数:10,代码来源:CamelCaseElementNameConventionsTests.cs

示例9: TestShouldNotChangeIfAlreadyCamelCased

        public void TestShouldNotChangeIfAlreadyCamelCased()
        {
            var convention = new CamelCaseElementNameConvention();
            var classMap = new BsonClassMap<TestClass>();
            var lowerCase = classMap.MapMember(x => x.camelCasedName);

            convention.Apply(lowerCase);

            Assert.AreEqual("camelCasedName", lowerCase.ElementName);
        }
开发者ID:vorou,项目名称:mongo-csharp-driver,代码行数:10,代码来源:CamelCaseElementNameConventionsTests.cs

示例10: TestShouldDowncaseCertainNumberOfChars

        public void TestShouldDowncaseCertainNumberOfChars(int charsToDowncase, string expected)
        {
            var convention = new CamelCaseElementNameConvention(charsToDowncase);
            var classMap = new BsonClassMap<TestClass>();
            var ioStream = classMap.MapMember(x => x.ALLCAPS);

            convention.Apply(ioStream);

            Assert.AreEqual(expected, ioStream.ElementName);
        }
开发者ID:vorou,项目名称:mongo-csharp-driver,代码行数:10,代码来源:CamelCaseElementNameConventionsTests.cs

示例11: Test

        public void Test()
        {
            var convention = new DelegateMemberMapConvention("test", m => m.SetElementName("blah"));

            Assert.AreEqual("test", convention.Name);

            var classMap = new BsonClassMap<TestClass>();
            var member = classMap.MapMember(x => x.FirstName);

            convention.Apply(member);

            Assert.AreEqual("blah", member.ElementName);
        }
开发者ID:CloudMetal,项目名称:mongo-csharp-driver,代码行数:13,代码来源:DelegateMemberMapConventionTests.cs

示例12: MapField

        // private methods
        private void MapField(BsonClassMap classMap, FieldInfo fieldInfo)
        {
            if (fieldInfo.IsInitOnly || fieldInfo.IsLiteral)
            {
                // we can't write
                return;
            }

            classMap.MapMember(fieldInfo);
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:11,代码来源:ReadWriteMemberFinderConvention.cs

示例13: MapProperty

        private void MapProperty(BsonClassMap classMap, PropertyInfo propertyInfo)
        {
            if (!propertyInfo.CanRead || (!propertyInfo.CanWrite && classMap.ClassType.Namespace != null))
            {
                // we can't write or it is anonymous...
                return;
            }

            // skip indexers
            if (propertyInfo.GetIndexParameters().Length != 0)
            {
                return;
            }

            // skip overridden properties (they are already included by the base class)
            var getMethodInfo = propertyInfo.GetGetMethod(true);
            if (getMethodInfo.IsVirtual && getMethodInfo.GetBaseDefinition().DeclaringType != classMap.ClassType)
            {
                return;
            }

            classMap.MapMember(propertyInfo);
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:23,代码来源:ReadWriteMemberFinderConvention.cs

示例14: OptInMembersWithBsonMemberMapModifierAttribute

            private void OptInMembersWithBsonMemberMapModifierAttribute(BsonClassMap classMap)
            {
                // let other fields opt-in if they have any IBsonMemberMapAttribute attributes
                foreach (var fieldInfo in classMap.ClassType.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
                {
                    var hasAttribute = fieldInfo.GetCustomAttributes(typeof(IBsonMemberMapAttribute), false).Any();
                    if (hasAttribute)
                    {
                        classMap.MapMember(fieldInfo);
                    }
                }

                // let other properties opt-in if they have any IBsonMemberMapAttribute attributes
                foreach (var propertyInfo in classMap.ClassType.GetProperties(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly))
                {
                    var hasAttribute = propertyInfo.GetCustomAttributes(typeof(IBsonMemberMapAttribute), false).Any();
                    if (hasAttribute)
                    {
                        classMap.MapMember(propertyInfo);
                    }
                }
            }
开发者ID:GGsus,项目名称:mongo-csharp-driver,代码行数:22,代码来源:AttributeConventionPack.cs

示例15: Apply

 public void Apply(BsonClassMap classMap)
 {
     var members = _convention.FindMembers(classMap.ClassType);
     foreach (var member in members)
     {
         classMap.MapMember(member);
     }
 }
开发者ID:Khosrow-Azizi,项目名称:MasterExperimentV2,代码行数:8,代码来源:ConventionProfile.cs


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