From 74110e8267b96462970177670aefe928b6d33372 Mon Sep 17 00:00:00 2001 From: Tom Laird-McConnell Date: Fri, 3 Feb 2017 12:44:46 -0800 Subject: [PATCH] create .net library for schema --- .gitattributes | 63 +++++++ AdaptiveCardToolkit.sln | 19 +- builders/.NET/Adaptive.NET.sln | 22 +++ .../Adaptive.Schema.Net.csproj | 76 ++++++++ .../.NET/Adaptive.Schema.Net/AdaptiveCard.cs | 20 +++ .../.NET/Adaptive.Schema.Net/CardElement.cs | 35 ++++ builders/.NET/Adaptive.Schema.Net/Choice.cs | 33 ++++ builders/.NET/Adaptive.Schema.Net/Column.cs | 19 ++ .../.NET/Adaptive.Schema.Net/ColumnGroup.cs | 19 ++ .../.NET/Adaptive.Schema.Net/Container.cs | 31 ++++ .../.NET/Adaptive.Schema.Net/DateInput.cs | 24 +++ builders/.NET/Adaptive.Schema.Net/Enums.cs | 170 ++++++++++++++++++ builders/.NET/Adaptive.Schema.Net/Fact.cs | 36 ++++ .../.NET/Adaptive.Schema.Net/FactGroup.cs | 23 +++ builders/.NET/Adaptive.Schema.Net/Image.cs | 27 +++ .../.NET/Adaptive.Schema.Net/ImageGallery.cs | 30 ++++ builders/.NET/Adaptive.Schema.Net/Input.cs | 23 +++ .../Adaptive.Schema.Net/MultichoiceInput.cs | 18 ++ .../Properties/AssemblyInfo.cs | 30 ++++ .../.NET/Adaptive.Schema.Net/Seperator.cs | 15 ++ .../.NET/Adaptive.Schema.Net/TextBlock.cs | 31 ++++ .../.NET/Adaptive.Schema.Net/TextInput.cs | 20 +++ .../.NET/Adaptive.Schema.Net/ToggleInput.cs | 16 ++ .../.NET/Adaptive.Schema.Net/TypedElement.cs | 24 +++ .../TypedElementConverter.cs | 51 ++++++ .../.NET/Adaptive.Schema.Net/packages.config | 4 + docs/Schema.md | 5 +- package.json | 2 +- 28 files changed, 876 insertions(+), 10 deletions(-) create mode 100644 .gitattributes create mode 100644 builders/.NET/Adaptive.NET.sln create mode 100644 builders/.NET/Adaptive.Schema.Net/Adaptive.Schema.Net.csproj create mode 100644 builders/.NET/Adaptive.Schema.Net/AdaptiveCard.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/CardElement.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Choice.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Column.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/ColumnGroup.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Container.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/DateInput.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Enums.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Fact.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/FactGroup.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Image.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/ImageGallery.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Input.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/MultichoiceInput.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Properties/AssemblyInfo.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/Seperator.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/TextBlock.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/TextInput.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/ToggleInput.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/TypedElement.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/TypedElementConverter.cs create mode 100644 builders/.NET/Adaptive.Schema.Net/packages.config diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000000..1ff0c42304 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,63 @@ +############################################################################### +# Set default behavior to automatically normalize line endings. +############################################################################### +* text=auto + +############################################################################### +# Set default behavior for command prompt diff. +# +# This is need for earlier builds of msysgit that does not have it on by +# default for csharp files. +# Note: This is only used by command line +############################################################################### +#*.cs diff=csharp + +############################################################################### +# Set the merge driver for project and solution files +# +# Merging from the command prompt will add diff markers to the files if there +# are conflicts (Merging from VS is not affected by the settings below, in VS +# the diff markers are never inserted). Diff markers may cause the following +# file extensions to fail to load in VS. An alternative would be to treat +# these files as binary and thus will always conflict and require user +# intervention with every merge. To do so, just uncomment the entries below +############################################################################### +#*.sln merge=binary +#*.csproj merge=binary +#*.vbproj merge=binary +#*.vcxproj merge=binary +#*.vcproj merge=binary +#*.dbproj merge=binary +#*.fsproj merge=binary +#*.lsproj merge=binary +#*.wixproj merge=binary +#*.modelproj merge=binary +#*.sqlproj merge=binary +#*.wwaproj merge=binary + +############################################################################### +# behavior for image files +# +# image files are treated as binary by default. +############################################################################### +#*.jpg binary +#*.png binary +#*.gif binary + +############################################################################### +# diff behavior for common document formats +# +# Convert binary document formats to text before diffing them. This feature +# is only available from the command line. Turn it on by uncommenting the +# entries below. +############################################################################### +#*.doc diff=astextplain +#*.DOC diff=astextplain +#*.docx diff=astextplain +#*.DOCX diff=astextplain +#*.dot diff=astextplain +#*.DOT diff=astextplain +#*.pdf diff=astextplain +#*.PDF diff=astextplain +#*.rtf diff=astextplain +#*.RTF diff=astextplain diff --git a/AdaptiveCardToolkit.sln b/AdaptiveCardToolkit.sln index b579a2d451..1e30b6fee1 100644 --- a/AdaptiveCardToolkit.sln +++ b/AdaptiveCardToolkit.sln @@ -3,27 +3,32 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 VisualStudioVersion = 14.0.25420.1 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InteractiveVisualizer", "src\InteractiveVisualizer\InteractiveVisualizer.csproj", "{AE93161A-244A-4410-BC34-466189AEFAF7}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Renderers", "Renderers", "{412460AB-E5CC-4605-8813-7EFFC924D990}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Visualizer", "Visualizer", "{CD8C128A-ABFB-43F8-B86A-8CC06FB0C7AA}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Builders", "Builders", "{CB015F2B-73A6-45E8-9066-77154240257B}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".NET", ".NET", "{38D9E098-DD38-49B7-B861-917FA527D346}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adaptive.Schema.Net", "builders\.NET\Adaptive.Schema.Net\Adaptive.Schema.Net.csproj", "{692311B2-E537-4700-8EF7-A5F83D90383C}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AE93161A-244A-4410-BC34-466189AEFAF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AE93161A-244A-4410-BC34-466189AEFAF7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AE93161A-244A-4410-BC34-466189AEFAF7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AE93161A-244A-4410-BC34-466189AEFAF7}.Release|Any CPU.Build.0 = Release|Any CPU + {692311B2-E537-4700-8EF7-A5F83D90383C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {692311B2-E537-4700-8EF7-A5F83D90383C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {692311B2-E537-4700-8EF7-A5F83D90383C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {692311B2-E537-4700-8EF7-A5F83D90383C}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {AE93161A-244A-4410-BC34-466189AEFAF7} = {CD8C128A-ABFB-43F8-B86A-8CC06FB0C7AA} + {38D9E098-DD38-49B7-B861-917FA527D346} = {CB015F2B-73A6-45E8-9066-77154240257B} + {692311B2-E537-4700-8EF7-A5F83D90383C} = {38D9E098-DD38-49B7-B861-917FA527D346} EndGlobalSection EndGlobal diff --git a/builders/.NET/Adaptive.NET.sln b/builders/.NET/Adaptive.NET.sln new file mode 100644 index 0000000000..fc1e601fda --- /dev/null +++ b/builders/.NET/Adaptive.NET.sln @@ -0,0 +1,22 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.25420.1 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adaptive.Schema.Net", "Adaptive.Schema.Net\Adaptive.Schema.Net.csproj", "{692311B2-E537-4700-8EF7-A5F83D90383C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {692311B2-E537-4700-8EF7-A5F83D90383C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {692311B2-E537-4700-8EF7-A5F83D90383C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {692311B2-E537-4700-8EF7-A5F83D90383C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {692311B2-E537-4700-8EF7-A5F83D90383C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/builders/.NET/Adaptive.Schema.Net/Adaptive.Schema.Net.csproj b/builders/.NET/Adaptive.Schema.Net/Adaptive.Schema.Net.csproj new file mode 100644 index 0000000000..9d6b709d8a --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Adaptive.Schema.Net.csproj @@ -0,0 +1,76 @@ + + + + + 10.0 + Debug + AnyCPU + {692311B2-E537-4700-8EF7-A5F83D90383C} + Library + Properties + Adaptive.Schema.Net + Adaptive.Schema.Net + en-US + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile111 + v4.5 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + + + + + + + + ..\..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll + True + + + + + + + + \ No newline at end of file diff --git a/builders/.NET/Adaptive.Schema.Net/AdaptiveCard.cs b/builders/.NET/Adaptive.Schema.Net/AdaptiveCard.cs new file mode 100644 index 0000000000..baa8ccfae4 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/AdaptiveCard.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// Adaptive card which has flexible container + /// + public class AdaptiveCard : TypedElement + { + public AdaptiveCard() { } + + public string Speak { get; set; } + + public Container Body { get; set; } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/CardElement.cs b/builders/.NET/Adaptive.Schema.Net/CardElement.cs new file mode 100644 index 0000000000..1ba84fd16d --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/CardElement.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// Base class for all elements in a container + /// + public class CardElement : TypedElement + { + public CardElement() : base() + { + } + + /// + /// SSML fragment for spoken interaction + /// + public string Speak { get; set; } + + /// + /// Size hint for the element + /// + public Size Size { get; set; } = Size.Auto; + + /// + /// Horizontal alignment for element + /// + public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Left; + } +} + + diff --git a/builders/.NET/Adaptive.Schema.Net/Choice.cs b/builders/.NET/Adaptive.Schema.Net/Choice.cs new file mode 100644 index 0000000000..fbd97d8ac6 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Choice.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// Choice as part of a MultichoiceInput element + /// + public class Choice + { + public Choice() + { } + + /// + /// Display text for the choice + /// + public string Display { get; set; } + + /// + /// Internal value which will be collected as input if the choice is selected + /// + public string Value { get; set; } + + /// + /// (OPTIONAL) Speech description of the choice + /// + // ISSUE: I think we need speak here... + public string Speak { get; set; } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/Column.cs b/builders/.NET/Adaptive.Schema.Net/Column.cs new file mode 100644 index 0000000000..d5e2c91725 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Column.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// A column container inside of a columngroup + /// + public class Column : Container + { + public Column() { } + + // ISSUE Number? I thought we had "Auto" and stuff.. + public int Weight { get; set; } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/ColumnGroup.cs b/builders/.NET/Adaptive.Schema.Net/ColumnGroup.cs new file mode 100644 index 0000000000..7949d4d363 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/ColumnGroup.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// A container for grouping columns together + /// + public class ColumnGroup : CardElement + { + public ColumnGroup() { } + + // ISSUE? Should this be called columns, it only can take Column elements, right? + public List Items { get; set; } = new List(); + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/Container.cs b/builders/.NET/Adaptive.Schema.Net/Container.cs new file mode 100644 index 0000000000..96df3675bf --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Container.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// Container for a collection of elements + /// + public class Container : TypedElement + { + public Container() + { } + + // Issue: Should this be Elements? + public List Items { get; set; } = new List(); + + /// + /// Image to use for the background of a card + /// + public string BackgroundImageUrl { get; set; } + + /// + /// Background color to use for the card + /// + // ISSUE: Why is this a string? + public string BackgroundColor { get; set; } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/DateInput.cs b/builders/.NET/Adaptive.Schema.Net/DateInput.cs new file mode 100644 index 0000000000..f82722e0b5 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/DateInput.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + + /// + /// Input control for date + /// + public class DateInput : Input + { + public DateInput() + { + this.Size = Size.Medium; + } + + public bool IncludeTime { get; set; } + + // ISSUE: WE NEED MORE PARAMETERS HERE + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/Enums.cs b/builders/.NET/Adaptive.Schema.Net/Enums.cs new file mode 100644 index 0000000000..7b7ab8990d --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Enums.cs @@ -0,0 +1,170 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// Controls the horizontal size (width) of element. + /// + public enum Size + { + /// + /// The width of the element is optimally chosen depending on the space available in the element's container + /// + Auto, + + /// + /// The width of the element adjusts to match that of its container + /// + Stretch, + + /// + /// Small width + /// + Small, + + /// + /// Medium width + /// + Medium, + + /// + /// Large width + /// + Large + } + + /// + /// Controls the relative size of TextBlock elements + /// + public enum TextSize + { + /// + /// Smallest text size + /// + Small, + + /// + /// Default text size + /// + Normal, + + /// + /// Slightly larger than normal + /// + Medium, + + /// + /// Slightly larger then medium + /// + Large, + + /// + /// The largest text size + /// + ExtraLarge + } + + /// + /// Controls the weight of TextBock Elements + /// + public enum TextWeight + { + /// + /// Lighter text (thinner stroke) + /// + Lighter, + + /// + /// The default text weight + /// + Normal, + + /// + /// Bolder text (wider stroke) + /// + Bolder + } + + /// + /// Controls the color style of TextBlock Elements + /// + public enum TextColor + { + /// + /// The default color which guarentees appropriate contrast + /// + Default, + + /// + /// Forces the text to be rendered in a dark color which is suitable when displayed over a light background + /// + Dark, + + /// + /// Forces the text to be rendered in a light color which is suitable when displayed over a dark background + /// + Light, + + /// + /// Accent the text + /// + Accent, + + /// + /// Good (such as green) + /// + Good, + + /// + /// Warning (such as yellow) + /// + Warning, + + /// + /// Highlight as needing attention (such as red) + /// + Attention + } + + /// + /// Controls how elements are horizontally positioned within their container. + /// + public enum HorizontalAlignment + { + /// + /// The element is left aligned + /// + Left, + + /// + /// The element is centered inside its container + /// + Center, + + /// + /// The element is right aligned + /// + Right + } + + /// + /// Controls the way Image elements are displayed. + /// + public enum ImageStyle + { + /// + /// The image is displayed within a rectangle. + /// + Normal, + + /// + /// The image is cropped to a circle, a common way to represent people photos. + /// + Person + } + +} diff --git a/builders/.NET/Adaptive.Schema.Net/Fact.cs b/builders/.NET/Adaptive.Schema.Net/Fact.cs new file mode 100644 index 0000000000..aa43a78de6 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Fact.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// Represents one "fact" in a FactGroup element. + /// + public class Fact + { + public Fact(string name, string value, string speak=null) + { + this.Name = name; + this.Value = value; + this.Speak = speak; + } + + /// + /// The facts label + /// + public string Name { get; set; } + + /// + /// The fact's value + /// + public string Value { get; set; } + + /// + /// (Optional) Specifies what should be spoken for this entire element. This is simple text or SSML fragment + /// + public string Speak { get; set; } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/FactGroup.cs b/builders/.NET/Adaptive.Schema.Net/FactGroup.cs new file mode 100644 index 0000000000..b88070c977 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/FactGroup.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// The FactGroup element makes it simple to display a se ries of "facts" (e.g. name/value pairs) in a tabular form. + /// + public class FactGroup : CardElement + { + public FactGroup() + { } + + /// + /// The facts to be displayed. + /// + // ISSUE: This only takes Fact objects, should this be called Facts? + public List Items { get; set; } = new List(); + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/Image.cs b/builders/.NET/Adaptive.Schema.Net/Image.cs new file mode 100644 index 0000000000..05dd98c50e --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Image.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// The Image element allows for the inclusion of images in an Adaptive Card. + /// + public class Image : CardElement + { + public Image() + { } + + /// + /// The style in which the image is displayed. + /// + public ImageStyle Style { get; set; } = ImageStyle.Normal; + + /// + /// A url pointing to an image to display + /// + public string Url { get; set; } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/ImageGallery.cs b/builders/.NET/Adaptive.Schema.Net/ImageGallery.cs new file mode 100644 index 0000000000..05f8b94642 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/ImageGallery.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// The ImageGallery allows for the inclusion of a collection images like a photogallery. + /// + public class ImageGallery : CardElement + { + public ImageGallery() + { + + } + + /// + /// Collection of image objects to display + /// + // ISSUE: Shouldn't this be called Images since it can only contain Image + public List Items { get; set; } = new List(); + + /// + /// Specifies the horizontal size of each image in the gallery. + /// + public Size ImageSize { get; set; } = Size.Medium; + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/Input.cs b/builders/.NET/Adaptive.Schema.Net/Input.cs new file mode 100644 index 0000000000..bf0b022138 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Input.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + /// + /// Input is used as part of a Form CardElement to collect information from a user + /// + public class Input : CardElement + { + public Input() + { } + + public string Id { get; set; } + + public string Title { get; set; } + + public string Value { get; set; } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/MultichoiceInput.cs b/builders/.NET/Adaptive.Schema.Net/MultichoiceInput.cs new file mode 100644 index 0000000000..acb41761cb --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/MultichoiceInput.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + public class MultichoiceInput : Input + { + public MultichoiceInput() + { + this.Size = Size.Medium; + } + + public List Items { get; set; } = new List(); + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/Properties/AssemblyInfo.cs b/builders/.NET/Adaptive.Schema.Net/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..43dd28a5f6 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Adaptive.Schema.Net")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Adaptive.Schema.Net")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/builders/.NET/Adaptive.Schema.Net/Seperator.cs b/builders/.NET/Adaptive.Schema.Net/Seperator.cs new file mode 100644 index 0000000000..b0a8e5da5f --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/Seperator.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + public class Seperator : CardElement + { + public Seperator() + { + } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/TextBlock.cs b/builders/.NET/Adaptive.Schema.Net/TextBlock.cs new file mode 100644 index 0000000000..4fa75bb0d7 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/TextBlock.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + public class TextBlock : CardElement + { + public TextBlock() + { + + } + + public TextSize TextSize { get; set; } = TextSize.Normal; + + public TextWeight TextWeight { get; set; } = TextWeight.Normal; + + public TextColor TextColor { get; set; } = TextColor.Default; + + public string Text { get; set; } + + public string Speak { get; set; } + + public bool IsSubtle { get; set; } = false; + + public bool Wrap { get; set; } = false; + + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/TextInput.cs b/builders/.NET/Adaptive.Schema.Net/TextInput.cs new file mode 100644 index 0000000000..050601d5de --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/TextInput.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + public class TextInput : Input + { + public TextInput() + { + this.Size = Size.Stretch; + } + + public int MaxLength { get; set; } = int.MaxValue; + + public bool IsMultiline { get; set; } = false; + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/ToggleInput.cs b/builders/.NET/Adaptive.Schema.Net/ToggleInput.cs new file mode 100644 index 0000000000..cfa71a6c53 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/ToggleInput.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Adaptive.Schema.Net +{ + public class ToggleInput : Input + { + public ToggleInput() + { } + + } + +} diff --git a/builders/.NET/Adaptive.Schema.Net/TypedElement.cs b/builders/.NET/Adaptive.Schema.Net/TypedElement.cs new file mode 100644 index 0000000000..5a3f825a83 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/TypedElement.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; + +namespace Adaptive.Schema.Net +{ + [JsonConverter(typeof(TypeConverter))] + [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] + public class TypedElement + { + public TypedElement() + { + this.Type = GetType().Name; + } + + [JsonProperty("@type", Order = -2)] + public string Type { get; set; } + } +} diff --git a/builders/.NET/Adaptive.Schema.Net/TypedElementConverter.cs b/builders/.NET/Adaptive.Schema.Net/TypedElementConverter.cs new file mode 100644 index 0000000000..e57cc1d2a5 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/TypedElementConverter.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Adaptive.Schema.Net +{ + /// + /// This handles using @type field to instantiate strongly typed object on deserialization + /// + public class TypeConverter : JsonConverter + { + public override bool CanConvert(Type objectType) + { + return typeof(TypedElement).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + } + + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + JObject jObject = JObject.Load(reader); + // Create target object based on JObject + string typeName = jObject["@type"]?.Value(); + object result = jObject; + if (typeName != null) + { + var type = typeof(TypedElement).GetTypeInfo().Assembly.ExportedTypes.FirstOrDefault(t => t.Name == typeName); + if (type != null) + { + result = Activator.CreateInstance(type); + } + // Populate the object properties + serializer.Populate(jObject.CreateReader(), result); + } + + return result; + } + + public override bool CanRead { get { return true; } } + + public override bool CanWrite { get { return false; } } + } + +} diff --git a/builders/.NET/Adaptive.Schema.Net/packages.config b/builders/.NET/Adaptive.Schema.Net/packages.config new file mode 100644 index 0000000000..d59cc88828 --- /dev/null +++ b/builders/.NET/Adaptive.Schema.Net/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/docs/Schema.md b/docs/Schema.md index d1ff27d387..7ac37cc4ec 100644 --- a/docs/Schema.md +++ b/docs/Schema.md @@ -22,14 +22,14 @@ The TextBlock element allows for the inclusion of text, with various font sizes, | **text** | string | The actual text to display | | **speak** | [Speak](/Microsoft/AdaptiveCards/blob/master/docs/SpeechAndAdvancedCustomization.md) | (Optional) Specifies what should be spoken for this entire element. This is simple text or SSML fragment | -## Image +## Image Object *Extends [CardElement](#cardelement)* The Image element allows for the inclusion of images in an Adaptive Card. | Property | Type | Description | |---|---|---| -| **url** | The URL to the image. | +| **url** | string | The URL to the image. | | **style** | [ImageStyle](#imagestyle) | The style in which the image is displayed. | ## ImageGallery @@ -39,6 +39,7 @@ The ImageGallery allows for the inclusion of a collection images like a photogal | Property | Type | Description | |---|---|---| +| **Items**| Image[] | Array of Image objects | | **size** | [Size](#size) | Specifies the horizontal size of each image in the gallery. | ## Separator diff --git a/package.json b/package.json index 9727b21303..b6f224f8e3 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "json-loader": "0.5.4", "ts-loader": "1.3.0", "tslint": "3.15.1", - "typescript": "2.0.10", + "typescript": "2.1.5", "webpack": "1.14.0" }, "author": "Microsoft",