Skip to content

Instantly share code, notes, and snippets.

@alastairtree
alastairtree / XmlDocumentCleanJsonFormatter.cs
Created June 12, 2016 12:16
xml and json conversion formatters
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml;
using Newtonsoft.Json.Linq;
namespace Formatters
{
public class XmlDocumentCleanJsonFormatter : XmlDocumentRawJsonFormatter
{
using System;
namespace Util
{
public interface IClock
{
DateTime NowUtc { get; }
}
public class Clock : IClock
namespace Util
{
public static class ExceptionExtensions
{
public static T Unwrap<T>(this Exception exception) where T : class
{
return exception.InnerException?.Unwrap<T>() ?? exception as T;
}
public static Exception Unwrap(this Exception exception)
using System;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
namespace Util
{
public static class XmlUtil
{
using System;
using System.Configuration;
namespace Util
{
public static class Config
{
public static string GetSetting(string key) => ConfigurationManager.AppSettings[key];
public static bool HasSetting(string key) => !string.IsNullOrEmpty(GetSetting(key));
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Util
{
public class FileHelper
{
public bool IsDirectoryEmpty(string path)
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Util
{
public class FileHelper
{
public bool IsDirectoryEmpty(string path)
@alastairtree
alastairtree / build.ps1
Created February 27, 2018 22:56
AppVeyor dotnet core CLI build script - restore, compile, test, upload test results and publish artifacts/nupkgs
Set-StrictMode -Version latest
$ErrorActionPreference = "Stop"
# Taken from psake https://github.com/psake/psake
<#
.SYNOPSIS
This is a helper function that runs a scriptblock and checks the PS variable $lastexitcode
to see if an error occcured. If an error is detected then an exception is thrown.
This function allows you to run command-line programs without having to
explicitly check the $lastexitcode variable.
@alastairtree
alastairtree / my_boxstarter
Last active December 5, 2018 10:39
my boxtstarter
choco install firefox -y
choco install 7zip -y
choco install putty -y
choco install notepadplusplus.install -y
choco install nuget.commandline -y
choco install git -y
choco install kdiff3 -y
choco install gitextensions -y
choco install vim -y
choco install fiddler4 -y
# Original code from https://github.com/slavizh/OMSSearch/blob/master/OMSSearch.psm1
# - Updated/fixed authentication method calls
# - Ensure ADAL DLL is loaded
Function Get-AADToken {
<#
.SYNOPSIS
Get token from Azure AD so you can use the other cmdlets.
.DESCRIPTION
Get token from Azure AD so you can use the other cmdlets.