Skip to content

Instantly share code, notes, and snippets.

View Maarten88's full-sized avatar

Maarten Sikkema Maarten88

View GitHub Profile
@Maarten88
Maarten88 / BotAuthenticationBuilderExtensions.cs
Last active September 8, 2017 14:30
Microsoft Bot Framework Bot Authentication migrated to dotnet core 2.0
using System;
using Microsoft.Bot.Connector;
namespace Microsoft.Extensions.DependencyInjection
{
/// <summary>
/// Extension methods to add BotAuthentication capabilities to an HTTP application pipeline.
/// </summary>
public static class BotAuthenticationAppBuilderExtensions
{
using System;
using System.Threading.Tasks;
using Orleans;
using GrainInterfaces;
using Orleans.Concurrency;
namespace Grains
{
public class CacheGrain<T>: Grain, ICacheGrain<T>
{
.Configure(app =>
{
app.UseCompressedStaticFiles();
}
const CompressionPlugin = require("compression-webpack-plugin");
[...]
plugins: [
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$/,
threshold: 10240,
[...]
export default createServerRenderer(params => {
return new Promise<RenderResult>((resolve, reject) => {
// Match the incoming request against the list of client-side routes
match({ routes, location: params.location }, (error, redirectLocation, renderProps: any) => {
[...]
// Build an instance of the application
const store = configureStore();
@{
ViewData["Title"] = "Home Page";
dynamic data = new { sessionId = ViewBag.SessionId, accessToken = ViewBag.AccessToken, xsrfToken = ViewBag.AntiForgeryRequestToken, isAuthenticated = this.User.Identity.IsAuthenticated, userModel = ViewBag.UserModel };
}
@* Save the request token in a div. CORS needs to make sure this token can't be read by javascript from other sources than ours *@
<div id="xsrf-token" data-xsrf-token="@ViewBag.AntiForgeryRequestToken"></div>
<div id="access-token" data-access-token="@ViewBag.accessToken"></div>
<environment names="Development">
import * as React from 'react';
import { Link } from 'react-router';
import { connect } from 'react-redux';
import { ApplicationState } from '../store';
import { Navbar, Nav, NavItem, NavDropdown, MenuItem } from 'react-bootstrap';
import { LinkContainer } from 'react-router-bootstrap';
const logo = require('../images/logo.svg') as string;
interface NavMenuProps {
var host = new WebHostBuilder()
[...]
.ConfigureServices(services =>
{
[...]
services.AddNodeServices(options => {
if ("development".Equals(environment, StringComparison.OrdinalIgnoreCase))
{
options.LaunchWithDebugging = true;
public async Task StartCounterTimer()
{
if (this.timer != null)
throw new Exception("Can't start: already started");
await this.Dispatch(new StartCounterAction());
await this.WriteStateAsync();
this.timer = this.RegisterTimer(async (state) => {
var action = new IncrementCounterAction();
public class CounterGrain : ReduxGrain<CounterState>, ICounterGrain
{
IDisposable storeSubscription;
IAsyncStream<IAction> actionsToClientStream;
public CounterGrain(ReduxTableStorage<CounterState> storage) : base(CounterState.Reducer, storage)
{
}
public override async Task OnActivateAsync()