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

C# BsonClassMap类代码示例

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

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



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

示例1: TestDoesNotSetWhenNoIdExists

        public void TestDoesNotSetWhenNoIdExists()
        {
            var classMap = new BsonClassMap<TestClass>(cm =>
            { });

            _subject.PostProcess(classMap);
        }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:7,代码来源:StringObjectIdGeneratorConventionsTests.cs


示例2: TestMapIdField

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


示例3: TestDoesNotSetWhenNoIdExists

        public void TestDoesNotSetWhenNoIdExists()
        {
            var classMap = new BsonClassMap<TestClass>(cm =>
            { });

            Assert.DoesNotThrow(() => _subject.PostProcess(classMap));
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:7,代码来源:StringObjectIdGeneratorConventionsTests.cs


示例4: Apply

 public void Apply(BsonClassMap classMap)
 {
     if (classMap.ClassType.IsClass && typeof(ISaga).IsAssignableFrom(classMap.ClassType))
     {
         classMap.MapIdProperty(nameof(ISaga.CorrelationId));
     }
 }
开发者ID:phatboyg,项目名称:MassTransit,代码行数:7,代码来源:SagaConvention.cs


示例5: BsonMigrationSerializer

 public BsonMigrationSerializer(IBsonSerializer versionSerializer, IVersionDetectionStrategy versionDetectionStrategy, BsonClassMap classMap)
     : base(classMap)
 {
     _versionSerializer = versionSerializer;
     _versionDetectionStrategy = versionDetectionStrategy;
     _migrations = ExtractMigrations(classMap.ClassType);
 }
开发者ID:RasmusTG,项目名称:mongo-csharp-migrations,代码行数:7,代码来源:BsonMigrationSerializer.cs


示例6: TestSave

        public void TestSave()
        {
            var server = Configuration.TestServer;
            var database = Configuration.TestDatabase;
            var collection = Configuration.GetTestCollection<Foo>();

            var conventions = new ConventionPack();
            conventions.Add(new NamedIdMemberConvention(new[] { "FooId" }));
            ConventionRegistry.Register("test", conventions, t => t == typeof(Foo));

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

            collection.RemoveAll();
            for (int i = 0; i < 10; i++)
            {
                var foo = new Foo
                {
                    FooId = ObjectId.Empty,
                    Name = string.Format("Foo-{0}", i),
                    Summary = string.Format("Summary for Foo-{0}", i)
                };
                collection.Save(foo);
                var count = collection.Count();
                Assert.AreEqual(i + 1, count);
            }
        }
开发者ID:annikulin,项目名称:code-classifier,代码行数:26,代码来源:CSharp77Tests.cs


示例7: ContentSerializer

		public ContentSerializer(Type type, MongoDatabaseProvider database, IProxyFactory proxies)
		{
			this.database = database;
			classMap = BsonClassMap.LookupClassMap(type);
			serializer = new BsonClassMapSerializer(classMap);
			this.proxies = proxies;
		}
开发者ID:meixger,项目名称:n2cms,代码行数:7,代码来源:ContentSerializer.cs


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


示例9: TestNamedIdMemberConventionWithTestClassB

 public void TestNamedIdMemberConventionWithTestClassB()
 {
     var convention = new NamedIdMemberConvention("Id", "id", "_id");
     var classMap = new BsonClassMap<TestClassB>();
     convention.Apply(classMap);
     Assert.Null(classMap.IdMemberMap);
 }
开发者ID:RavenZZ,项目名称:MDRelation,代码行数:7,代码来源:IdMemberConventionsTests.cs


示例10: Apply

        // public methods
        /// <summary>
        /// Applies a modification to the class map.
        /// </summary>
        /// <param name="classMap">The class map.</param>
        public void Apply(BsonClassMap classMap)
        {
            //使用插件机制处理序列化成员 james.wei 2015-05-26。
            foreach (var convention in _conventions.OfType<IClassMapConvention>())
            {
                convention.Apply(classMap);
            }

            foreach (var convention in _conventions.OfType<IMemberMapConvention>())
            {
                foreach (var memberMap in classMap.DeclaredMemberMaps)
                {
                    convention.Apply(memberMap);
                }
            }

            foreach (var convention in _conventions.OfType<ICreatorMapConvention>())
            {
                foreach (var creatorMap in classMap.CreatorMaps)
                {
                    convention.Apply(creatorMap);
                }
            }

            foreach (var convention in _conventions.OfType<IPostProcessingConvention>())
            {
                convention.PostProcess(classMap);
            }
        }
开发者ID:huoxudong125,项目名称:SequoiaDB.Charp,代码行数:34,代码来源:ConventionRunner.cs


示例11: PostProcess

 /// <summary>
 /// Post process the class map.
 /// </summary>
 /// <param name="classMap">The class map to be processed.</param>
 public void PostProcess(BsonClassMap classMap)
 {
     if (typeof(IEntity).IsAssignableFrom(classMap.ClassType) && classMap.IdMemberMap != null)
     {
         classMap.IdMemberMap.SetIdGenerator(new GuidGenerator());
     }
 }
开发者ID:heianxing,项目名称:ByteartRetail,代码行数:11,代码来源:GuidIDGeneratorConvention.cs


示例12: MongoTest

 static MongoTest()
 {
     BsonSerializer.RegisterIdGenerator(typeof(string), StringObjectIdGenerator.Instance);
     var map = new BsonClassMap<Person>();
     map.AutoMap();
     BsonClassMap.RegisterClassMap(map);
 }
开发者ID:pvasek,项目名称:RavenVsMongo,代码行数:7,代码来源:MongoTest.cs


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


示例14: BsonMemberMap

 // constructors
 /// <summary>
 /// Initializes a new instance of the BsonMemberMap class.
 /// </summary>
 /// <param name="classMap">The class map this member map belongs to.</param>
 /// <param name="memberInfo">The member info.</param>
 public BsonMemberMap(BsonClassMap classMap, MemberInfo memberInfo)
 {
     _classMap = classMap;
     _memberInfo = memberInfo;
     _memberType = BsonClassMap.GetMemberInfoType(memberInfo);
     _defaultValue = GetDefaultValue(_memberType);
 }
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:13,代码来源:BsonMemberMap.cs


示例15: SetUp

        public void SetUp()
        {
            var stopwatch = new Stopwatch();
            _pack = new ConventionPack();
            _pack.AddRange(new IConvention[] 
            {
                new TrackingBeforeConvention(stopwatch) { Name = "1" },
                new TrackingMemberConvention(stopwatch) { Name = "3" },
                new TrackingAfterConvention(stopwatch) { Name = "5" },
                new TrackingMemberConvention(stopwatch) { Name = "4" },
                new TrackingAfterConvention(stopwatch) { Name = "6" },
                new TrackingBeforeConvention(stopwatch) { Name = "2" },
            });
            _subject = new ConventionRunner(_pack);

            var classMap = new BsonClassMap<TestClass>(cm =>
            {
                cm.MapMember(t => t.Prop1);
                cm.MapMember(t => t.Prop2);
            });

            stopwatch.Start();
            _subject.Apply(classMap);
            stopwatch.Stop();
        }
开发者ID:niemyjski,项目名称:mongo-csharp-driver,代码行数:25,代码来源:ConventionRunnerTests.cs


示例16: Apply

 // public methods
 /// <summary>
 /// Applies a modification to the class map.
 /// </summary>
 /// <param name="classMap">The class map.</param>
 public void Apply(BsonClassMap classMap)
 {
     foreach (var type in _knownTypes)
     {
         classMap.AddKnownType(type);
     }
 }
开发者ID:horizon3d,项目名称:SequoiaDB,代码行数:12,代码来源:BsonKnownTypesAttribute.cs


示例17: TestNoDefaultConstructorClassMapConventionWithTestClassA

 public void TestNoDefaultConstructorClassMapConventionWithTestClassA()
 {
     var convention = new ImmutableTypeClassMapConvention();
     var classMap = new BsonClassMap<TestClassA>();
     convention.Apply(classMap);
     Assert.False(classMap.HasCreatorMaps);
 }
开发者ID:mfidemraizer,项目名称:mongo-csharp-driver,代码行数:7,代码来源:ImmutableTypeClassMapConventionTests.cs


示例18: TestNamedExtraElementsMemberConventionWithTestClassB

 public void TestNamedExtraElementsMemberConventionWithTestClassB()
 {
     var convention = new NamedExtraElementsMemberConvention("ExtraElements");
     var classMap = new BsonClassMap<TestClassB>();
     convention.Apply(classMap);
     Assert.IsNull(classMap.ExtraElementsMemberMap);
 }
开发者ID:Bogdan0x400,项目名称:mongo-csharp-driver,代码行数:7,代码来源:ExtraElementsConventionsTests.cs


示例19: TestDoesNotMapExtraElementsWhenIsNotValidType

        public void TestDoesNotMapExtraElementsWhenIsNotValidType()
        {
            var classMap = new BsonClassMap<TestClass5>();

            _subject.Apply(classMap);

            Assert.IsNull(classMap.ExtraElementsMemberMap);
        }
开发者ID:robinNode,项目名称:mongo-csharp-driver,代码行数:8,代码来源:NamedExtraElementsConventionsTests.cs


示例20: TestMapsExtraElementsWhenFirstNameExists

        public void TestMapsExtraElementsWhenFirstNameExists()
        {
            var classMap = new BsonClassMap<TestClass2>();

            _subject.Apply(classMap);

            Assert.IsNotNull(classMap.ExtraElementsMemberMap);
        }
开发者ID:robinNode,项目名称:mongo-csharp-driver,代码行数:8,代码来源:NamedExtraElementsConventionsTests.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# BsonDocument类代码示例发布时间:2022-05-24
下一篇:
C# BsonBinarySubType类代码示例发布时间: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