This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CurrencyHelper | |
{ | |
private static string _currencyRegex = "rhs: \\\"(\\d*.\\d*)"; | |
// slightly modified from: http://www.ashishblog.com/blog/currency-exchange-rate-in-webpage-using-c-asp-net/ | |
// Uses a google api which takes requests in this format: http://www.google.com/ig/calculator?hl=en&q=1AUD%3D%3FUSD | |
public static decimal Convert(decimal amount, string fromCurrency, string toCurrency) | |
{ | |
var web = new WebClient(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[EditorBrowsable(EditorBrowsableState.Never)] | |
public interface IFluentInterface { | |
[EditorBrowsable(EditorBrowsableState.Never)] | |
Type GetType(); | |
[EditorBrowsable(EditorBrowsableState.Never)] | |
int GetHashCode(); | |
[EditorBrowsable(EditorBrowsableState.Never)] | |
string ToString(); | |
[EditorBrowsable(EditorBrowsableState.Never)] | |
bool Equals(object obj); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static DownloadableFile ToDownloadableXmlFileForExcel2003(this System.Xml.Linq.XDocument file, string fileName) | |
{ | |
MemoryStream ms = new MemoryStream(); | |
XmlWriterSettings xmlWriterSettings = new XmlWriterSettings() { Encoding = Encoding.UTF8 }; | |
XmlWriter xmlWriter = XmlWriter.Create(ms, xmlWriterSettings); | |
file.Save(xmlWriter); //.Save() adds the <xml /> header tag! | |
xmlWriter.Close(); //Must close the writer to dump it's content its output (the memory stream) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class DateExtensions | |
{ | |
public static string TimeAgo(this DateTime date) | |
{ | |
if (date <= DateTime.Now) | |
{ | |
var timeSince = DateTime.Now.Subtract(date); | |
if (timeSince.TotalMilliseconds < 1) return "not yet"; | |
if (timeSince.TotalMinutes < 1) return "just now"; | |
if (timeSince.TotalMinutes < 2) return "1 minute ago"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class CalendarHelpers | |
{ | |
//Google Calender | |
public static string GoogleCalendar(this HtmlHelper helper, string linkText, string what, DateTime start, DateTime? end, string description, string location, string websiteName, string websiteAddress, string attributes) | |
{ | |
//parse dates | |
var dates = start.ToString("yyyyMMddTHHmmssZ"); | |
if (end.HasValue && end > start) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class StringExtensions | |
{ | |
/// Like linq take - takes the first x characters | |
public static string Take(this string theString, int count, bool ellipsis = false) | |
{ | |
int lengthToTake = Math.Min(count, theString.Length); | |
var cutDownString = theString.Substring(0, lengthToTake); | |
if (ellipsis && lengthToTake < theString.Length) | |
cutDownString += "..."; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Globalization; | |
using System.Linq; | |
using Newtonsoft.Json.Linq; | |
using RestSharp; | |
using RestSharp.Deserializers; | |
using RestSharp.Extensions; |
NewerOlder