Exemple #1
0
        public TRepository GetRepository <TRepository>() where TRepository : IRepository
        {
            TRepository repository = ExtensionManager.GetInstance <TRepository>(a => a.FullName.ToLower().Contains("entityframework.postgresql"));

            repository.SetStorageContext(this.StorageContext);
            return(repository);
        }
Exemple #2
0
        /// <summary>
        /// Gets a repository of the given type.
        /// </summary>
        /// <typeparam name="T">The type parameter to find implementation of.</typeparam>
        /// <returns></returns>
        public TRepository GetRepository <TRepository>() where TRepository : IRepository
        {
            TRepository repository = ExtensionManager.GetInstance <TRepository>();

            repository.SetStorageContext(this.StorageContext);
            return(repository);
        }
Exemple #3
0
        /// <summary>
        /// Gets a repository of the given type.
        /// </summary>
        /// <typeparam name="T">The type parameter to find implementation of.</typeparam>
        /// <returns></returns>
        public TRepository GetRepository <TRepository>() where TRepository : IRepository
        {
            TRepository repository = ExtensionManager.GetInstance <TRepository>();

            if (repository != null)
            {
                repository.SetStorageContext(this.StorageContext, this.Client);
            }

            return(repository);
        }
        public TRepository GetRepository <TRepository>() where TRepository : IRepository
        {
            foreach (Type type in this.GetType().GetTypeInfo().Assembly.GetTypes())
            {
                if (typeof(TRepository).GetTypeInfo().IsAssignableFrom(type) && type.GetTypeInfo().IsClass)
                {
                    TRepository repository = (TRepository)Activator.CreateInstance(type);

                    repository.SetStorageContext(this.Context);
                    return(repository);
                }
            }

            return(default(TRepository));
        }
Exemple #5
0
        public TRepository GetRepository <TRepository>() where TRepository : IDataRepository
        {
            foreach (Assembly assembly in Assemblies.Where(a => !a.FullName.Contains("Reflection")))
            {
                foreach (Type type in assembly.GetTypes())
                {
                    if (typeof(TRepository).IsAssignableFrom(type) && type.GetTypeInfo().IsClass)
                    {
                        TRepository repository = (TRepository)Activator.CreateInstance(type);
                        repository.SetStorageContext(StorageContext);
                        return(repository);
                    }
                }
            }

            throw new ArgumentException("Implementation of " + typeof(TRepository) + " not found");
        }