protected override async Task WriteResponseAsync(DashboardResponse response) { foreach (var resourceName in _resourceNames) { await WriteResourceAsync( response, _assembly, $"{_baseNamespace}.{resourceName}"); } }
protected async Task WriteResourceAsync(DashboardResponse response, Assembly assembly, string resourceName) { using (var inputStream = assembly.GetManifestResourceStreamIgnoreCase(resourceName)) { if (inputStream == null) { throw new ArgumentException($@"Resource with name {resourceName} not found in assembly {assembly}."); } await inputStream.CopyToAsync(response.Body); } }
protected async Task WriteResourceAsync(DashboardResponse response, string path) { var dllPath = System.IO.Path.Combine(AppContext.BaseDirectory, path); if (!System.IO.File.Exists(path) && System.IO.File.Exists(dllPath)) { path = dllPath; } using (var inputStream = System.IO.File.OpenRead(path)) { if (inputStream == null) { throw new ArgumentException($@"Path with name {path} not found in file."); } await inputStream.CopyToAsync(response.Body); } }
protected virtual async Task WriteResponseAsync(DashboardResponse response, string path) { await WriteResourceAsync(response, path); }
protected virtual async Task WriteResponseAsync(DashboardResponse response, string resourceName) { await WriteResourceAsync(response, _assembly, resourceName); }