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
protected string RenderRazorViewToString(string viewName, object model) | |
{ | |
ViewData.Model = model; | |
using (var sw = new StringWriter()) | |
{ | |
var viewResult = ViewEngines.Engines.FindPartialView(ControllerContext, viewName); | |
var viewContext = new ViewContext(ControllerContext, viewResult.View, ViewData, TempData, sw); | |
viewResult.View.Render(viewContext, sw); | |
viewResult.ViewEngine.ReleaseView(ControllerContext, viewResult.View); | |
return sw.GetStringBuilder().ToString(); |
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
void Main() | |
{ | |
new Foo().DoSomething(); | |
} | |
// Define other methods and classes here | |
class Foo | |
{ | |
public Foo() | |
{ |
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
var client = new WebClient(); | |
var content = client.DownloadString("http://example.com"); |
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 static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action) | |
{ | |
foreach(T item in enumeration) | |
{ | |
action(item); | |
} | |
} |
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
/// <summary> | |
/// Overload of the Set method of entity framework | |
/// </summary> | |
/// <typeparam name="T"></typeparam> | |
/// <returns></returns> | |
public IDbSet<T> Set<T>() where T : class | |
{ | |
var correspondingDbSets = this.GetType().GetProperties().Where(a => a.PropertyType == typeof(IDbSet<T>)); | |
if (correspondingDbSets.Count() == 1) |