Skip to content

Instantly share code, notes, and snippets.

View smchristensen's full-sized avatar

Scott Christensen smchristensen

View GitHub Profile
@smchristensen
smchristensen / HandlebarsRenderer.cs
Created December 19, 2018 19:05
Handlebars.Net ITemplateRenderer for FluentEmail. Works best as a singleton as it will compile and store each template passed in
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using FluentEmail.Core.Interfaces;
using HandlebarsDotNet;
namespace FluentEmail.Renderers
{
public class HandlebarsRenderer : ITemplateRenderer
{
@smchristensen
smchristensen / Quick method for deserializing JSON URL response
Created September 13, 2016 03:34
Simple concept method for deserializing a JSON response to a class. No error checking is done so don't use this as is but use as a base.
private List<T> GetRestRequestList<T>(string url)
{
List<T> results = new List<T>();
var httpClient = new HttpClient();
var response = httpClient.GetAsync(new Uri(url)).Result;
//will throw an exception if not successful
response.EnsureSuccessStatusCode();
@smchristensen
smchristensen / AuthenticatedWcfServiceClientBuilder.cs
Last active March 11, 2016 06:13
General code for creating an authenticated (Basic) WCF service client. IFace is the WCF interface and Clnt is the Client that inherits from ClientBase. Uses an endpoint and endpoint url when creating the client. Also uses the self-cleaning service model from ChannelAdam.
using System.ServiceModel;
using ChannelAdam.ServiceModel;
using EcmServices.DataModel;
public class User
{
public String Username { get; set; }
public String Password { get; set; }
}