Skip to content

Instantly share code, notes, and snippets.

View HomeController.cs
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
namespace IHostingEnvironmentExample.Controllers
{
public class HomeController : Controller
{
private IHostingEnvironment _env;
public HomeController(IHostingEnvironment env)
{
View Program.cs
using Microsoft.AspNetCore.Hosting;
using System.IO;
namespace IHostingEnvironmentExample
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
View DatabaseFileInfo.cs
using Microsoft.Extensions.FileProviders;
using System;
using System.Data.SqlClient;
using System.IO;
using System.Text;
namespace RazorEngineViewOptionsFileProviders
{
public class DatabaseFileInfo : IFileInfo
{
View DatabaseChangeToken.cs
using Microsoft.Extensions.Primitives;
using System;
using System.Data.SqlClient;
namespace RazorEngineViewOptionsFileProviders
{
public class DatabaseChangeToken : IChangeToken
{
private string _connection;
private string _viewPath;
View tsconfig.json
{
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"target": "es5"
},
"exclude": [
"node_modules",
View tsconfig.json
{
"compileOnSave": true,
"compilerOptions": {
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"sourceMap": true,
"module": "amd",
"target": "es5"
}
View webmail.json
{
"folders": [
{
"id": "Inbox",
"mails": [
{
"id": 1,
"from": "Abbot \u003coliver@smoke-stage.xyz\u003e",
"to": "steve@example.com",
"date": "May 25, 2011",
View webmail.css
.folders {
background-color: #bbb;
list-style-type: none;
padding: 0;
margin: 0;
border-radius: 7px;
background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #d6d6d6), color-stop(0.4, #c0c0c0), color-stop(1,#a4a4a4));
margin: 10px 0 16px 0;
font-size: 0px;
}
View webmail.cshtml
@page
@model WebMailModel
@{
ViewData["Title"] = "WebMail";
}
<h2>WebMail</h2>
<ul class="folders" data-bind="foreach: folders">
<li data-bind="text: $data,
css: { selected: $data == $root.chosenFolderId() },
View webmail.js
function WebmailViewModel() {
// Data
var self = this;
self.folders = ['Inbox', 'Archive', 'Sent', 'Spam'];
self.chosenFolderId = ko.observable();
self.chosenFolderData = ko.observable();
self.chosenMailData = ko.observable();
// Behaviours
self.goToFolder = function(folder) {