Skip to content

Instantly share code, notes, and snippets.

View merken's full-sized avatar

Maarten Merken merken

View GitHub Profile
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
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;
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
public interface IInvoicingService
{
string CreateInvoice(float numberOfHoursPerformed);
}
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;
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));
}
}
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.
[Route("api/[controller]")]
[ApiController]
public class InvoicesController : ControllerBase
{
private readonly IEnumerable<IInvoicingService> invoicingServices;
public InvoicesController(IEnumerable<IInvoicingService> invoicingServices)
{
this.invoicingServices = invoicingServices;
}
@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();
@merken
merken / calculation.cs
Last active July 3, 2018 06:57
Addition, Division, Multiplication, and Subtraction
using System;
namespace calculation
{
public class Addition : ICalculation
{
private readonly decimal x;
private readonly decimal y;
public Addition(decimal x, decimal y)