public void ConfigureShowTypingMiddleWare(BotAdapter adapter, BotSettings settings) { if (settings.Feature.UseShowTypingMiddleware) { adapter.Use(new ShowTypingMiddleware()); } }
public void ConfigureInspectionMiddleWare(BotAdapter adapter, BotSettings settings, IStorage storage) { if (settings.Feature.UseInspectionMiddleware) { adapter.Use(new InspectionMiddleware(new InspectionState(storage))); } }
/// <summary> /// Enable Debug Adapter Protocol for the running adapter. /// </summary> /// <param name="botAdapter">The <see cref="BotAdapter"/> to enable.</param> /// <param name="port">port to listen on.</param> /// <param name="sourceMap">ISourceMap to use (default will be SourceMap()).</param> /// <param name="breakpoints">IBreakpoints to use (default will be SourceMap()).</param> /// <param name="terminate">Termination function (Default is Environment.Exit().</param> /// <param name="events">IEvents to use (Default is Events).</param> /// <param name="codeModel">ICodeModel to use (default is internal implementation).</param> /// <param name="dataModel">IDataModel to use (default is internal implementation).</param> /// <param name="logger">ILogger to use (Default is NullLogger).</param> /// <returns>The <see cref="BotAdapter"/>.</returns> public static BotAdapter UseDebugger( this BotAdapter botAdapter, int port, ISourceMap sourceMap = null, IBreakpoints breakpoints = null, Action terminate = null, IEvents events = null, ICodeModel codeModel = null, IDataModel dataModel = null, ILogger logger = null) { codeModel = codeModel ?? new CodeModel(); DebugSupport.SourceMap = sourceMap ?? new DebuggerSourceMap(codeModel); return(botAdapter.Use( #pragma warning disable CA2000 // Dispose objects before losing scope (excluding, the object ownership is transferred to the adapter and the adapter should dispose it) new DialogDebugAdapter( port: port, sourceMap: DebugSupport.SourceMap, breakpoints: breakpoints ?? DebugSupport.SourceMap as IBreakpoints, terminate: terminate, events: events, codeModel: codeModel, dataModel: dataModel, logger: logger))); #pragma warning restore CA2000 // Dispose objects before losing scope }
public void ConfigureTranscriptLoggerMiddleware(BotAdapter adapter, BotSettings settings) { if (ConfigSectionValid(settings.BlobStorage.ConnectionString) && ConfigSectionValid(settings.BlobStorage.Container)) { adapter.Use(new TranscriptLoggerMiddleware(new AzureBlobTranscriptStore(settings.BlobStorage.ConnectionString, settings.BlobStorage.Container))); } }
/// <summary> /// Enable Debug Adapter Protocol for the running adapter. /// </summary> /// <param name="botAdapter">The <see cref="BotAdapter"/> to enable.</param> /// <param name="port">port to listen on.</param> /// <param name="sourceMap">ISourceMap to use (default will be SourceMap()).</param> /// <param name="breakpoints">IBreakpoints to use (default will be SourceMap()).</param> /// <param name="terminate">Termination function (Default is Environment.Exit().</param> /// <param name="events">IEvents to use (Default is Events).</param> /// <param name="codeModel">ICodeModel to use (default is internal implementation).</param> /// <param name="dataModel">IDataModel to use (default is internal implementation).</param> /// <param name="logger">ILogger to use (Default is NullLogger).</param> /// <param name="coercion">ICoercion to use (default is internal implementation).</param> /// <returns>The <see cref="BotAdapter"/>.</returns> public static BotAdapter UseDebugger( this BotAdapter botAdapter, int port, ISourceMap sourceMap = null, IBreakpoints breakpoints = null, Action terminate = null, IEvents events = null, ICodeModel codeModel = null, IDataModel dataModel = null, ILogger logger = null, ICoercion coercion = null) { codeModel = codeModel ?? new CodeModel(); DebugSupport.SourceMap = sourceMap ?? new DebuggerSourceMap(codeModel); return(botAdapter.Use( new DialogDebugAdapter( port: port, sourceMap: DebugSupport.SourceMap, breakpoints: breakpoints ?? DebugSupport.SourceMap as IBreakpoints, terminate: terminate, events: events, codeModel: codeModel, dataModel: dataModel, logger: logger))); }
public virtual void Inject(BotAdapter adapter) { foreach (var middleware in Middlewares) { adapter.Use(middleware); } }
/// <summary> /// Register ILanguageGenerator as default langugage generator. /// </summary> /// <param name="botAdapter">botAdapter to add services to.</param> /// <param name="resourceExplorer">resourceExporer to provide to LanguageGenerator.</param> /// <param name="languageGenerator">LanguageGenerator to use.</param> /// <returns>botAdapter.</returns> public static BotAdapter UseLanguageGeneration(this BotAdapter botAdapter, ResourceExplorer resourceExplorer, ILanguageGenerator languageGenerator) { DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); lock (languageGeneratorManagers) { if (!languageGeneratorManagers.TryGetValue(resourceExplorer ?? throw new ArgumentNullException(nameof(resourceExplorer)), out var lgm)) { lgm = new LanguageGeneratorManager(resourceExplorer); languageGeneratorManagers[resourceExplorer] = lgm; } botAdapter.Use(new RegisterClassMiddleware <LanguageGeneratorManager>(lgm)); botAdapter.Use(new RegisterClassMiddleware <ILanguageGenerator>(languageGenerator ?? throw new ArgumentNullException(nameof(languageGenerator)))); return(botAdapter); } }
/// <summary> /// Register ResourceExplorer and optionally register more types. /// </summary> /// <param name="botAdapter">BotAdapter to add middleware to.</param> /// <param name="resourceExplorer">resourceExplorer to use.</param> /// <param name="types">custom types to register.</param> /// <returns>The bot adapter.</returns> public static BotAdapter UseResourceExplorer(this BotAdapter botAdapter, ResourceExplorer resourceExplorer, IEnumerable <TypeRegistration> types = null) { if (resourceExplorer == null) { throw new ArgumentNullException(nameof(resourceExplorer)); } DeclarativeTypeLoader.AddComponent(new DialogComponentRegistration()); if (types != null) { foreach (var type in types) { TypeFactory.Register(type.Name, type.Type, type.CustomDeserializer); } } return(botAdapter.Use(new RegisterClassMiddleware <ResourceExplorer>(resourceExplorer))); }
/// <summary> /// Enable Debug Adapter Protocol for the running adapter. /// </summary> /// <param name="botAdapter">The <see cref="BotAdapter"/> to enable.</param> /// <param name="port">port to listen on.</param> /// <param name="sourceMap">ISourceMap to use (default will be SourceMap()).</param> /// <param name="terminate">Termination function (Default is Environment.Exit().</param> /// <param name="logger">ILogger to use (Default is NullLogger).</param> /// <returns>The <see cref="BotAdapter"/>.</returns> public static BotAdapter UseDebugger( this BotAdapter botAdapter, int port, ISourceMap sourceMap = null, Action terminate = null, ILogger logger = null) { DebugSupport.SourceMap = sourceMap ?? new DebuggerSourceMap(new CodeModel()); return(botAdapter.Use( #pragma warning disable CA2000 // Dispose objects before losing scope (excluding, the object ownership is transferred to the adapter and the adapter should dispose it) new DialogDebugAdapter( port, DebugSupport.SourceMap, DebugSupport.SourceMap as IBreakpoints, terminate, codeModel: new CodeModel(), logger: logger))); #pragma warning restore CA2000 // Dispose objects before losing scope }
/// <summary> /// Register MessageActivityGeneration. /// </summary> /// <param name="botAdapter">botAdapter to add services to.</param> /// <param name="messageGenerator">(OPTIONAL) Default is TextMessageActivityGenerator(). </param> /// <returns>botAdapter.</returns> public static BotAdapter UseMessageActivityGeneration(this BotAdapter botAdapter, IActivityGenerator messageGenerator = null) { DeclarativeTypeLoader.AddComponent(new LanguageGenerationComponentRegistration()); botAdapter.Use(new RegisterClassMiddleware <IActivityGenerator>(messageGenerator ?? new ActivityGenerator())); return(botAdapter); }