This file contains 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
private IEnumerable<string> GetElementNames(XElement xElement, string path) | |
{ | |
var output = new List<string>(); | |
if (string.IsNullOrWhiteSpace(path)) | |
{ | |
path = xElement.Name.ToString(); | |
output.Add(path); | |
if (xElement.HasAttributes) |
This file contains 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
// resource https://raw.github.com/padolsey/prettyPrint.js/master/prettyprint.js | |
var Debug = { | |
Setup: function() { | |
var debugDivId = "debug"; | |
if (document.getElementById(debugDivId) === null || document.getElementById(debugDivId) === 'undefined') { | |
var div = document.createElement('div'); | |
div.id = debugDivId; | |
div.style.position = "absolute"; | |
div.style.zIndex = "9999"; |
This file contains 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
// resource http://www.phpied.com/rgb-color-parser-in-javascript/ | |
// resource http://code.google.com/p/canvg/ | |
// resource http://www.nihilogic.dk/labs/canvas2image/ | |
String.prototype.FixForRaphael = function() { | |
// based on http://goo.gl/KZDII strip off all spaces between tags | |
var svgXmlNoSpace = this.replace(/>\s+/g, ">").replace(/\s+</g, "<"); | |
// based on gabelerner added xmlns:xlink="http://www.w3.org/1999/xlink" into svg xlmns | |
var svgXmlFixNamespace = svgXmlNoSpace.replace('xmlns="http://www.w3.org/2000/svg"', 'xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"'); |
This file contains 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; | |
public static class StringConverters | |
{ | |
public static string ToBase64(this string value, Encoding encoding) | |
{ | |
byte[] encbuff = encoding.GetBytes(value); | |
return Convert.ToBase64String(encbuff); | |
} |
This file contains 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 sealed class ControlChars | |
{ | |
/// <summary> | |
/// Chr(8) | |
/// </summary> | |
public const char BackSpace = '\b'; // #8 | |
/// <summary> | |
/// Chr(13) | |
/// </summary> | |
public const char CarriageReturn = '\r'; // #13 |
This file contains 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 long GetSize(object value) | |
{ | |
long result; | |
using (var stream = new System.IO.MemoryStream()) | |
{ | |
var serializer = new System.Runtime.Serialization.NetDataContractSerializer(); | |
serializer.WriteObject(stream, value); | |
stream.Flush(); | |
result = stream.Length; | |
} |
This file contains 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.Reflection; | |
using System.ComponentModel; | |
public static class Enumerations | |
{ | |
/// <summary> | |
/// Retrieves the enumeration's description based on given value | |
/// </summary> | |
public static string GetDescription(this Enum value) |
This file contains 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
// resource https://gist.github.com/4017806 | |
using System; | |
using System.Text.RegularExpressions; | |
public static class StringConverters | |
{ | |
public static string[] SplitCrLf(this string input) | |
{ | |
return new Regex(string.Format("{0}?{1}", ControlChars.CarriageReturn, ControlChars.LineFeed)).Split(input); |
This file contains 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; | |
public static class DateTimeConverters | |
{ | |
public static DateTime CombineDateAndTime(DateTime dateValue, DateTime timeValue) | |
{ | |
return new DateTime(dateValue.Year, dateValue.Month, dateValue.Day, timeValue.Hour, timeValue.Minute, timeValue.Second); | |
} | |
} |
This file contains 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; | |
public static class DateTimeConverters | |
{ | |
public static long ToJavaScript(this DateTime value) | |
{ | |
var epoch = new TimeSpan(new DateTime(1970, 1, 1, 0, 0, 0, 0).Ticks); | |
DateTime time = value.Subtract(epoch); | |
return (time.Ticks / 10000); | |
} |
OlderNewer