View running_aspnetcore_server_port_at_command_line
# Unix:
ASPNETCORE_URLS="https://*:5123" dotnet run
# Windows PowerShell:
$env:ASPNETCORE_URLS="https://*:5123" ; dotnet run
# Windows CMD (note: no quotes):
SET ASPNETCORE_URLS=https://*:5123 && dotnet run
View static_c_types_c#.cs
// User defined type
int myUserDefinedTypeNumber = 1;
string myUserDefinedTypeString = "Hello";
bool myUserDefinedTypeBool = true;
// Compiler defined type
var myCompilerDefinedTypeNumber = 1;
var myCompilerDefinedTypeString = "Hello";
var myCompilerDefinedTypeBool = true;
View using_example_c#_forensics.cs
using (var file = File.OpenRead(CARD_ROOT_PATH + "card.raw"))
{
// Code which uses the file object
}
View asp_core_project_ignore_node_modules.json
{
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"compile": {
"exclude": [ "node_modules" ]
}
},
"tools": {
"SomeToolsRemovedForBrevity": true
View cascade_delete_efcore_example.cs
using Microsoft.Data.Entity;
using Microsoft.Data.Entity.Metadata;
public class MyDBContext : DBContext
{
public DbSet<Blog> Blog { get; set; }
public DbSet<Post> Posts { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
View panel_bs3_example.html
<!-- http://getbootstrap.com/components/#panels -->
<div class="row">
<div class="col-md-2">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Panel title</h3>
</div>
<div class="panel-body">
Panel content
</div>
View .gitconfig
# Colour settings best suited to a terminal with a dark background
[color "status"]
added = white green bold
changed = yellow reverse
untracked = white red bold
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
View startup_class_configureservices_example.cs
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddApplicationInsightsTelemetry(Configuration);
services.AddMvc();
// Add SQLite DB using EF Core
var path = PlatformServices.Default.Application.ApplicationBasePath;
var connection = $"Filename={Path.Combine(path, "mydb.db")}";
View ef7_sqlite_project.json
{
"dependencies": {
"EntityFramework.Sqlite": "7.0.0-rc1-final",
"EntityFramework.Commands": "7.0.0-rc1-final",
"Microsoft.Extensions.PlatformAbstractions": "1.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --server.urls=http://*:9000/",
"ef": "EntityFramework.Commands"
}
View ef_7_error_db_context.cs
using Microsoft.Data.Entity;
namespace CodingMonkey.Models
{
public class CodingMonkeyContext : DbContext
{
public DbSet<Exercise> Exercises { get; set; }
public DbSet<ExerciseTemplate> ExerciseTemplates { get; set; }
public DbSet<ExerciseCategory> ExerciseCategories { get; set; }
public DbSet<Test> Tests { get; set; }