コード例 #1
0
        protected EntityCollectionDefinition(IMongoConnectionHandler connectionHandler)
        {
            if (connectionHandler == null)
            {
                throw new ArgumentNullException("connectionHandler");
            }

            Collection = connectionHandler.Database.GetCollection <T>(typeof(T).Name.ToLower() + "s");

            // setup serialization
            if (!BsonClassMap.IsClassMapRegistered(typeof(Entity)))
            {
                try
                {
                    BsonClassMap.RegisterClassMap <Entity>(
                        cm =>
                    {
                        cm.AutoMap();
                        cm.SetIdMember(cm.GetMemberMap(i => i.Id));
                        cm.IdMemberMap.SetIdGenerator(StringObjectIdGenerator.Instance);
                    });
                }
                catch (ArgumentException)
                {
                    // this fails with an argument exception at startup, but otherwise works fine.  Probably should try to figure out why, but ignoring it is easier :(
                }
            }
        }
コード例 #2
0
 public InfoController(IMemberRepository memberRepository, IMongoConnectionHandler mongoConnectionHandler, 
     ICommentRepository commentRepository, IInfoRepository infoRepository)
 {
     _memberRepo = memberRepository;
     _commentRepo = commentRepository;
     _infoRepo = infoRepository;
     _mongoConnectionHandler = mongoConnectionHandler;
 }
コード例 #3
0
 public TapCollectionDefinition(IMongoConnectionHandler connectionHandler)
     : base(connectionHandler)
 {
     if (!BsonClassMap.IsClassMapRegistered(typeof(Tap)))
     {
         BsonClassMap.RegisterClassMap <Tap>(
             cm =>
         {
             cm.AutoMap();
         });
     }
 }
 public MeetingInfoValuesCollectionDefinition(IMongoConnectionHandler connectionHandler)
     : base(connectionHandler)
 {
     if (!BsonClassMap.IsClassMapRegistered(typeof(MeetingInfoValues)))
     {
         BsonClassMap.RegisterClassMap <MeetingInfoValues>(
             cm =>
         {
             cm.AutoMap();
         });
     }
 }
コード例 #5
0
 public SecurityRequestCollectionDefinition(IMongoConnectionHandler connectionHandler)
     : base(connectionHandler)
 {
     if (!BsonClassMap.IsClassMapRegistered(typeof(SecurityRequest)))
     {
         BsonClassMap.RegisterClassMap <SecurityRequest>(
             cm =>
         {
             cm.AutoMap();
         });
     }
 }
コード例 #6
0
 public StoredEventCollectionDefinition(IMongoConnectionHandler connectionHandler)
     : base(connectionHandler)
 {
     if (!BsonClassMap.IsClassMapRegistered(typeof(StoredEvent)))
     {
         BsonClassMap.RegisterClassMap <StoredEvent>(
             cm =>
         {
             cm.AutoMap();
         });
     }
 }
コード例 #7
0
        public UserCollectionDefinition(IMongoConnectionHandler connectionHandler)
            : base(connectionHandler)
        {
            if (!BsonClassMap.IsClassMapRegistered(typeof(User)))
            {
                BsonClassMap.RegisterClassMap <User>(
                    cm =>
                {
                    cm.AutoMap();
                    cm.MapField("_roleIds").SetElementName("RoleIds");
                });
            }

            Collection.EnsureIndex(new IndexKeysBuilder().Ascending("Username"));
        }
コード例 #8
0
 public SecurityRequestCollectionDefinition(IMongoConnectionHandler connectionHandler)
     : base(connectionHandler)
 {
     if (!BsonClassMap.IsClassMapRegistered(typeof(SecurityRequest)))
     {
         try
         {
             BsonClassMap.RegisterClassMap <SecurityRequest>(
                 cm =>
             {
                 cm.AutoMap();
             });
         }
         catch (ArgumentException)
         {
             // this fails with an argument exception at startup, but otherwise works fine.  Probably should try to figure out why, but ignoring it is easier :(
         }
     }
 }
コード例 #9
0
        protected EntityCollectionDefinition(IMongoConnectionHandler connectionHandler)
        {
            if (connectionHandler == null)
            {
                throw new ArgumentNullException("connectionHandler");
            }

            Collection = connectionHandler.Database.GetCollection <T>(typeof(T).Name.ToLower() + "s");

            // setup serialization
            if (!BsonClassMap.IsClassMapRegistered(typeof(Entity)))
            {
                BsonClassMap.RegisterClassMap <Entity>(
                    cm =>
                {
                    cm.AutoMap();
                    cm.SetIdMember(cm.GetMemberMap(c => c.Id));
                    cm.IdMemberMap.SetIdGenerator(StringObjectIdGenerator.Instance);
                });
            }
        }