This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.ConfigureServices((hostContext, services) => | |
{ | |
services.AddTransient<PdfReader>() | |
.AddTransient<PdfProcessor>() | |
.AddTransient<OdtReader>() | |
.AddTransient<OdtProcessor>(); | |
services.AddSingleton<WordReader>() | |
.AddSingleton<WordProcessor>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IDocumentProcessor { } | |
public class PdfProcessor : IDocumentProcessor { | |
public PdfProcessor(PdfReader reader) { } | |
} | |
public class OdtProcessor : IDocumentProcessor { | |
public OdtProcessor(OdtReader reader) { } | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IShapeRenderer { } | |
public class CircleRenderer : IShapeRenderer { } | |
public class TriangleRenderer : IShapeRenderer { } | |
public class SquareRenderer : IShapeRenderer { } | |
public interface IShapeRendererFactory | |
{ | |
IShapeRenderer Create(string type); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void Configure(IApplicationBuilder app) | |
{ | |
var healthCheckOptions = new HealthCheckOptions() | |
{ | |
ResponseWriter = WriteReadinessResponse | |
}; | |
app.UseEndpoints(endpoints => | |
{ | |
endpoints.MapHealthChecks("/ops/health", healthCheckOptions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var tran = await _dbContext.BeginTransactionAsync()) | |
{ | |
try | |
{ | |
var modelsToRemove = await _dbContext.QueryModels | |
.Where(f => /* some filter here */) | |
.ToArrayAsync(); | |
if (modelsToRemove.Any()) | |
_dbContext.QueryModels.RemoveRange(modelsToRemove); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using (var tran = await _dbContext.BeginTransactionAsync()) | |
{ | |
try | |
{ | |
var modelsToRemove = await _dbContext.QueryModels | |
.Where(f => /* some filter here */) | |
.ToArrayAsync(); | |
if (modelsToRemove.Any()) | |
_dbContext.QueryModels.RemoveRange(modelsToRemove); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Task aggregationTask = null; | |
try{ | |
var task1 = DoSomethingAsync(); | |
var task2 = DoSomethingElseAsync(); | |
aggregationTask = Task.WhenAll(task1, task2); | |
await aggregationTask; | |
}catch(Exception ex){ | |
if(aggregationTask?.Exception?.InnerExceptions != null && aggregationTask.Exception.InnerExceptions.Any()) | |
foreach (var innerEx in aggregationTask.Exception.InnerExceptions){ | |
// do your magic here |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try{ | |
var task1 = DoSomethingAsync(); | |
var task2 = DoSomethingElseAsync(); | |
await Task.WhenAll(task1, task2); | |
}catch(Exception ex){ | |
// do something meaningful with the exception | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var task1 = DoSomethingAsync(); | |
var task2 = DoSomethingElseAsync(); | |
await Task.WhenAll(task1, task2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IFoo{ | |
void Bar(); | |
} | |
public class Foo : IFoo{ | |
public Bar(){ | |
// whatever... | |
} | |
} |
NewerOlder