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 System; | |
using System.Data; | |
using System.Data.SqlClient; | |
using System.Linq; | |
using System.Reflection; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; | |
namespace txn |
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 System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.HttpsPolicy; | |
using Microsoft.AspNetCore.Mvc; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.DependencyInjection; |
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 System; | |
using System.Collections.Generic; | |
using System.Data; | |
using System.Linq; | |
using System.Threading.Tasks; | |
using Dapper; | |
namespace txn.Models | |
{ | |
public class MyItemsRepository : IService |
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 IInvoicingService | |
{ | |
string CreateInvoice(float numberOfHoursPerformed); | |
} |
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 class EuroInvoicingService : IInvoicingService | |
{ | |
private float rate = 25; | |
private string currency = "EUR"; | |
private float vat = 0.21f; | |
public string CreateInvoice(float numberOfHoursPerformed) | |
{ | |
var value = rate * numberOfHoursPerformed; | |
value += value * vat; |
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 static class ServiceCollectionExtensions | |
{ | |
public static void RegisterAllTypes<T>(this IServiceCollection services, Assembly[] assemblies, | |
ServiceLifetime lifetime = ServiceLifetime.Transient) | |
{ | |
var typesFromAssemblies = assemblies.SelectMany(a => a.DefinedTypes.Where(x => x.GetInterfaces().Contains(typeof(T)))); | |
foreach (var type in typesFromAssemblies) | |
services.Add(new ServiceDescriptor(typeof(T), type, lifetime)); | |
} | |
} |
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 class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
// This method gets called by the runtime. Use this method to add services to the container. |
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
[Route("api/[controller]")] | |
[ApiController] | |
public class InvoicesController : ControllerBase | |
{ | |
private readonly IEnumerable<IInvoicingService> invoicingServices; | |
public InvoicesController(IEnumerable<IInvoicingService> invoicingServices) | |
{ | |
this.invoicingServices = invoicingServices; | |
} |
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
@Component({ | |
selector: 'app-comp', | |
templateUrl: './comp.component.html', | |
styleUrls: ['./comp.component.scss'] | |
}) | |
export class CompComponent implements OnInit, AfterViewInit { | |
@ViewChild('inputField') inputField: ElementRef; | |
constructor(private elementRef: ElementRef, private renderer: Renderer) { | |
super(); |
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 System; | |
namespace calculation | |
{ | |
public class Addition : ICalculation | |
{ | |
private readonly decimal x; | |
private readonly decimal y; | |
public Addition(decimal x, decimal y) |