Skip to content

Instantly share code, notes, and snippets.

View goldytech's full-sized avatar

Muhammad Afzal Qureshi goldytech

View GitHub Profile
@goldytech
goldytech / Convert.csx
Last active December 16, 2020 01:25
Convert MSTest to XUnit
using System.Text.RegularExpressions;
using System;
using System.IO;
string path = string.Empty;
if (Env.ScriptArgs.Count() == 1)
{
path = Env.ScriptArgs[0];
}
@goldytech
goldytech / Sample Startup.cs
Created March 6, 2016 06:27
ConfigureServices and Configure methods in Startup.cs of Asp.net core
// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddSingleton<IDataService, DataService>();
services.AddSingleton<IViewModelService, ViewModelService>();
}
@goldytech
goldytech / Azurefunctions.cs
Created August 22, 2018 05:54
Azure Functions SendGrid email from blob container.
namespace AzFuncAppBlobToSendGrid
{
using System;
using System.IO;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;
using SendGrid.Helpers.Mail;
@goldytech
goldytech / serverless.yml
Created June 4, 2019 06:03
serverless config for aws lambda layers
# Welcome to Serverless!
#
# This file is the main config file for your service.
# It's very minimal at this point and uses default values.
# You can always add more config options for more control.
# We've included some commented out config examples here.
# Just uncomment any of them to get that config option.
#
# For full config options, check the docs:
# docs.serverless.com
@goldytech
goldytech / Model.cs
Created October 7, 2019 10:49
HR domain model
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsManager { get; set; }
public Department Department { get; set; }
@goldytech
goldytech / Model.cs
Created October 7, 2019 11:04
Updated Model
public class Employee
{
public int Id { get; set; }
public string Name { get; set; }
public bool IsManager { get; set; }
public Department Department { get; set; }
@goldytech
goldytech / IsHrManager.cs
Last active October 7, 2019 11:16
Positional Pattern
private static bool IsHrManagerByPositionalPattern(object obj)
{
return obj is Employee e && e is (_, _ , true, (_, "Human Resources"));
}
@goldytech
goldytech / empobj.cs
Created October 7, 2019 11:27
Employee object
var employee = new Employee
{
Id = 1,
Department = new Department {Id = 1, Name = "Human Resources"},
Name = "John Doe",
IsManager = true
},
@goldytech
goldytech / HrManagerByPropertyPattern.cs
Created October 7, 2019 12:13
Property Pattern matching
private static bool IsHrManagerByPropertyPattern(object employee)
{
return employee is Emp e && e is { IsManager: true, Department: {Name: "Human Resources" } };
}
@goldytech
goldytech / clm.cs
Created October 7, 2019 12:33
Agreement Life Cycle
public enum StatusCategory
{
Request,
InSignature,
InAuthoring,
InEffect,
Terminated,
Expired
}