Skip to content

Instantly share code, notes, and snippets.

View duplicate.cs
public class Employee
{
public int Id { get; set; }
// ...
}
public class EmployeeComparer : IEqualityComparer<Employee>
{
public bool Equals(Employee x, Employee y)
{
@OdeToCode
OdeToCode / ShowEditWidgets.cshtml
Created May 24, 2018
ASP.NET Core Binding Collections
View ShowEditWidgets.cshtml
@using WebApp1.Controllers
@model IList<Widget>
@{
ViewData["Title"] = "ShowEditWidgets";
Layout = null;
}
<h2>Dump of Widgets</h2>
<table>
View index.cshtml
@{
ViewBag.Title = "Home Page";
}
Route: @Url.RouteUrl("DefaultApi", new { httproute= "", controller = "Videos" })
<div id="videoTableOutput">
View hi.cs
public void Configure(IApplicationBuilder app)
{
app.Run(SayHello);
}
public Task SayHello(HttpContext ctx)
{
return ctx.Response.WriteAsync("Hi World!!!");
}
View project.json
{
"name": "psrsjx5",
"version": "1.0.0",
"description": "",
"scripts": {
"start": "webpack-dev-server --watch --inline",
"postinstall": "typings install"
},
"dependencies": {
"rxjs": "5.0.0-beta.12"
View cdn fallback tests for asp.net core.cshtml
<environment names="Development">
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.css" />
<link rel="stylesheet" href="~/css/site.css" />
</environment>
<environment names="Staging,Production">
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link rel="stylesheet" href="~/css/site.min.css" asp-append-version="true" />
</environment>
View example.cs
using (var db = new ThingDb())
{
// just need this once for all instances to log:
var serviceProvider = db.GetInfrastructure();
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
loggerFactory.AddConsole();
}
@OdeToCode
OdeToCode / Program.cs
Created Sep 16, 2016
Some quick code to show assembly name, version, and load path in Program.cs of AspNet Core
View Program.cs
var assemblies = Assembly.GetEntryAssembly().GetReferencedAssemblies();
foreach (var assembly in assemblies)
{
Console.WriteLine($"{assembly.Version} {assembly.Name}");
var codebase = Assembly.Load(assembly).CodeBase.Replace("file:///", "");
Console.WriteLine($"\t{Path.GetDirectoryName(codebase)}");
}
View manufacturers.csv
ALFA ROMEO Italy 2016
Aston Martin Lagonda Ltd UK 2016
Audi Germany 2016
BMW Germany 2016
Chevrolet USA 2016
Dodge USA 2016
Ferrari Italy 2016
Honda Japan 2016
Jaguar UK 2016
Lamborghini Italy 2016
View fuel.csv
Model Year Division Carline Eng Displ # Cyl City FE Hwy FE Comb FE
2016 ALFA ROMEO 4C 1.8 4 24 34 28
2016 Aston Martin Lagonda Ltd V12 Vantage S 6.0 12 12 18 14
2016 Aston Martin Lagonda Ltd V8 Vantage 4.7 8 14 21 16
2016 Aston Martin Lagonda Ltd V8 Vantage 4.7 8 13 19 15
2016 Aston Martin Lagonda Ltd V8 Vantage S 4.7 8 14 21 16
2016 Aston Martin Lagonda Ltd V8 Vantage S 4.7 8 13 19 15
2016 Aston Martin Lagonda Ltd Vantage GT 4.7 8 14 21 16
2016 Aston Martin Lagonda Ltd Vantage GT 4.7 8 13 19 15
2016 Audi TT Roadster quattro 2.0 4 23 30 26