Exemplo n.º 1
0
        internal static void SetupDatabase()
        {
            BsonClassMap.RegisterClassMap <Entity <Guid> >(cm =>
            {
                cm.AutoMap();
                cm.MapIdMember(c => c.Id);
                cm.AddKnownType(typeof(Entity));
            });

            BsonClassMap.RegisterClassMap <Entity>(cm =>
            {
                cm.AutoMap();
                cm.SetIsRootClass(true);
            });

            MongoHelpers.AutoRegisterClassMap <Level>(c => new Level(c.Id, c.Description, c.Generators, c.NextLevels));
            MongoHelpers.AutoRegisterClassMap <Topic>(c => new Topic(c.Id, c.Name, c.Description, c.Levels));

            MongoHelpers.AutoRegisterClassMap <TemplateTaskGenerator>(c => new TemplateTaskGenerator(c.Id, c.PossibleAnswers,
                                                                                                     c.Text, c.Hints,
                                                                                                     c.Answer, c.Streak, c.Question));
            MongoHelpers.AutoRegisterClassMap <TaskGenerator>(cm => cm.SetIsRootClass(true));
            MongoHelpers.AutoRegisterClassMap <TaskInfoEntity>(c => new TaskInfoEntity(c.Question, c.Answer, c.Hints, c.HintsTaken,
                                                                                       c.ParentGeneratorId, c.IsSolved, c.Id));

            MongoHelpers.AutoRegisterClassMap <UserEntity>(c => new UserEntity(c.Id, c.UserProgressEntity));

            MongoHelpers.AutoRegisterClassMap <LevelProgressEntity>(cm =>
            {
                MongoHelpers.MapDictionary <LevelProgressEntity, Guid, int>(cm, c => c.CurrentLevelStreaks);
                cm.MapCreator(c => new LevelProgressEntity(c.LevelId, c.CurrentLevelStreaks, c.Id));
            });
            MongoHelpers.AutoRegisterClassMap <TopicProgressEntity>(cm =>
            {
                MongoHelpers.MapDictionary <TopicProgressEntity, Guid, LevelProgressEntity>(cm, c => c.LevelProgressEntities);
                cm.MapCreator(c => new TopicProgressEntity(c.LevelProgressEntities, c.TopicId, c.Id));
            });
            MongoHelpers.AutoRegisterClassMap <UserProgressEntity>(cm =>
            {
                MongoHelpers.MapDictionary <UserProgressEntity, Guid, TopicProgressEntity>(cm, c => c.TopicsProgress);
                cm.MapCreator(c => new UserProgressEntity(c.CurrentTopicId, c.CurrentLevelId, c.UserId,
                                                          c.TopicsProgress, c.CurrentTask, c.Id));
            });
        }
Exemplo n.º 2
0
 static UserRepository()
 {
     MongoHelpers.AutoRegisterClassMap <Container>();
     MongoHelpers.AutoRegisterClassMap <TAuth>();
     MongoHelpers.AutoRegisterClassMap <TToken>();
 }