public ITypedMongoRepository <T> GetRepository <T>() where T : MongoEntity
            {
                var type = typeof(T);

                ITypedMongoRepository <T> typedRepoObj = null;
                IGenericMongoRepository   repoObj      = null;

                lock (repositoryFactoryLck)
                {
                    if (!repositoryFactory.TryGetValue(type, out repoObj))
                    {
                        typedRepoObj = new MongoRepository <T>(Database.GetCollection <T>(type.Name.ToLowerInvariant()));
                        repositoryFactory.Add(type, typedRepoObj);
                    }
                    else
                    {
                        typedRepoObj = (ITypedMongoRepository <T>)repoObj;
                    }
                }

                return(typedRepoObj);
            }
 public NoteController(IGenericMongoRepository<Note> noteRepository)
 {
     _noteRepository = noteRepository;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="$safeitemname$Controller"/> class.
 /// </summary>
 /// <param name="genericRepository">The generic repository.</param>
 public $safeitemname$Controller(IGenericMongoRepository genericRepository)
 {
     this.genericRepository = genericRepository;
     createdAtActionName    = nameof($safeitemname$Controller);
 }
 /// <summary>
 /// Pass the intended method name to createdAtActionName
 /// argument.
 /// Use of the "nameof(..)" keyword is advised.
 /// </summary>
 /// <param name="repository">The repository.</param>
 /// <param name="createdAtActionName">Name of the created at action.</param>
 protected ApiController(IGenericMongoRepository repository, string createdAtActionName)
 {
     this.genericRepository   = repository;
     this.createdAtActionName = createdAtActionName;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ApiController{TDocument}"/> class.
 /// </summary>
 /// <param name="genericRepository">The generic repository.</param>
 protected ApiController(IGenericMongoRepository genericRepository)
 {
     this.genericRepository = genericRepository;
 }
Esempio n. 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EventFlowEventController"/> class.
 /// </summary>
 /// <param name="genericRepository">The generic repository.</param>
 public EventFlowEventController(IGenericMongoRepository genericRepository)
 {
     this.genericRepository = genericRepository;
     createdAtActionName    = nameof(EventFlowEventController);
 }