Beispiel #1
0
 public QueryBuilderTests()
 {
     service = new QueryBuilder(GetService <ILogger <QueryBuilder> >(),
                                GetService <IViewTypeInfoService>(), GetService <IMapper>(), GetService <ISearchQueryParser>(),
                                GetService <IPermissionService>());
     typeInfoService = GetService <IViewTypeInfoService>();
 }
 public UserService(ILogger <UserService> logger, IHashService hashService, IAuthTokenService <long> authTokenService,
                    UserServiceConfig config, IDbServicesFactory factory, IViewTypeInfoService typeInfoService)
 {
     this.logger           = logger;
     this.hashService      = hashService;
     this.authTokenService = authTokenService;
     this.config           = config;
     this.dbFactory        = factory;
     this.typeInfoService  = typeInfoService;
     userTable             = typeInfoService.GetDatabaseForType <UserView>();
 }
 public GenericSearcher(ILogger <GenericSearcher> logger, IDbConnection connection,
                        IViewTypeInfoService typeInfoService, GenericSearcherConfig config, IMapper mapper,
                        IQueryBuilder queryBuilder, IPermissionService permissionService)
 {
     this.logger            = logger;
     this.dbcon             = connection;
     this.typeService       = typeInfoService;
     this.config            = config;
     this.mapper            = mapper;
     this.queryBuilder      = queryBuilder;
     this.permissionService = permissionService;
 }
Beispiel #4
0
    public QueryBuilder(ILogger <QueryBuilder> logger, IViewTypeInfoService typeInfoService,
                        IMapper mapper, ISearchQueryParser parser, IPermissionService permissionService)
    {
        this.logger            = logger;
        this.typeService       = typeInfoService;
        this.mapper            = mapper;
        this.parser            = parser;
        this.permissionService = permissionService;

        var assembly = System.Reflection.Assembly.GetAssembly(typeof(contentapi.data.Views.UserView)) ?? throw new InvalidOperationException("NO ASSEMBLY FOR QUERYBUILDER???");

        //Pull the view types out, compute the STANDARD mapping of requests to views. Requests that don't have a standard mapping have something custom and don't go through
        //any of the standard codepaths (they do their own thing entirely)
        ViewTypes = assembly.GetTypes().Where(t => String.Equals(t.Namespace, $"{nameof(contentapi)}.{nameof(contentapi.data)}.{nameof(contentapi.data.Views)}", StringComparison.Ordinal)).ToList();
        var typeInfos = ViewTypes.Select(x => typeInfoService.GetTypeInfo(x));

        StandardViewRequests = typeInfos.Where(x => x.requestType.HasValue).ToDictionary(
            k => k.requestType ?? throw new InvalidOperationException("How did the HasValue check fail on StandardViewRequest build??"), v => v.type);

        if (StandardViewRequests.Count == 0)
        {
            throw new InvalidOperationException("NO VIEWS FOUND FOR CACHING IN QUERY BUILDER!! Check the namespace!");
        }
    }
    public static string GetDatabaseForType <T>(this IViewTypeInfoService typeService)
    {
        var typeinfo = typeService.GetTypeInfo <T>();

        return(typeinfo.selectFromSql ?? throw new InvalidOperationException($"No database for type {typeof(T).Name}"));
    }
Beispiel #6
0
 public PermissionService(ILogger <PermissionService> logger, IViewTypeInfoService typeInfoService)
 {
     this.typeInfoService = typeInfoService;
     this.logger          = logger;
 }