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 PropertyHelper | |
{ | |
/// <summary> | |
/// Looks up the DisplayName attribute on the property defined by the expression. If the type | |
/// of the expression is generic (e.g. IEnumerable of T) we will look up the inner type instead. | |
/// </summary> | |
public static string GetDisplayName<TModel, T>(Expression<Func<TModel, T>> property) | |
{ | |
var fieldName = ExpressionHelper.GetExpressionText(property); |
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 partial class EnumerableExt | |
{ | |
public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action) | |
{ | |
foreach (T item in enumeration) | |
{ | |
action(item); | |
} | |
} | |
} |
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 ControllerExt | |
{ | |
public static bool TryValidateAndTranslate(this Controller controller, object model, string prefix, object propertyMap) | |
{ | |
return TryValidateAndTranslate(controller, model, prefix, new RouteValueDictionary(propertyMap)); | |
} | |
public static bool TryValidateAndTranslate(this Controller controller, object model, string prefix, RouteValueDictionary propertyMap) | |
{ | |
ModelMetadata metadata = ModelMetadataProviders |
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 Conversion | |
{ | |
public static DataTable ToDataTable<T>(this IList<T> list , string tableName) | |
{ | |
var dataTable = new DataTable(tableName); | |
var properties = TypeDescriptor.GetProperties(typeof(T)) | |
.Cast<PropertyDescriptor>() | |
.Where(p => p.PropertyType.Namespace.Equals("System")) | |
.ToArray(); | |
var values = new object[properties.Length]; |
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
.expander { | |
-webkit-transition: all cubic-bezier(0.250, 0.460, 0.450, 0.940) .5s; | |
-moz-transition: all cubic-bezier(0.250, 0.460, 0.450, 0.940) .5s; | |
-o-transition: all cubic-bezier(0.250, 0.460, 0.450, 0.940) .5s; | |
transition: all cubic-bezier(0.250, 0.460, 0.450, 0.940) .5s; | |
height: 100px; | |
} | |
.expander.ng-hide { | |
height: 0px; |
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 class AzureTraceAppender : TraceAppender | |
{ | |
protected override void Append(LoggingEvent loggingEvent) | |
{ | |
var level = loggingEvent.Level; | |
var message = RenderLoggingEvent(loggingEvent); | |
if (level >= Level.Error) | |
Trace.TraceError(message); | |
else if (level >= Level.Warn) | |
Trace.TraceWarning(message); |
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
if (Array.prototype.contains){ | |
throw "Array.contains already exists"; | |
} | |
Array.prototype.contains = function(item) { | |
for (var i = 0; i < this.length; i++) { | |
if (this[i] === item) | |
return true; | |
} |
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
var obj = { | |
car: 300, | |
bike: 60, | |
motorbike: 200, | |
airplane: 1000, | |
helicopter: 400, | |
rocket: 8 * 60 * 60 | |
}; | |
var sortable = []; |
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
void Main() | |
{ | |
var xml = XElement.Load (@"C:\\Temp\\ModelWheelSize.xml"); | |
var parent = xml.Descendants("ModelWheelSize") | |
.Where(e => e.Element("ModelID").Value == "747") | |
.Dump(); | |
} |
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
Array.prototype.removeByKey = function (key, value) { | |
var i = this.length; | |
while(i--){ | |
if (this[i][key] === value) { | |
return this.splice(i, 1); | |
} | |
} | |
return null; | |
}; |