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 | |
{ | |
[MobileRedirect] | |
public IActionResult Index() | |
{ | |
return View(); | |
} | |
public IActionResult OnlyDesktop() | |
{ |
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
[Area("Mobile")] | |
[DesktopRedirect] | |
public class HomeController : Controller | |
{ | |
public IActionResult Index() | |
{ | |
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
using Microsoft.AspNetCore.Mvc.Filters; | |
using Wangkanai.Detection.Services; | |
namespace Mobile_Redirection_Subfolder | |
{ | |
public class MobileRedirectAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
var path = filterContext.HttpContext.Request.Path.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
using Microsoft.AspNetCore.Mvc.Filters; | |
using Wangkanai.Detection.Services; | |
namespace Mobile_Redirection_Subfolder | |
{ | |
public class DesktopRedirectAttribute : ActionFilterAttribute | |
{ | |
public override void OnActionExecuting(ActionExecutingContext filterContext) | |
{ | |
var path = filterContext.HttpContext.Request.Path.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
public class Startup | |
{ | |
public Startup(IConfiguration configuration) | |
{ | |
Configuration = configuration; | |
} | |
public IConfiguration Configuration { get; } | |
// This method gets called by the runtime. Use this method to add services to the container. |
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 symKey = Symbol(); | |
var obj = { | |
[symKey]: 'symbol val', | |
a: 'val1', | |
b: 'val2', | |
}; | |
console.log(obj); | |
//{ a: 'val1', b: 'val2', [Symbol()]: 'symbol val' } |
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
//ES5 | |
var PersonES5 = function(name) { | |
this.name = name; | |
this.walk(); | |
}; | |
PersonES5.prototype.walk = function () { | |
return 'pata pata'; | |
}; |
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
//ES5 | |
// lib/math.js | |
LibMath = {}; | |
LibMath.sum = function (x, y) { | |
return x + y; | |
}; | |
LibMath.pi = 3.141593; | |
// someApp.js | |
var math = LibMath; |
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
//ES5 | |
var obj = { a: 1 }; | |
var list = [1]; | |
var a = obj.a; | |
var b = obj.b === undefined ? 2 : obj.b; | |
var x = list[0]; | |
var y = list[1] === undefined ? 2 : list[1]; | |
console.log(a, b, x, y); | |
//output | |
//1 2 1 2 |
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 obj = function fn1() { | |
return { x: 'val1', y: 12, z: 'val2' }; | |
}; | |
//ES5 | |
var resES5 = obj(); | |
var x = resES5.x; | |
var y = resES5.y; | |
var z = resES5.z; | |
console.log(x, y, z); | |
//output |
NewerOlder