-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c6b4f69
commit 094213e
Showing
22 changed files
with
1,615 additions
and
4 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
CSharp/Bot.Connector.AspNetCore.Package/Bot.Connector.AspNetCore.Package.nuproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|AnyCPU"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>AnyCPU</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|AnyCPU"> | ||
<Configuration>Release</Configuration> | ||
<Platform>AnyCPU</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>50f1a769-433e-4668-bb36-514a5a52da94</ProjectGuid> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<NuProjPath Condition=" '$(NuProjPath)' == '' ">$(MSBuildExtensionsPath)\NuProj\</NuProjPath> | ||
</PropertyGroup> | ||
<Import Project="$(NuProjPath)\NuProj.props" Condition="Exists('$(NuProjPath)\NuProj.props')" /> | ||
<PropertyGroup Label="Configuration"> | ||
<Id>Bot.Connector.AspNetCore.Package</Id> | ||
<Version>1.0.0</Version> | ||
<Title>Bot.Connector.AspNetCore.Package</Title> | ||
<Authors>cement</Authors> | ||
<Owners>cement</Owners> | ||
<Summary>Bot.Connector.AspNetCore.Package</Summary> | ||
<Description>Bot.Connector.AspNetCore.Package</Description> | ||
<ReleaseNotes> | ||
</ReleaseNotes> | ||
<ProjectUrl> | ||
</ProjectUrl> | ||
<LicenseUrl> | ||
</LicenseUrl> | ||
<Copyright>Copyright © cement</Copyright> | ||
<Tags>Bot.Connector.AspNetCore.Package</Tags> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Content Include="Readme.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Library\Microsoft.Bot.Connector.Abstractions\Microsoft.Bot.Connector.Abstractions.csproj" /> | ||
<ProjectReference Include="..\Library\Microsoft.Bot.Connector.AspNetCore\Microsoft.Bot.Connector.AspNetCore.csproj" /> | ||
</ItemGroup> | ||
<Import Project="$(NuProjPath)\NuProj.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is your NuGet package. |
45 changes: 45 additions & 0 deletions
45
CSharp/Builder.Autofac.Package/Builder.Autofac.Package.nuproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<ItemGroup Label="ProjectConfigurations"> | ||
<ProjectConfiguration Include="Debug|AnyCPU"> | ||
<Configuration>Debug</Configuration> | ||
<Platform>AnyCPU</Platform> | ||
</ProjectConfiguration> | ||
<ProjectConfiguration Include="Release|AnyCPU"> | ||
<Configuration>Release</Configuration> | ||
<Platform>AnyCPU</Platform> | ||
</ProjectConfiguration> | ||
</ItemGroup> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>c1fe5500-356c-47f2-92a7-ccec2a87b773</ProjectGuid> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<NuProjPath Condition=" '$(NuProjPath)' == '' ">$(MSBuildExtensionsPath)\NuProj\</NuProjPath> | ||
</PropertyGroup> | ||
<Import Project="$(NuProjPath)\NuProj.props" Condition="Exists('$(NuProjPath)\NuProj.props')" /> | ||
<PropertyGroup Label="Configuration"> | ||
<Id>Builder.Autofac.Package</Id> | ||
<Version>1.0.0</Version> | ||
<Title>Builder.Autofac.Package</Title> | ||
<Authors>cement</Authors> | ||
<Owners>cement</Owners> | ||
<Summary>Builder.Autofac.Package</Summary> | ||
<Description>Builder.Autofac.Package</Description> | ||
<ReleaseNotes> | ||
</ReleaseNotes> | ||
<ProjectUrl> | ||
</ProjectUrl> | ||
<LicenseUrl> | ||
</LicenseUrl> | ||
<Copyright>Copyright © cement</Copyright> | ||
<Tags>Builder.Autofac.Package</Tags> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Content Include="Readme.txt" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Library\Microsoft.Bot.Builder.Autofac\Microsoft.Bot.Builder.Autofac.csproj" /> | ||
<ProjectReference Include="..\Library\Microsoft.Bot.Builder\Microsoft.Bot.Builder.csproj" /> | ||
</ItemGroup> | ||
<Import Project="$(NuProjPath)\NuProj.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This is your NuGet package. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
89 changes: 89 additions & 0 deletions
89
CSharp/Samples/Microsoft.Bot.Sample.AspNetCore.Pizza/Controllers/MessagesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
using System.Threading.Tasks; | ||
|
||
using Microsoft.Bot.Connector; | ||
using Microsoft.Bot.Builder.FormFlow; | ||
using Microsoft.Bot.Builder.Dialogs; | ||
using System.Diagnostics; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Authorization; | ||
using Microsoft.Extensions.Configuration; | ||
using System; | ||
|
||
namespace Microsoft.Bot.Sample.AspNetCore.Pizza | ||
{ | ||
[Route("api/[controller]")] | ||
public class MessagesController : Controller | ||
{ | ||
private static IForm<PizzaOrder> BuildForm() | ||
{ | ||
var builder = new FormBuilder<PizzaOrder>(); | ||
|
||
ActiveDelegate<PizzaOrder> isBYO = (pizza) => pizza.Kind == PizzaOptions.BYOPizza; | ||
ActiveDelegate<PizzaOrder> isSignature = (pizza) => pizza.Kind == PizzaOptions.SignaturePizza; | ||
ActiveDelegate<PizzaOrder> isGourmet = (pizza) => pizza.Kind == PizzaOptions.GourmetDelitePizza; | ||
ActiveDelegate<PizzaOrder> isStuffed = (pizza) => pizza.Kind == PizzaOptions.StuffedPizza; | ||
|
||
return builder | ||
// .Field(nameof(PizzaOrder.Choice)) | ||
.Field(nameof(PizzaOrder.Size)) | ||
.Field(nameof(PizzaOrder.Kind)) | ||
.Field("BYO.Crust", isBYO) | ||
.Field("BYO.Sauce", isBYO) | ||
.Field("BYO.Toppings", isBYO) | ||
.Field(nameof(PizzaOrder.GourmetDelite), isGourmet) | ||
.Field(nameof(PizzaOrder.Signature), isSignature) | ||
.Field(nameof(PizzaOrder.Stuffed), isStuffed) | ||
.AddRemainingFields() | ||
.Confirm("Would you like a {Size}, {BYO.Crust} crust, {BYO.Sauce}, {BYO.Toppings} pizza?", isBYO) | ||
.Confirm("Would you like a {Size}, {&Signature} {Signature} pizza?", isSignature, dependencies: new string[] { "Size", "Kind", "Signature" }) | ||
.Confirm("Would you like a {Size}, {&GourmetDelite} {GourmetDelite} pizza?", isGourmet) | ||
.Confirm("Would you like a {Size}, {&Stuffed} {Stuffed} pizza?", isStuffed) | ||
.Build() | ||
; | ||
} | ||
|
||
internal static IDialog<PizzaOrder> MakeRoot() | ||
{ | ||
return Chain.From(() => new PizzaOrderDialog(BuildForm)); | ||
} | ||
|
||
private readonly IConfigurationRoot configuration; | ||
|
||
public MessagesController(IConfigurationRoot configuration) | ||
{ | ||
this.configuration = configuration; | ||
} | ||
|
||
[Authorize(Roles = "Bot")] | ||
// POST api/values | ||
[HttpPost] | ||
public virtual async Task<OkResult> Post([FromBody]Activity activity) | ||
{ | ||
var appCredentials = new MicrosoftAppCredentials(this.configuration); | ||
var client = new ConnectorClient(new Uri(activity.ServiceUrl), appCredentials); | ||
var reply = activity.CreateReply(); | ||
|
||
if (activity != null) | ||
{ | ||
// one of these will have an interface and process it | ||
switch (activity.GetActivityType()) | ||
{ | ||
case ActivityTypes.Message: | ||
await Conversation.SendAsync(activity, MakeRoot); | ||
break; | ||
|
||
case ActivityTypes.ConversationUpdate: | ||
case ActivityTypes.ContactRelationUpdate: | ||
case ActivityTypes.Typing: | ||
case ActivityTypes.DeleteUserData: | ||
default: | ||
Trace.TraceError($"Unknown activity type ignored: {activity.GetActivityType()}"); | ||
break; | ||
} | ||
} | ||
|
||
await client.Conversations.ReplyToActivityAsync(reply); | ||
return Ok(); | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...Samples/Microsoft.Bot.Sample.AspNetCore.Pizza/Microsoft.Bot.Sample.AspNetCore.Pizza.xproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion> | ||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.Props" Condition="'$(VSToolsPath)' != ''" /> | ||
<PropertyGroup Label="Globals"> | ||
<ProjectGuid>6ef6048d-91ca-43fa-96f3-2c7939c40ed9</ProjectGuid> | ||
<RootNamespace>WebApplication5</RootNamespace> | ||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">.\obj</BaseIntermediateOutputPath> | ||
<OutputPath Condition="'$(OutputPath)'=='' ">.\bin\</OutputPath> | ||
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<SchemaVersion>2.0</SchemaVersion> | ||
</PropertyGroup> | ||
<Import Project="$(VSToolsPath)\DotNet.Web\Microsoft.DotNet.Web.targets" Condition="'$(VSToolsPath)' != ''" /> | ||
</Project> |
Oops, something went wrong.