Skip to content

Instantly share code, notes, and snippets.

View boydc2014's full-sized avatar
🎯
Focusing

Dong Lei boydc2014

🎯
Focusing
View GitHub Profile
@boydc2014
boydc2014 / ChannelDataMiddleware.cs
Created March 11, 2021 11:21
Sample BF Middleware attaching channelData to activities
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Bot.Builder;
namespace Microsoft.BotFramework.Composer.WebApp.Middlewares
{
public class ChannelDataMiddleware : IMiddleware
{
public async Task OnTurnAsync(ITurnContext turnContext, NextDelegate next, CancellationToken cancellationToken = default)
{
@boydc2014
boydc2014 / FullPropertySystem.ts
Last active December 7, 2018 06:38
show everything need currently
interface StatePropertyAccessor {
get(context):any
}
// this user state implements many interfaces
class UserState implements StatePropertyAccessor {
constructor(public data?:Object, public _parent?:UserState, public _name?:string) {
if (data == null)
@boydc2014
boydc2014 / MinimalPropertyChangeTracker.ts
Last active December 6, 2018 12:10
Show a more simple and native way to create a event system for change tracking, notification, validation ... etc
// this state is just a simple observer
class State {
constructor(public data: object) {
this.walk(data);
}
walk = (obj: Object) => {
this.data = obj;
for (let k in obj)