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
#Controller | |
def HomeController < ApplicationController | |
def index | |
gon.myVar = 100 | |
end | |
end | |
#home.html.erb |
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 void Application_Start() | |
{ | |
AreaRegistration.RegisterAllAreas(); | |
GlobalFilters.Filters.Add(new NGonActionFilterAttribute()); | |
RegisterGlobalFilters(GlobalFilters.Filters); | |
RegisterRoutes(RouteTable.Routes); | |
} |
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 class HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
ViewBag.NGon.SomeValue = 100; | |
return View(); | |
} | |
} |
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
<script type="text/javascript"> | |
$(function () { | |
$("#button").click(function () { | |
alert(ngon.SomeValue); | |
}); | |
}); </script> |
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 class HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
var person = new Person { FirstName = "John", LastName = "Doe", Age = 30 }; | |
ViewBag.NGon.Person = person; | |
return View(); | |
} | |
} |
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
<script type="text/javascript"> | |
$(function () { | |
$("#button").click(function () { | |
var person = ngon.Person; | |
var div = $("#output"); | |
div.html(''); | |
div.append("FirstName: " + person.FirstName); | |
div.append(", LastName: " + person.LastName); | |
div.append(", Age: " + person.Age); | |
}); |
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 class NGonActionFilterAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
filterContext.Controller.ViewBag.NGon = new ExpandoObject(); | |
base.OnActionExecuting(filterContext); | |
} | |
} |
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 class HtmlHelperExtensions | |
{ | |
public static IHtmlString IncludeNGon(this HtmlHelper helper, string @namespace = "ngon") | |
{ | |
var viewData = helper.ViewContext.ViewData; | |
if (viewData == null) | |
{ | |
return MvcHtmlString.Empty; | |
} |
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
<script type="text/javascript">window.ngon={};ngon.Person={"FirstName":"John","LastName":"Doe","Age":30};</script> |
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 class RandomStreamGenerator | |
{ | |
private static Random _random = new Random(); | |
public static void GenerateIndefinitley<T>(Func<T> func, Action<T> onNext) | |
{ | |
GenerateIndefinitley(func, 100, 1000, onNext); | |
} | |
public static void GenerateIndefinitley<T>(Func<T> func, int minMilliseconds, int maxMilliseconds, Action<T> onNext) |
OlderNewer