Skip to content

Instantly share code, notes, and snippets.

@sfmskywalker
sfmskywalker / Startup.cs
Last active July 21, 2018 19:41
Startup with custom configuration
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Environment.Shell;
namespace MultiTenantApp
{
@sfmskywalker
sfmskywalker / tenants.json
Created June 27, 2018 10:30
Tenants with custom settings
{
"CustomerA": {
"State": "Running",
"RequestUrlHost": null,
"RequestUrlPrefix": "customer-a",
"CustomSetting": "Custom setting for Customer A"
},
"CustomerB": {
"State": "Running",
"RequestUrlHost": null,
@sfmskywalker
sfmskywalker / Startup.cs
Created June 27, 2018 10:51
Partial Startup
app.UseOrchardCore(a => a.Run(async context =>
{
// ShellSettings provide the tenant's configuration.
var shellSettings = context.RequestServices.GetRequiredService<ShellSettings>();
// Read the tenant-specific custom setting.
var customSetting = shellSettings.Configuration["CustomSetting"];
// Resolve all registered IMessageProvider services.
var messageProviders = context.RequestServices.GetServices<IMessageProvider>();
public class AuthenticatingHandler<T> : DelegatingHandler where T : ISecurityTokenAccessor
{
private readonly Policy<HttpResponseMessage> _policy;
private readonly T _securityTokenAccessor;
private IAccessToken _accessToken;
private AuthenticationHeaderValue _authenticationHeader;
public AuthenticatingHandler(T securityTokenAccessor)
{
_securityTokenAccessor = securityTokenAccessor;
@sfmskywalker
sfmskywalker / Startup.cs
Created July 29, 2018 18:56
Startup.cs
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
namespace AngularWidgetsDemo
{
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
@sfmskywalker
sfmskywalker / NewProject.cmd
Last active July 29, 2018 20:25
Create new ASP.NET Core Orchard Core Project
dotnet new web --name "AngularWidgetsDemo"
cd "AngularWidgetsDemo"
dotnet add package "OrchardCore.Application.Cms.Targets" --version 1.0.0-beta2-*
npm i -g @angular/cli
ng new ClientApp --prefix custom
@sfmskywalker
sfmskywalker / IncludeElements.cmd
Last active July 29, 2018 19:16
Add Angular Elements & Polyfill
cd ClientApp
ng add @angular/elements
@sfmskywalker
sfmskywalker / DownloadAngularElementSample.ps1
Last active July 29, 2018 20:04
Downloads and extracts a sample Angular Custom Element from GitHub
Add-Type -AssemblyName System.IO.Compression.FileSystem
Invoke-WebRequest -Uri https://github.com/nitayneeman/made-with-love/archive/release/v1.1.0.zip -OutFile ./ClientApp.zip
[System.IO.Compression.ZipFile]::ExtractToDirectory("c:\Code\Orchard Core and Angular\AngularWidgetsDemo\ClientApp.zip", "c:\Code\Orchard Core and Angular\AngularWidgetsDemo")
Rename-Item made-with-love-master ClientApp
@sfmskywalker
sfmskywalker / npm-install.cmd
Last active July 29, 2018 20:04
Executes the NPM Install command
cd ClientApp
npm install
ng build