Skip to content

Instantly share code, notes, and snippets.

@scottoffen
scottoffen / Program.cs
Created August 30, 2019 17:35
Make delegates from methods
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
namespace DelegateTesting
{
public class Program
{
public static void Main(string[] args)
@troyanov
troyanov / CoreAutomation.tt
Last active March 7, 2020 09:22
Generate Enums from database lookup tables. CoreAutomation.tt - t4 helper class, that uses EnvDTE to get all Projects in Solution, configurations, etc. DBEnum.tt - generates enums for tables by criteria enumDescriptionColumnName
<#@ template debug="true" hostspecific="true" language="C#" #>
<#@ output encoding="utf-8" extension=".cs"#>
<#@ assembly name="EnvDTE" #>
<#@ assembly name="EnvDTE80" #>
<#@ assembly name="System.Core" #>
<#@ assembly name="System.Configuration" #>
<#@ import namespace="System.Collections.Generic" #>
<#@ import namespace="System.Configuration" #>
<#@ import namespace="System.Text.RegularExpressions" #>
<#@ import namespace="EnvDTE" #>
@emmkong
emmkong / Get Relative Path in Unit Test
Last active November 28, 2023 08:04
Get full path from relative path in unit testing
private string GetFolderPath()
{
var currentAssemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase).Replace(@"file:\", string.Empty);
var relativePath = Path.Combine(currentAssemblyPath, @"..\folder");
return Path.GetFullPath(relativePath);
}