Esempio n. 1
0
        public override async Task OnActionExecutionAsync(ActionExecutingContext actionContext, ActionExecutionDelegate next)
        {
            var configurationJSON = Request.Headers["X-Backend-Configuration"];
            var backendTypeString = Request.Headers["X-Backend-Driver"];

            var configHash = (configurationJSON + backendTypeString).GetHashCode();

            backend = MemoryCache.GetOrCreate(backendTypeString, i => {
                Logger.LogInformation($"Request: {actionContext.ActionDescriptor.DisplayName} "
                                      + $"{Request.Path.Value} Driver: {backendTypeString}");

                try
                {
                    var backendType = Type.GetType(backendTypeString);
                    var backend     = Activator.CreateInstance(backendType) as IFileBackend;
                    backend.Logger  = BackendLogger;
                    return(backend);
                }
                catch (Exception e)
                {
                    throw new Exception($"X-Backend-Driver={backendTypeString}: Failed to create backend", e);
                }
            });

            this.context = MemoryCache.GetOrCreate(configHash, i => {
                object config = null;

                config = backend.CreateContext(configurationJSON);
                return(config);
            });

            await next();
        }
Esempio n. 2
0
 public FileController(IFileBackend fileBackend, ICurrentUserDirectoryService currentUserDirectoryService)
 {
     this.fileBackend = fileBackend;
     this.currentUserDirectoryService = currentUserDirectoryService;
 }
 public FileListingHub(IFileBackend fileBackend,
                       ICurrentUserDirectoryService currentUserDirectoryService)
 {
     this.fileBackend = fileBackend;
     this.currentUserDirectoryService = currentUserDirectoryService;
 }
Esempio n. 4
0
 public SymbolMaps(Kirin k, IFileBackend fileBackend) : base("SymbolMapService", k)
 {
     _Service     = new Generated.SymbolMapService(KirinAssistant);
     _FileBackend = fileBackend;
 }