├── Library ├── AdaptiveCards │ ├── docs │ │ └── .gitignore │ ├── Globals.cs │ ├── ILogWarnings.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── TypedEventHandler.cs │ ├── AdaptiveCards.NET.asmdef │ ├── MarkedNet │ │ ├── MarkedNet │ │ │ ├── Objects.cs │ │ │ ├── Token.cs │ │ │ ├── TokensResult.cs │ │ │ ├── Marked.cs │ │ │ └── Options.cs │ │ ├── HtmlRenderer.cs │ │ ├── EmojiRenderer.cs │ │ ├── License.txt │ │ └── MarkedNetLicense.txt │ ├── Rendering │ │ ├── ImageSetConfig.cs │ │ ├── ImageSizesConfig.cs │ │ ├── HeadingsConfig.cs │ │ ├── AdaptiveCardConfig.cs │ │ ├── InputsConfig.cs │ │ ├── AdaptiveRenderException.cs │ │ ├── SeparatorConfig.cs │ │ ├── SpacingsConfig.cs │ │ ├── AdaptiveConfigBase.cs │ │ ├── FontStyleConfig.cs │ │ ├── HighlightColorConfig.cs │ │ ├── ContainerStyleConfig.cs │ │ ├── FontStylesConfig.cs │ │ ├── LabelConfig.cs │ │ ├── MediaConfig.cs │ │ ├── ErrorMessageConfig.cs │ │ ├── FactSetConfig.cs │ │ ├── AdaptiveRenderTransformers.cs │ │ ├── RenderedAdaptiveCardBase.cs │ │ ├── FontWeightsConfig.cs │ │ ├── InputsLabelConfig.cs │ │ ├── RenderedAdaptiveCardInputs.cs │ │ ├── TextBlockConfig.cs │ │ ├── AdaptiveRenderArgs.cs │ │ ├── FontSizesConfig.cs │ │ ├── AdaptiveCardRendererBase.cs │ │ └── AdaptiveActionHandlers.cs │ ├── package.json │ ├── AdaptiveTableCell.cs │ ├── AdaptiveFontStyle.cs │ ├── AdaptiveUnknownElement.cs │ ├── AdaptiveColumnWidth.cs │ ├── AdaptiveTextBlockStyle.cs │ ├── AdaptiveCardParseResult.cs │ ├── AdaptiveException.cs │ ├── AdaptiveActionMode.cs │ ├── AdaptiveVerticalAlignment.cs │ ├── AdaptiveTypedBaseElementConverter.cs │ ├── AdaptiveAssociatedInputs.cs │ ├── AdaptiveColumnSize.cs │ ├── AdaptiveSerializationException.cs │ ├── AdaptiveChoiceInputStyle.cs │ ├── AdaptiveVerticalContentAlignment.cs │ ├── RemoteResourceInformation.cs │ ├── AdaptiveHorizontalContentAlignment.cs │ ├── AdaptiveFallbackException.cs │ ├── AdaptiveImageStyle.cs │ ├── AdaptiveHorizontalAlignment.cs │ ├── AdaptiveTextWeight.cs │ ├── AdaptiveFactSet.cs │ ├── AdaptiveShowCardAction.cs │ ├── AdaptiveImageSize.cs │ ├── AdaptiveTokenExchangeResource.cs │ ├── AdaptiveToggleVisibilityAction.cs │ ├── AdaptiveSpacing.cs │ ├── AdaptiveTextSize.cs │ ├── AdaptiveTextInputStyle.cs │ ├── AdaptiveAuthCardButton.cs │ ├── AdaptiveTextColor.cs │ ├── AdaptiveImageSet.cs │ ├── AdaptiveColumnSet.cs │ ├── AdaptiveContainerStyle.cs │ ├── IAdaptiveTextElement.cs │ ├── AdaptiveInput.cs │ ├── AdaptiveInline.cs │ ├── AdaptiveRefresh.cs │ ├── AdaptiveMediaSource.cs │ ├── AdaptiveActionSet.cs │ ├── AdaptiveOpenUrlAction.cs │ ├── AdaptiveMedia.cs │ ├── AdaptiveRichTextBlock.cs │ ├── AdaptiveChoice.cs │ ├── AdaptiveAuthentication.cs │ ├── AdaptiveColumn.cs │ ├── AdaptiveFact.cs │ ├── AdaptiveCollectionWithContentAlignment.cs │ ├── IgnoreNullEnumConverter.cs │ ├── AdaptiveImageFillMode.cs │ ├── IgnoreEmptyItemsConverter.cs │ ├── StrictIntConverter.cs │ ├── ToggleElementsConverter.cs │ ├── AdaptiveDateInput.cs │ ├── AdaptiveTimeInput.cs │ ├── IgnoreDefaultStringEnumConverter.cs │ ├── AdaptiveInlinesConverter.cs │ ├── AdaptiveNumberInput.cs │ └── AdaptiveToggleInput.cs ├── AdaptiveCards.Rendering.Wpf.Xceed │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── XceedChoiceSetInput.cs │ ├── XceedAdaptiveCardRenderer.cs │ ├── XceedNumberInput.cs │ ├── AdaptiveCards.Rendering.Wpf.Xceed.csproj │ └── XceedInputValue.cs ├── AdaptiveCards.Rendering.Wpf │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── AdaptiveMediaEventArgs.cs │ ├── AdaptiveActionEventArgs.cs │ ├── MissingInputEventArgs.cs │ ├── MissingInputException.cs │ ├── RenderedAdaptiveCardImage.cs │ ├── XamlUtilities.cs │ ├── AdaptiveDateInputRenderer.cs │ ├── AdaptiveTimeInputRenderer.cs │ ├── Helpers │ │ └── TaskExtensions.cs │ ├── AdaptiveNumberInputRenderer.cs │ ├── AdaptiveToggleInputRenderer.cs │ ├── RenderedAdaptiveCard.cs │ ├── AdaptiveImageSetRenderer.cs │ ├── TagContent.cs │ ├── AdaptiveCards.Rendering.Wpf.csproj │ └── PreFetchImageVisitor.cs └── AdaptiveCards.Rendering.Wpf.Core │ └── AdaptiveCards.Rendering.Wpf.Core.csproj ├── Samples ├── AdaptiveCards.Sample.ImageRender │ ├── .gitignore │ ├── Properties │ │ └── launchSettings.json │ ├── AdaptiveCards.Sample.ImageRender.csproj │ └── README.md ├── WPFVisualizer │ ├── FodyWeavers.xml │ ├── Properties │ │ ├── Settings.settings │ │ └── Settings.Designer.cs │ ├── CustomElements │ │ ├── MyCustomAction.cs │ │ └── MyCustomRating.cs │ ├── App.xaml │ ├── ShowCardWindow.xaml │ ├── ViewImageWindow.xaml │ ├── PRIVACY.md │ ├── App.config │ ├── ViewImageWindow.xaml.cs │ ├── SyntaxHighlighting │ │ └── JSON.xml │ ├── App.xaml.cs │ └── ShowCardWindow.xaml.cs ├── WPFVisualizer.PackageProject │ ├── Images │ │ ├── BadgeLogo.scale-100.png │ │ ├── BadgeLogo.scale-200.png │ │ ├── BadgeLogo.scale-400.png │ │ ├── StoreLogo.scale-100.png │ │ ├── StoreLogo.scale-200.png │ │ ├── StoreLogo.scale-400.png │ │ ├── Square44x44Logo.scale-100.png │ │ ├── Square44x44Logo.scale-200.png │ │ ├── Square44x44Logo.scale-400.png │ │ ├── Square150x150Logo.scale-100.png │ │ ├── Square150x150Logo.scale-200.png │ │ ├── Square150x150Logo.scale-400.png │ │ ├── Square44x44Logo.targetsize-16.png │ │ ├── Square44x44Logo.targetsize-48.png │ │ ├── Square44x44Logo.targetsize-256.png │ │ ├── Square44x44Logo.altform-unplated_targetsize-16.png │ │ ├── Square44x44Logo.altform-unplated_targetsize-48.png │ │ └── Square44x44Logo.altform-unplated_targetsize-256.png │ ├── AdaptiveCards.Sample.WPFVisualizer.PackageProject_TemporaryKey.pfx │ └── Package.appxmanifest ├── AdaptiveCards.Core.Sample.ImageRender │ ├── Properties │ │ └── launchSettings.json │ ├── AdaptiveCards.Core.Sample.ImageRender.csproj │ └── README.md └── ImageRendererServer │ ├── wwwroot │ └── Styles │ │ └── MyStyles.xaml │ ├── Properties │ └── launchSettings.json │ ├── Program.cs │ ├── ImageRendererServer.csproj │ └── Startup.cs ├── .vscode ├── tasks.json └── launch.json ├── custom.props ├── Test └── AdaptiveCards.Test │ ├── AdaptiveCards.Test.csproj │ ├── AdaptiveInputTests.cs │ └── AdaptiveSchemaVersionTests.cs ├── LICENSE ├── RunAllTests.ps1 ├── Build ├── SignNugetConfig.xml └── SignConfig.xml └── .pipelines └── dotnet-ci.yml /Library/AdaptiveCards/docs/.gitignore: -------------------------------------------------------------------------------- 1 | *.xml -------------------------------------------------------------------------------- /Samples/AdaptiveCards.Sample.ImageRender/.gitignore: -------------------------------------------------------------------------------- 1 | *.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer/FodyWeavers.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Globals.cs: -------------------------------------------------------------------------------- 1 | namespace AdaptiveCards 2 | { 3 | class Globals 4 | { 5 | public static readonly string ObjectModelVersion = "1.5"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/BadgeLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/BadgeLogo.scale-100.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/BadgeLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/BadgeLogo.scale-200.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/BadgeLogo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/BadgeLogo.scale-400.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/StoreLogo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/StoreLogo.scale-100.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/StoreLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/StoreLogo.scale-200.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/StoreLogo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/StoreLogo.scale-400.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.scale-100.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.scale-400.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square150x150Logo.scale-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square150x150Logo.scale-100.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square150x150Logo.scale-400.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square150x150Logo.scale-400.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.targetsize-16.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.targetsize-48.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.targetsize-256.png -------------------------------------------------------------------------------- /Samples/AdaptiveCards.Sample.ImageRender/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "AdaptiveCards.Sample.ImageRender": { 4 | "commandName": "Project", 5 | "commandLineArgs": "-r -o ./out" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.altform-unplated_targetsize-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.altform-unplated_targetsize-16.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.altform-unplated_targetsize-48.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.altform-unplated_targetsize-48.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.altform-unplated_targetsize-256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/Images/Square44x44Logo.altform-unplated_targetsize-256.png -------------------------------------------------------------------------------- /Samples/WPFVisualizer/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/AdaptiveCards.Sample.WPFVisualizer.PackageProject_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/microsoft/AdaptiveCards-.NET/main/Samples/WPFVisualizer.PackageProject/AdaptiveCards.Sample.WPFVisualizer.PackageProject_TemporaryKey.pfx -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf.Xceed/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | 4 | #if DELAY_SIGN 5 | [assembly: AssemblyKeyFileAttribute(@"../../../../35MSSharedLib1024.snk")] 6 | [assembly: AssemblyDelaySignAttribute(true)] 7 | #endif 8 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/ILogWarnings.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections.Generic; 4 | 5 | namespace AdaptiveCards 6 | { 7 | internal interface ILogWarnings 8 | { 9 | List Warnings { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Reflection; 5 | 6 | #if DELAY_SIGN 7 | [assembly: AssemblyKeyFileAttribute(@"../../../../35MSSharedLib1024.snk")] 8 | [assembly: AssemblyDelaySignAttribute(true)] 9 | #endif 10 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/Test/AdaptiveCards.Rendering.Html.Test/AdaptiveCards.Rendering.Html.Test.csproj" 11 | ], 12 | "problemMatcher": "$msCompile" 13 | } 14 | ] 15 | } 16 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/TypedEventHandler.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards 6 | { 7 | public delegate void TypedEventHandler( 8 | TSender sender, 9 | TEventArgs e 10 | ) where TEventArgs : EventArgs; 11 | } 12 | -------------------------------------------------------------------------------- /Samples/AdaptiveCards.Core.Sample.ImageRender/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "AdaptiveCards.Core.Sample.ImageRender": { 4 | "commandName": "Project", 5 | "commandLineArgs": "..\\..\\..\\..\\..\\..\\..\\samples\\v1.0\\Scenarios -r -i -o ./out --host-config ..\\..\\..\\..\\..\\..\\..\\samples\\HostConfig\\windows-notification.json" 6 | } 7 | } 8 | } -------------------------------------------------------------------------------- /Samples/WPFVisualizer/CustomElements/MyCustomAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using AdaptiveCards; 4 | 5 | namespace WpfVisualizer 6 | { 7 | public class MyCustomAction : AdaptiveAction 8 | { 9 | public override string Type { get; set; } = "Action.MyCustomAction"; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveCards.NET.asmdef: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Microsoft.AdaptiveCards.NET", 3 | "rootNamespace": "AdaptiveCards", 4 | "references": [ 5 | ], 6 | "includePlatforms": [ 7 | ], 8 | "excludePlatforms": [], 9 | "allowUnsafeCode": false, 10 | "overrideReferences": false, 11 | "precompiledReferences": [], 12 | "autoReferenced": true, 13 | "defineConstraints": [], 14 | "versionDefines": [], 15 | "noEngineReferences": false 16 | } -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Reflection; 5 | using System.Windows; 6 | 7 | #if DELAY_SIGN 8 | [assembly: AssemblyKeyFileAttribute(@"../../../../35MSSharedLib1024.snk")] 9 | [assembly: AssemblyDelaySignAttribute(true)] 10 | #endif 11 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)] 12 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/MarkedNet/Objects.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.MarkedNet 7 | { 8 | public class TableCellFlags 9 | { 10 | public bool Header { get; set; } 11 | public string Align { get; set; } 12 | } 13 | 14 | public class LinkObj 15 | { 16 | public string Href { get; set; } 17 | public string Title { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /custom.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1 5 | 1 6 | 7 | 1.1.0 8 | AdaptiveCards 9 | 10 | 11 | -------------------------------------------------------------------------------- /Samples/ImageRendererServer/wwwroot/Styles/MyStyles.xaml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/ImageSetConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | 9 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 10 | public class ImageSetConfig 11 | { 12 | public ImageSetConfig() { } 13 | 14 | public AdaptiveImageSize ImageSize { get; set; } = AdaptiveImageSize.Medium; 15 | } 16 | 17 | } 18 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/ImageSizesConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 9 | public class ImageSizesConfig 10 | { 11 | public int Small { get; set; } = 40; 12 | 13 | public int Medium { get; set; } = 80; 14 | 15 | public int Large { get; set; } = 160; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "com.microsoft.adaptivecards.net", 3 | "version": "%version%", 4 | "displayName": "Adaptive Cards", 5 | "description": "For incorporating Adaptive Cards in Unity.", 6 | "author": "Microsoft", 7 | "license": "MIT", 8 | "licensesUrl": "https://github.com/microsoft/AdaptiveCards/blob/main/LICENSE", 9 | "unity": "2020.3", 10 | "documentationUrl": "", 11 | "changelogUrl": "", 12 | "keywords": [ 13 | "AdaptiveCards" 14 | ], 15 | "dependencies": { 16 | "com.unity.nuget.newtonsoft-json": "2.0.2" 17 | } 18 | } -------------------------------------------------------------------------------- /Samples/WPFVisualizer/App.xaml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/AdaptiveMediaEventArgs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards.Rendering.Wpf 6 | { 7 | public class AdaptiveMediaEventArgs : EventArgs 8 | { 9 | public AdaptiveMediaEventArgs(AdaptiveMedia media) 10 | { 11 | Media = media; 12 | } 13 | 14 | /// 15 | /// The clicked media 16 | /// 17 | public AdaptiveMedia Media { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/HeadingsConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 9 | public class HeadingsConfig 10 | { 11 | /// 12 | /// Level of heading text, used only if underlying platform requires it. 13 | /// 14 | public int Level { get; set; } = 2; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/AdaptiveActionEventArgs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards.Rendering.Wpf 6 | { 7 | public class AdaptiveActionEventArgs : EventArgs 8 | { 9 | public AdaptiveActionEventArgs(AdaptiveAction action) 10 | { 11 | Action = action; 12 | } 13 | 14 | /// 15 | /// The action that fired 16 | /// 17 | public AdaptiveAction Action { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTableCell.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System.Xml.Serialization; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Represents a cell within a row of a Table element. 10 | /// 11 | 12 | #if !NETSTANDARD1_3 13 | [XmlType(TypeName = AdaptiveTableCell.TypeName)] 14 | #endif 15 | public class AdaptiveTableCell : AdaptiveContainer 16 | { 17 | /// 18 | public new const string TypeName = "TableCell"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/HtmlRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.MarkedNet; 7 | 8 | namespace Microsoft.MarkedNet 9 | { 10 | /// 11 | /// Renderer which renders to HTML with Emoji Support 12 | /// 13 | public class HtmlRenderer : EmojiMarkdownRenderer 14 | { 15 | public HtmlRenderer() : base() 16 | { 17 | } 18 | 19 | public HtmlRenderer(Options options) : base(options) 20 | { 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/MissingInputEventArgs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Windows; 5 | 6 | namespace AdaptiveCards.Rendering.Wpf 7 | { 8 | public class MissingInputEventArgs : EventArgs 9 | { 10 | public MissingInputEventArgs(AdaptiveInput input, FrameworkElement frameworkElement) 11 | { 12 | this.FrameworkElement = frameworkElement; 13 | this.AdaptiveInput = input; 14 | } 15 | 16 | public FrameworkElement FrameworkElement { get; private set; } 17 | 18 | public AdaptiveInput AdaptiveInput { get; private set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Samples/ImageRendererServer/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:50959/", 7 | "sslPort": 0 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "environmentVariables": { 15 | "ASPNETCORE_ENVIRONMENT": "Development" 16 | } 17 | }, 18 | "ImageRendererServer": { 19 | "commandName": "Project", 20 | "launchBrowser": true, 21 | "environmentVariables": { 22 | "ASPNETCORE_ENVIRONMENT": "Development" 23 | }, 24 | "applicationUrl": "http://localhost:50960/" 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/MissingInputException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Windows; 5 | 6 | namespace AdaptiveCards.Rendering.Wpf 7 | { 8 | public class MissingInputException : Exception 9 | { 10 | public MissingInputException(string message, AdaptiveInput input, FrameworkElement frameworkElement) 11 | : base(message) 12 | { 13 | this.FrameworkElement = frameworkElement; 14 | this.AdaptiveInput = input; 15 | } 16 | 17 | public FrameworkElement FrameworkElement { get; set; } 18 | 19 | public AdaptiveInput AdaptiveInput { get; set; } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveFontStyle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Newtonsoft.Json; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Controls the font type of the TextBlock Elements 10 | /// 11 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 12 | public enum AdaptiveFontType 13 | { 14 | /// 15 | /// The default font type for general use 16 | /// 17 | Default, 18 | 19 | /// 20 | /// The monospace font type 21 | /// 22 | Monospace 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/RenderedAdaptiveCardImage.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections.Generic; 4 | using System.IO; 5 | 6 | namespace AdaptiveCards.Rendering.Wpf 7 | { 8 | public class RenderedAdaptiveCardImage : RenderedAdaptiveCardBase 9 | { 10 | /// 11 | /// The rendered image stream as image/png 12 | /// 13 | public Stream ImageStream { get; } 14 | 15 | public RenderedAdaptiveCardImage(Stream stream, AdaptiveCard originatingCard, IList warnings) : base(originatingCard, warnings) 16 | { 17 | ImageStream = stream; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveUnknownElement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace AdaptiveCards 5 | { 6 | /// 7 | /// Represents an unknown element encountered while parsing. 8 | /// 9 | public class AdaptiveUnknownElement : AdaptiveElement 10 | { 11 | /// 12 | public override string Type { get; set; } 13 | } 14 | 15 | /// 16 | /// Represents an unknown action encountered while parsing. 17 | /// 18 | public class AdaptiveUnknownAction : AdaptiveAction 19 | { 20 | /// 21 | public override string Type { get; set; } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveColumnWidth.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | namespace AdaptiveCards 4 | { 5 | /// 6 | /// Controls the horizontal size (width) of Column. 7 | /// 8 | public class AdaptiveColumnWidth 9 | { 10 | /// 11 | /// The width of the Column is optimally chosen depending on the space available in the element's container 12 | /// 13 | public const string Auto = "auto"; 14 | 15 | /// 16 | /// The width of the Column adjusts to match that of its container 17 | /// 18 | public const string Stretch = "stretch"; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTextBlockStyle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Indicates TextBlock element's content type. 10 | /// 11 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 12 | public enum AdaptiveTextBlockStyle 13 | { 14 | /// 15 | /// The content is a paragraph (default). 16 | /// 17 | Paragraph = 0, 18 | 19 | /// 20 | /// The content is a heading. 21 | /// 22 | Heading = 1, 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/AdaptiveCardConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// Contains options for the AdaptiveCard element. 10 | /// 11 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 12 | public class AdaptiveCardConfig : AdaptiveConfigBase 13 | { 14 | /// 15 | /// Determines whether custom styles should be honored. 16 | /// 17 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public bool AllowCustomStyle { get; set; } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveCardParseResult.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections.Generic; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// The result of parsing an AdaptiveCard from JSON. 9 | /// 10 | public class AdaptiveCardParseResult 11 | { 12 | /// 13 | /// The parsed card object. 14 | /// 15 | public AdaptiveCard Card { get; set; } 16 | 17 | /// 18 | /// A collection of any warnings that might have been encountered when parsing the card. 19 | /// 20 | public List Warnings { get; } = new List(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/ShowCardWindow.xaml: -------------------------------------------------------------------------------- 1 | 2 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Represents an exception thrown by Adaptive Cards itself. 9 | /// 10 | public class AdaptiveException : Exception 11 | { 12 | /// 13 | public AdaptiveException() 14 | { 15 | } 16 | 17 | /// 18 | public AdaptiveException(string message) : base(message) 19 | { 20 | } 21 | 22 | /// 23 | public AdaptiveException(string message, Exception innerException) : base(message, innerException) 24 | { 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/EmojiRenderer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using Microsoft.MarkedNet; 7 | 8 | namespace Microsoft.MarkedNet 9 | { 10 | /// 11 | /// Renderer which renders emoji markdown to unicode 12 | /// 13 | public class EmojiMarkdownRenderer : MarkdownRenderer 14 | { 15 | public EmojiMarkdownRenderer() : base() 16 | { 17 | } 18 | 19 | public EmojiMarkdownRenderer(Options options) : base(options) 20 | { 21 | } 22 | 23 | public override string Preprocess(string text) 24 | { 25 | return EmojiConverter.ConvertMarkupToEmoji(text); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/MarkedNet/Token.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | 7 | namespace Microsoft.MarkedNet 8 | { 9 | public class Token 10 | { 11 | public string Text { get; set; } 12 | public string Type { get; set; } 13 | 14 | 15 | public int Depth { get; set; } 16 | public bool Escaped { get; set; } 17 | public string Lang { get; set; } 18 | public bool Ordered { get; set; } 19 | 20 | public int Start { get; set; } 21 | 22 | public bool Pre { get; set; } 23 | 24 | public IList Header { get; set; } 25 | public IList Align { get; set; } 26 | public IList> Cells { get; set; } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveActionMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Determines whether the action should be displayed as a button or in the overflow menu. 9 | /// 10 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 11 | public enum AdaptiveActionMode 12 | { 13 | /// 14 | /// Action is displayed as a button. 15 | /// 16 | Primary, 17 | 18 | /// 19 | /// Action is placed in an overflow menu (typically a popup menu under a ... button). 20 | /// 21 | Secondary 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveVerticalAlignment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Defines the vertical alignment behavior of an element. 10 | /// 11 | [JsonConverter(typeof(StringEnumConverter), true)] 12 | public enum AdaptiveVerticalAlignment 13 | { 14 | /// 15 | /// Align to the top. 16 | /// 17 | Top, 18 | 19 | /// 20 | /// Centered. 21 | /// 22 | Center, 23 | 24 | /// 25 | /// Align to the bottom. 26 | /// 27 | Bottom 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/InputsConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// Properties which control rendering of media 10 | /// 11 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 12 | public class InputsConfig 13 | { 14 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 15 | public LabelConfig Label { get; set; } = new LabelConfig(); 16 | 17 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public ErrorMessageConfig ErrorMessage { get; set; } = new ErrorMessageConfig(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/ViewImageWindow.xaml: -------------------------------------------------------------------------------- 1 | 2 | 11 | 12 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTypedBaseElementConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// JsonConverters that deserialize to AdaptiveCards elements and use ParseContext must inherit this class. 9 | /// ParseContext provides id generation, id collision detections, and other useful services during deserialization. 10 | /// 11 | public abstract class AdaptiveTypedBaseElementConverter : JsonConverter 12 | { 13 | /// 14 | /// The to use while parsing in AdaptiveCards. 15 | /// 16 | public ParseContext ParseContext { get; set; } = new ParseContext(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveAssociatedInputs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Newtonsoft.Json; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Controls which inputs are associated with a given submit action 10 | /// 11 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 12 | public enum AdaptiveAssociatedInputs 13 | { 14 | /// 15 | /// Gathers and validates inputs from the current card and any parent cards 16 | /// 17 | Auto = 0, 18 | 19 | /// 20 | /// Does not gather or validate any inputs on submit 21 | /// 22 | None = 1 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Samples/ImageRendererServer/Program.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Threading.Tasks; 8 | using Microsoft.AspNetCore; 9 | using Microsoft.AspNetCore.Hosting; 10 | using Microsoft.Extensions.Configuration; 11 | using Microsoft.Extensions.Logging; 12 | 13 | namespace ImageRendererServer 14 | { 15 | public class Program 16 | { 17 | public static void Main(string[] args) 18 | { 19 | BuildWebHost(args).Run(); 20 | } 21 | 22 | public static IWebHost BuildWebHost(string[] args) => 23 | WebHost.CreateDefaultBuilder(args) 24 | .UseStartup() 25 | .Build(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Samples/AdaptiveCards.Core.Sample.ImageRender/AdaptiveCards.Core.Sample.ImageRender.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | netcoreapp3.0 6 | 7 | 8 | 9 | 10 | x86 11 | false 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/MarkedNet/TokensResult.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.MarkedNet 7 | { 8 | public class TokensResult 9 | { 10 | public IList Tokens { get; set; } 11 | public IDictionary Links { get; set; } 12 | public int Length { get { return Tokens.Count; } } 13 | 14 | public IEnumerable Reverse() 15 | { 16 | return Tokens.Reverse(); 17 | } 18 | 19 | public TokensResult() 20 | { 21 | Tokens = new List(); 22 | Links = new Dictionary(); 23 | } 24 | 25 | 26 | public void Add(Token token) 27 | { 28 | Tokens.Add(token); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/PRIVACY.md: -------------------------------------------------------------------------------- 1 | # Privacy Policy 2 | 3 | This privacy notice discloses the privacy practices for the Adaptive Cards WPF Visualizer. This privacy notice applies solely to information collected by this app. It will notify you of the following: 4 | 5 | 1. What personally identifiable information is collected from you through the app, how it is used and with whom it may be shared. 6 | 1. What choices are available to you regarding the use of your data. 7 | 1. The security procedures in place to protect the misuse of your information. 8 | 1. How you can correct any inaccuracies in the information. 9 | 10 | ## Information Collection, Use, and Sharing 11 | We do not collect any information from the app. 12 | 13 | If you feel that we are not abiding by this privacy policy, you should contact us immediately [via email](adaptivecardstores@microsoft.com). -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/AdaptiveRenderException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards.Rendering 6 | { 7 | public class AdaptiveRenderException : AdaptiveException 8 | { 9 | public AdaptiveRenderException() 10 | { 11 | 12 | } 13 | 14 | public AdaptiveRenderException(string message) : base(message) 15 | { 16 | } 17 | 18 | public AdaptiveRenderException(string message, Exception innerException) : base(message, innerException) 19 | { 20 | } 21 | 22 | /// 23 | /// The fallback text associated with this card, if provided by the card author 24 | /// 25 | public string CardFallbackText { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/SeparatorConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | 9 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 10 | public class SeparatorConfig 11 | { 12 | /// 13 | /// If there is a visible line, how thick should the line be 14 | /// 15 | public int LineThickness { get; set; } = 1; 16 | 17 | /// 18 | /// If there is a visible color, what color to use 19 | /// 20 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 21 | public string LineColor { get; set; } = "#FF707070"; 22 | 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/SpacingsConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// Specifies how much spacing should be used for the various spacing options 10 | /// 11 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 12 | public class SpacingsConfig 13 | { 14 | public int Small { get; set; } = 3; 15 | 16 | public int Default { get; set; } = 8; 17 | 18 | public int Medium { get; set; } = 20; 19 | 20 | public int Large { get; set; } = 30; 21 | 22 | public int ExtraLarge { get; set; } = 40; 23 | 24 | public int Padding { get; set; } = 15; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveColumnSize.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Controls the horizontal size (width) of Column. 9 | /// 10 | [Obsolete("ColumnSize has been deprecated. Use ColumnWidth", false)] 11 | public class AdaptiveColumnSize 12 | { 13 | /// 14 | /// The width of the Column is optimally chosen depending on the space available in the element's container 15 | /// 16 | public const string Auto = "Auto"; 17 | 18 | /// 19 | /// The width of the Column adjusts to match that of its container 20 | /// 21 | public const string Stretch = "Stretch"; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveSerializationException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Represents an exception that occurs during serialization. 9 | /// 10 | public class AdaptiveSerializationException : AdaptiveException 11 | { 12 | /// 13 | public AdaptiveSerializationException() 14 | { 15 | } 16 | 17 | /// 18 | public AdaptiveSerializationException(string message) : base(message) 19 | { 20 | } 21 | 22 | /// 23 | public AdaptiveSerializationException(string message, Exception innerException) : base(message, innerException) 24 | { 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/AdaptiveConfigBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections.Generic; 4 | using Newtonsoft.Json; 5 | using Newtonsoft.Json.Linq; 6 | using Newtonsoft.Json.Serialization; 7 | 8 | namespace AdaptiveCards.Rendering 9 | { 10 | /// 11 | /// Base class for configuration-holding renderer classes. 12 | /// 13 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 14 | public abstract class AdaptiveConfigBase 15 | { 16 | /// 17 | /// Holds additional data in a configuration that doesn't map to known properties. 18 | /// 19 | [JsonExtensionData] 20 | public IDictionary AdditionalData { get; set; } = new Dictionary(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveChoiceInputStyle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// The style of ChoiceInput to display. 10 | /// 11 | [JsonConverter(typeof(StringEnumConverter), true)] 12 | public enum AdaptiveChoiceInputStyle 13 | { 14 | /// 15 | /// Compact display similar to a ComboBox. 16 | /// 17 | Compact, 18 | 19 | /// 20 | /// Expanded display i.e. Checkbox or Radio buttons. 21 | /// 22 | Expanded, 23 | 24 | /// 25 | /// Allows users to filter choices in a choice set. 26 | /// 27 | Filtered 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveVerticalContentAlignment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Controls the vertical alignment of child elements within a container. 9 | /// 10 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 11 | public enum AdaptiveVerticalContentAlignment 12 | { 13 | /// 14 | /// Align to the top. 15 | /// 16 | Top, 17 | 18 | /// 19 | /// Center within the container. 20 | /// 21 | Center, 22 | 23 | /// 24 | /// Align to the bottom of the container. 25 | /// 26 | Bottom 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/FontStyleConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 9 | public class FontStyleConfig 10 | { 11 | public FontStyleConfig() { } 12 | 13 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 14 | public string FontFamily { get; set; } 15 | 16 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 17 | public FontSizesConfig FontSizes { get; set; } = new FontSizesConfig(); 18 | 19 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 20 | public FontWeightsConfig FontWeights { get; set; } = new FontWeightsConfig(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/HighlightColorConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Newtonsoft.Json; 5 | using Newtonsoft.Json.Serialization; 6 | 7 | namespace AdaptiveCards.Rendering 8 | { 9 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 10 | public class HighlightColorConfig 11 | { 12 | public HighlightColorConfig() 13 | { 14 | this.Default = this.Subtle = "#FFFFFF00"; 15 | } 16 | 17 | /// 18 | /// Color in #RRGGBB format 19 | /// 20 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 21 | public string Default { get; set; } 22 | 23 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 24 | public string Subtle { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/RemoteResourceInformation.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace AdaptiveCards 5 | { 6 | /// 7 | /// Contains information about a remote source. 8 | /// 9 | public struct RemoteResourceInformation 10 | { 11 | readonly string url; 12 | readonly string mimeType; 13 | 14 | /// 15 | /// Initializes a with the given properties. 16 | /// 17 | /// The URL of the remote resource. 18 | /// The mimetype of the remote resource. 19 | public RemoteResourceInformation(string url, string mimeType) 20 | { 21 | this.url = url; 22 | this.mimeType = mimeType; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveHorizontalContentAlignment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Controls the horizontal alignment of child elements within a container. 9 | /// 10 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 11 | public enum AdaptiveHorizontalContentAlignment 12 | { 13 | /// 14 | /// Align to the leading edge of the container. 15 | /// 16 | Left, 17 | 18 | /// 19 | /// Center within the container. 20 | /// 21 | Center, 22 | 23 | /// 24 | /// Align to the trailing edge of the container. 25 | /// 26 | Right 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf.Xceed/XceedChoiceSetInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Windows; 6 | using System.Windows.Controls; 7 | using System.Windows.Data; 8 | using Xceed.Wpf.Toolkit; 9 | 10 | namespace AdaptiveCards.Rendering.Wpf 11 | { 12 | public static class XceedChoiceSetInput 13 | { 14 | public static FrameworkElement Render(AdaptiveChoiceSetInput input, AdaptiveRenderContext context) 15 | { 16 | // Use xceed's WatermarkComboBox to support placeholder 17 | var comboBox = new WatermarkComboBox 18 | { 19 | Watermark = input.Placeholder 20 | }; 21 | 22 | return AdaptiveChoiceSetRenderer.RenderHelper(new Grid(), comboBox, new StackPanel(), input, context); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Samples/AdaptiveCards.Sample.ImageRender/AdaptiveCards.Sample.ImageRender.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net4.5.2 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/ViewImageWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.IO; 4 | using System.Windows; 5 | using System.Windows.Media.Imaging; 6 | 7 | namespace WpfVisualizer 8 | { 9 | /// 10 | /// Interaction logic for ViewImageWindow.xaml 11 | /// 12 | public partial class ViewImageWindow : Window 13 | { 14 | public ViewImageWindow(Stream sourceImageStream) 15 | { 16 | InitializeComponent(); 17 | 18 | var localStream = new MemoryStream(); 19 | sourceImageStream.CopyTo(localStream); 20 | localStream.Position = 0; 21 | var source = new BitmapImage(); 22 | source.BeginInit(); 23 | source.StreamSource = localStream; 24 | source.EndInit(); 25 | PreviewImage.Source = source; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Test/AdaptiveCards.Test/AdaptiveCards.Test.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | false 6 | false 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/MarkedNet/Marked.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | 7 | namespace Microsoft.MarkedNet 8 | { 9 | public class Marked 10 | { 11 | public Options Options { get; set; } 12 | 13 | 14 | public Marked() 15 | : this(null) 16 | { 17 | } 18 | 19 | public Marked(Options options) 20 | { 21 | Options = options ?? new Options(); 22 | } 23 | 24 | 25 | public virtual string Parse(string src) 26 | { 27 | if (String.IsNullOrEmpty(src)) 28 | { 29 | return src; 30 | } 31 | 32 | src = Options.Renderer.Preprocess(src); 33 | var tokens = Lexer.Lex(src, Options); 34 | var result = Parser.Parse(tokens, Options); 35 | return Options.Renderer.Postprocess(result); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveFallbackException.cs: -------------------------------------------------------------------------------- 1 | // Copyright (C) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// An exception thrown while processing fallback. 9 | /// 10 | /// 11 | /// This exception is intended to be caught and handled by an element that has a fallback action. 12 | /// 13 | public class AdaptiveFallbackException: AdaptiveException 14 | { 15 | /// 16 | public AdaptiveFallbackException() 17 | { 18 | } 19 | 20 | /// 21 | public AdaptiveFallbackException(string message) : base(message) 22 | { 23 | } 24 | 25 | /// 26 | public AdaptiveFallbackException(string message, Exception innerException) : base(message, innerException) 27 | { 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/ContainerStyleConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 9 | public class ContainerStyleConfig 10 | { 11 | public ContainerStyleConfig() { } 12 | 13 | /// 14 | /// The background color to use for this container 15 | /// 16 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 17 | public string BackgroundColor { get; set; } = "#FFFFFFFF"; 18 | 19 | /// 20 | /// The font colors to use for this container 21 | /// 22 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 23 | public ForegroundColorsConfig ForegroundColors { get; set; } = new ForegroundColorsConfig(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveImageStyle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Newtonsoft.Json; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Controls the way Image elements are displayed. 10 | /// 11 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 12 | public enum AdaptiveImageStyle 13 | { 14 | /// 15 | /// The image is displayed within a rectangle. 16 | /// 17 | Default = 0, 18 | 19 | /// 20 | /// The image is displayed within a rectangle. 21 | /// 22 | [Obsolete("ImageStyle.Normal has been deprecated. Use ImageStyle.Default", false)] 23 | Normal = 0, 24 | 25 | /// 26 | /// The image is cropped to a circle, a common way to represent people photos. 27 | /// 28 | Person = 1 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveHorizontalAlignment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Controls how elements are horizontally positioned within their container. 10 | /// 11 | [JsonConverter(typeof(StringEnumConverter), true)] 12 | public enum AdaptiveHorizontalAlignment 13 | { 14 | /// 15 | /// The element is left aligned 16 | /// 17 | Left, 18 | 19 | /// 20 | /// The element is centered inside its container 21 | /// 22 | Center, 23 | 24 | /// 25 | /// The element is right aligned 26 | /// 27 | Right, 28 | 29 | /// 30 | /// Stretch the actions to fit the containerhrit 31 | /// 32 | Stretch 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTextWeight.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Newtonsoft.Json; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Controls the weight of TextBock Elements 10 | /// 11 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 12 | public enum AdaptiveTextWeight 13 | { 14 | /// 15 | /// The default text weight 16 | /// 17 | Default = 0, 18 | 19 | /// 20 | /// The default text weight 21 | /// 22 | [Obsolete("TextWeight.Normal has been deprecated. Use TextWeight.Default", false)] 23 | Normal = 0, 24 | 25 | /// 26 | /// Lighter text (thinner stroke) 27 | /// 28 | Lighter = 1, 29 | 30 | /// 31 | /// Bolder text (wider stroke) 32 | /// 33 | Bolder = 2 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/FontStylesConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 9 | public class FontTypesConfig 10 | { 11 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 12 | public FontStyleConfig Default { get; set; } = new FontStyleConfig(); 13 | 14 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 15 | public FontStyleConfig Monospace { get; set; } = new FontStyleConfig(); 16 | 17 | public FontStyleConfig GetFontType(AdaptiveFontType fontType) 18 | { 19 | switch (fontType) 20 | { 21 | case AdaptiveFontType.Monospace: 22 | return Monospace; 23 | case AdaptiveFontType.Default: 24 | default: 25 | return Default; 26 | } 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/LabelConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// Properties which control rendering of input labels 10 | /// 11 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 12 | public class LabelConfig 13 | { 14 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 15 | public InputLabelConfig RequiredInputs { get; set; } = new InputLabelConfig(); 16 | 17 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public InputLabelConfig OptionalInputs { get; set; } = new InputLabelConfig(); 19 | 20 | /// 21 | /// Specifies the spacing between the label and the input 22 | /// 23 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 24 | public AdaptiveSpacing InputSpacing { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveFactSet.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections.Generic; 4 | using System.Xml.Serialization; 5 | using Newtonsoft.Json; 6 | 7 | namespace AdaptiveCards 8 | { 9 | /// 10 | /// Represents the FactSet element. 11 | /// 12 | #if !NETSTANDARD1_3 13 | [XmlType(TypeName = AdaptiveFactSet.TypeName)] 14 | #endif 15 | public class AdaptiveFactSet : AdaptiveElement 16 | { 17 | /// 18 | public const string TypeName = "FactSet"; 19 | 20 | /// 21 | #if !NETSTANDARD1_3 22 | [XmlIgnore] 23 | #endif 24 | public override string Type { get; set; } = TypeName; 25 | 26 | /// 27 | /// A collection of Facts to this FactSet contains. 28 | /// 29 | [JsonRequired] 30 | #if !NETSTANDARD1_3 31 | [XmlElement(Type = typeof(AdaptiveFact), ElementName = "Fact")] 32 | #endif 33 | public List Facts { get; set; } = new List(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Microsoft 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveShowCardAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System.Xml.Serialization; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Represents the Action.ShowCard element. 10 | /// 11 | #if !NETSTANDARD1_3 12 | [XmlType(TypeName = AdaptiveShowCardAction.TypeName)] 13 | #endif 14 | public class AdaptiveShowCardAction : AdaptiveAction 15 | { 16 | /// 17 | public const string TypeName = "Action.ShowCard"; 18 | 19 | /// 20 | #if !NETSTANDARD1_3 21 | [XmlIgnore] 22 | #endif 23 | public override string Type { get; set; } = TypeName; 24 | 25 | /// 26 | /// to show when the action is invoked. 27 | /// 28 | [JsonProperty(Required = Required.Always)] 29 | #if !NETSTANDARD1_3 30 | [XmlElement(typeof(AdaptiveCard), ElementName = AdaptiveCard.TypeName)] 31 | #endif 32 | public AdaptiveCard Card { get; set; } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveImageSize.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Controls the horizontal size (width) of element. 9 | /// 10 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 11 | public enum AdaptiveImageSize 12 | { 13 | /// 14 | /// The width of the element is optimally chosen depending on the space available in the element's container 15 | /// 16 | Auto, 17 | 18 | /// 19 | /// The width of the element adjusts to match that of its container 20 | /// 21 | Stretch, 22 | 23 | /// 24 | /// Small width 25 | /// 26 | Small, 27 | 28 | /// 29 | /// Medium width 30 | /// 31 | Medium, 32 | 33 | /// 34 | /// Large width 35 | /// 36 | Large 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/SyntaxHighlighting/JSON.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | true 12 | false 13 | 14 | 15 | " 16 | (?=:) 17 | 18 | 19 | 20 | (?<=:)\040"[^"]* 21 | 22 | " 23 | 24 | \b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)? 25 | 26 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/License.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Microsoft Corp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/MediaConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// Properties which control rendering of media 10 | /// 11 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 12 | public class MediaConfig 13 | { 14 | /// 15 | /// Default poster URL to use for media thumbnail 16 | /// 17 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public string DefaultPoster { get; set; } 19 | 20 | /// 21 | /// Play button URL to use for media thumbnail 22 | /// 23 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 24 | public string PlayButton { get; set; } 25 | 26 | /// 27 | /// Controls whether the media is played in the card or sent to host 28 | /// 29 | public bool AllowInlinePlayback { get; set; } = true; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/App.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Configuration; 6 | using System.Data; 7 | using System.IO; 8 | using System.Linq; 9 | using System.Threading.Tasks; 10 | using System.Windows; 11 | 12 | namespace WpfVisualizer 13 | { 14 | /// 15 | /// Interaction logic for App.xaml 16 | /// 17 | public partial class App : Application 18 | { 19 | public App() 20 | { 21 | SetCurrentDirectory(); 22 | } 23 | 24 | /// 25 | /// Sets the current directory to the app's output directory. This is needed for Desktop Bridge, which 26 | /// defaults to the Windows directory. 27 | /// 28 | private void SetCurrentDirectory() 29 | { 30 | // Gets the location of the EXE, including the EXE name 31 | var exePath = typeof(App).Assembly.Location; 32 | var outputDir = Path.GetDirectoryName(exePath); 33 | Directory.SetCurrentDirectory(outputDir); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/MarkedNetLicense.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Alex Titarenko, Christopher Jeffrey 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to find out which attributes exist for C# debugging 3 | // Use hover for the description of the existing attributes 4 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/Test/AdaptiveCards.Rendering.Html.Test/bin/Debug/netcoreapp1.1/AdaptiveCards.Rendering.Html.Test.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/Test/AdaptiveCards.Rendering.Html.Test", 16 | // For more information about the 'console' field, see https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md#console-terminal-window 17 | "console": "internalConsole", 18 | "stopAtEntry": false, 19 | "internalConsoleOptions": "openOnSessionStart" 20 | }, 21 | { 22 | "name": ".NET Core Attach", 23 | "type": "coreclr", 24 | "request": "attach", 25 | "processId": "${command:pickProcess}" 26 | } 27 | ] 28 | } 29 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTokenExchangeResource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System.Xml.Serialization; 5 | 6 | namespace AdaptiveCards 7 | { 8 | public class AdaptiveTokenExchangeResource 9 | { 10 | /// 11 | /// The unique identifier of this token exchange instance. 12 | /// 13 | [JsonRequired] 14 | #if !NETSTANDARD1_3 15 | [XmlAttribute] 16 | #endif 17 | public string Id { get; set; } 18 | 19 | /// 20 | /// An application ID or resource identifier with which to exchange a token on behalf of. 21 | /// This property is identity provider- and application-specific. 22 | /// 23 | [JsonRequired] 24 | #if !NETSTANDARD1_3 25 | [XmlAttribute] 26 | #endif 27 | public string Uri { get; set; } 28 | 29 | /// 30 | /// An identifier for the identity provider with which to attempt a token exchange. 31 | /// 32 | [JsonRequired] 33 | #if !NETSTANDARD1_3 34 | [XmlAttribute] 35 | #endif 36 | public string ProviderId { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveToggleVisibilityAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System.Collections.Generic; 5 | using System.Xml.Serialization; 6 | 7 | namespace AdaptiveCards 8 | { 9 | /// 10 | /// Represents the Action.ToggleVisibility element. 11 | /// 12 | #if !NETSTANDARD1_3 13 | [XmlType(TypeName = AdaptiveToggleVisibilityAction.TypeName)] 14 | #endif 15 | public class AdaptiveToggleVisibilityAction : AdaptiveAction 16 | { 17 | /// 18 | public const string TypeName = "Action.ToggleVisibility"; 19 | 20 | /// 21 | #if !NETSTANDARD1_3 22 | [XmlIgnore] 23 | #endif 24 | public override string Type { get; set; } = TypeName; 25 | 26 | /// 27 | /// Ids of elements whose visibility this element should change. 28 | /// 29 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 30 | [JsonConverter(typeof(ToggleElementsConverter))] 31 | #if !NETSTANDARD1_3 32 | [XmlElement] 33 | #endif 34 | public List TargetElements { get; set; } = new List(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/ErrorMessageConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// Properties which control rendering of media 10 | /// 11 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 12 | public class ErrorMessageConfig 13 | { 14 | /// 15 | /// The text color of the label 16 | /// 17 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public AdaptiveSpacing Spacing { get; set; } = AdaptiveSpacing.Default; 19 | 20 | /// 21 | /// The text size of the label 22 | /// 23 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 24 | public AdaptiveTextSize Size { get; set; } = AdaptiveTextSize.Default; 25 | 26 | /// 27 | /// The text weight of the label 28 | /// 29 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 30 | public AdaptiveTextWeight Weight { get; set; } = AdaptiveTextWeight.Default; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveSpacing.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Controls the spacing of an element. 9 | /// 10 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 11 | public enum AdaptiveSpacing 12 | { 13 | /// 14 | /// Use the default spacing. 15 | /// 16 | Default, 17 | 18 | /// 19 | /// Use no spacing. 20 | /// 21 | None, 22 | 23 | /// 24 | /// Use small spacing. 25 | /// 26 | Small, 27 | 28 | /// 29 | /// Use medium spacing. 30 | /// 31 | Medium, 32 | 33 | /// 34 | /// Use large spacing. 35 | /// 36 | Large, 37 | 38 | /// 39 | /// Use extra large spacing. 40 | /// 41 | ExtraLarge, 42 | 43 | /// 44 | /// This results in the same padding that's applied to the card itself. 45 | /// 46 | Padding 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTextSize.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Newtonsoft.Json; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Controls the relative size of TextBlock elements 10 | /// 11 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 12 | public enum AdaptiveTextSize 13 | { 14 | /// 15 | /// Default text size 16 | /// 17 | Default = 0, 18 | /// 19 | /// Default text size 20 | /// 21 | [Obsolete("TextSize.Normal has been deprecated. Use Default", false)] 22 | Normal = 0, 23 | 24 | /// 25 | /// Smallest text size 26 | /// 27 | Small = 1, 28 | 29 | /// 30 | /// Slightly larger than default 31 | /// 32 | Medium = 2, 33 | 34 | /// 35 | /// Slightly larger then medium 36 | /// 37 | Large = 3, 38 | 39 | /// 40 | /// The largest text size 41 | /// 42 | ExtraLarge = 4 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Samples/AdaptiveCards.Sample.ImageRender/README.md: -------------------------------------------------------------------------------- 1 | # AdaptiveCards Image Renderer Sample 2 | 3 | This provides a CLI to exercise the .NET WPF Renderer to render to images (`AdaptiveCards.Rendering.Wpf`) 4 | 5 | ## Usage 6 | 7 | If you cloned this repo, run the following command to generate HTML from the Scenario samples. The tool scans a directory for .json files that contain Adaptive Card payloads. 8 | 9 | ```console 10 | Usage: dotnet run [payload-path] [options] 11 | ``` 12 | 13 | ```console 14 | $ dotnet run 15 | ``` 16 | 17 | Or output to a specific directory 18 | 19 | ```console 20 | $ dotnet run -o ./out 21 | ``` 22 | 23 | 24 | ### Arguments 25 | 26 | Name | Description 27 | ---|--- 28 | path | The path that contains JSON card payloads 29 | 30 | ### Options 31 | 32 | Short | Long | Description 33 | ---|---|--- 34 | -h |--help | Show help information 35 | -r |--recursive | Recurse the directory for all JSON files 36 | -o |--out | The directory to output the image(s) to 37 | -i | --supports-interactivity | Include actions and inputs in the output 38 | n/a | --host-config | Specify a host config file 39 | 40 | ## Example to use Windows Notification host config 41 | 42 | ```console 43 | dotnet run ../../../../samples -r -i -o ./out --host-config ../../../../samples/hostconfig/windows-notification.json 44 | ``` -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/XamlUtilities.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | namespace AdaptiveCards.Rendering.Wpf 4 | { 5 | 6 | public class XamlUtilities 7 | { 8 | /// 9 | /// Get fallback text from the speech element 10 | /// 11 | /// 12 | /// 13 | public static string GetFallbackText(AdaptiveElement adaptiveElement) 14 | { 15 | #pragma warning disable CS0618 // Type or member is obsolete 16 | if (!string.IsNullOrEmpty(adaptiveElement.Speak)) 17 | { 18 | var doc = new System.Xml.XmlDocument(); 19 | var xml = adaptiveElement.Speak; 20 | if (!xml.Trim().StartsWith("<")) 21 | xml = $"\n{xml}"; 22 | else if (!xml.StartsWith("\n{xml}"; 24 | doc.LoadXml(xml); 25 | return doc.InnerText; 26 | } 27 | #pragma warning restore CS0618 // Type or member is obsolete 28 | 29 | return null; 30 | } 31 | 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTextInputStyle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Style of text input. 10 | /// 11 | [JsonConverter(typeof(StringEnumConverter), true)] 12 | public enum AdaptiveTextInputStyle 13 | { 14 | /// 15 | /// Unstructured plain text. 16 | /// 17 | Text, 18 | 19 | /// 20 | /// Input is a telephone number. The client may use this information to provide optimized keyboard input for the 21 | /// user. 22 | /// 23 | Tel, 24 | 25 | /// 26 | /// Input is a url. The client may use this information to provide optimized keyboard input for the user. 27 | /// 28 | Url, 29 | 30 | /// 31 | /// Input is an email address. The client may use this information to provide optimized keyboard input for the user. 32 | /// 33 | Email, 34 | 35 | /// 36 | /// Display input text with password masking 37 | /// 38 | Password, 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf.Core/AdaptiveCards.Rendering.Wpf.Core.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Library 5 | netcoreapp3.0 6 | true 7 | 8 | false 9 | AdaptiveCards.Rendering.Wpf.Core 10 | AdaptiveCards.Rendering.Wpf 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | MSBuild:Compile 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /Samples/AdaptiveCards.Core.Sample.ImageRender/README.md: -------------------------------------------------------------------------------- 1 | # AdaptiveCards Image Renderer Sample 2 | 3 | This provides a CLI to exercise the .NETCore Renderer to render to images (`AdaptiveCards.Rendering.Wpf.Core`) 4 | 5 | ## Usage 6 | 7 | If you cloned this repo, run the following command to generate images from the Scenario samples. The tool scans a directory for .json files that contain Adaptive Card payloads. 8 | 9 | ```console 10 | Usage: dotnet run [payload-path] [options] 11 | ``` 12 | 13 | ```console 14 | $ dotnet run 15 | ``` 16 | 17 | Or output to a specific directory 18 | 19 | ```console 20 | $ dotnet run -- -o ./out 21 | ``` 22 | 23 | 24 | ### Arguments 25 | 26 | Name | Description 27 | ---|--- 28 | path | The path that contains JSON card payloads 29 | 30 | ### Options 31 | 32 | Short | Long | Description 33 | ---|---|--- 34 | -h |--help | Show help information 35 | -r |--recursive | Recurse the directory for all JSON files 36 | -o |--out | The directory to output the image(s) to 37 | -i | --supports-interactivity | Include actions and inputs in the output 38 | n/a | --host-config | Specify a host config file 39 | 40 | ## Example to use Windows Notification host config 41 | 42 | ```console 43 | dotnet run -- ../../../../samples -r -i -o ./out --host-config ../../../../samples/hostconfig/windows-notification.json 44 | ``` -------------------------------------------------------------------------------- /Samples/WPFVisualizer/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | //------------------------------------------------------------------------------ 4 | // 5 | // This code was generated by a tool. 6 | // Runtime Version:4.0.30319.42000 7 | // 8 | // Changes to this file may cause incorrect behavior and will be lost if 9 | // the code is regenerated. 10 | // 11 | //------------------------------------------------------------------------------ 12 | 13 | namespace WpfVisualizer.Properties 14 | { 15 | 16 | 17 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 18 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 19 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 20 | { 21 | 22 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 23 | 24 | public static Settings Default 25 | { 26 | get 27 | { 28 | return defaultInstance; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /RunAllTests.ps1: -------------------------------------------------------------------------------- 1 | Push-Location $PSScriptRoot 2 | 3 | # Disable our build versionning for the tests as it doesn't support .NETCore 4 | $env:XES_DISABLEMSBUILDVERSIONING ="True" 5 | 6 | $testResultsPath = New-Item -ErrorAction Ignore -ItemType directory -Path .\TestResults\$(get-date -f MM-dd-yyyy-HH-mm-ss) 7 | New-Item -ItemType directory $testResultsPath/HTML 8 | New-Item -ItemType directory $testResultsPath/WPF 9 | 10 | $samplesPath = "..\..\..\..\samples" 11 | $v1scenariosPath = $samplesPath + "\v1.0\scenarios" 12 | 13 | Write-Host Running unit tests... 14 | dotnet test .\test\AdaptiveCards.Test 15 | 16 | Write-Host Running WPF tests... 17 | Set-Location .\Samples\AdaptiveCards.Sample.ImageRender 18 | 19 | Write-Host SupportsInteractivity = false... 20 | dotnet run $v1scenariosPath -- -r -o $testResultsPath\WPF\StandardNonInteractive 21 | 22 | Write-Host SupportsInteractivity = true... 23 | dotnet run $v1scenariosPath -- -r -i -o $testResultsPath\WPF\Standard 24 | 25 | Write-Host Windows notification config.... 26 | dotnet run $v1scenariosPath -- -r -o $testResultsPath\WPF\WindowsNotification --host-config $samplesPath\hostconfig\windows-notification.json 27 | 28 | Write-Host Timeline config... 29 | dotnet run $v1scenariosPath -- -r -o $testResultsPath\WPF\WindowsTimeline --host-config $samplesPath\hostconfig\windows-timeline.json 30 | 31 | Pop-Location 32 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/FactSetConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 9 | public class FactSetConfig 10 | { 11 | 12 | /// 13 | /// TextBlock to use for Titles in factsets 14 | /// 15 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 16 | public TextBlockConfig Title { get; set; } = new TextBlockConfig() { Size = AdaptiveTextSize.Default, Color = AdaptiveTextColor.Default, IsSubtle = false, Weight = AdaptiveTextWeight.Bolder, Wrap = true, MaxWidth = 150 }; 17 | 18 | /// 19 | /// TextBlock to use for Values in fact sets 20 | /// 21 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 22 | public TextBlockConfig Value { get; set; } = new TextBlockConfig() { Size = AdaptiveTextSize.Default, Color = AdaptiveTextColor.Default, IsSubtle = false, Weight = AdaptiveTextWeight.Default, Wrap = true }; 23 | 24 | /// 25 | /// Spacing between facts and values 26 | /// 27 | public int Spacing { get; set; } = 10; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/AdaptiveDateInputRenderer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | 7 | namespace AdaptiveCards.Rendering.Wpf 8 | { 9 | public static class AdaptiveDateInputRenderer 10 | { 11 | public static FrameworkElement Render(AdaptiveDateInput input, AdaptiveRenderContext context) 12 | { 13 | var textBox = new TextBox() { Text = input.Value }; 14 | textBox.SetPlaceholder(input.Placeholder); 15 | textBox.Style = context.GetStyle($"Adaptive.Input.Text.Date"); 16 | textBox.SetContext(input); 17 | 18 | DateTime maxDate, minDate; 19 | if ((DateTime.TryParse(input.Max, out maxDate) || DateTime.TryParse(input.Min, out minDate) || input.IsRequired) 20 | && string.IsNullOrEmpty(input.ErrorMessage)) 21 | { 22 | context.Warnings.Add(new AdaptiveWarning((int)AdaptiveWarning.WarningStatusCode.NoErrorMessageForValidatedInput, 23 | "Inputs with validation should include an ErrorMessage")); 24 | } 25 | 26 | context.InputValues.Add(input.Id, new AdaptiveDateInputValue(input, textBox)); 27 | 28 | return textBox; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/AdaptiveTimeInputRenderer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | 7 | namespace AdaptiveCards.Rendering.Wpf 8 | { 9 | public static class AdaptiveTimeInputRenderer 10 | { 11 | public static FrameworkElement Render(AdaptiveTimeInput input, AdaptiveRenderContext context) 12 | { 13 | var textBox = new TextBox() { Text = input.Value }; 14 | textBox.SetPlaceholder(input.Placeholder); 15 | textBox.Style = context.GetStyle("Adaptive.Input.Text.Time"); 16 | textBox.SetContext(input); 17 | 18 | TimeSpan maxTime, minTime; 19 | if ((TimeSpan.TryParse(input.Max, out maxTime) || TimeSpan.TryParse(input.Min, out minTime) || input.IsRequired) 20 | && string.IsNullOrEmpty(input.ErrorMessage)) 21 | { 22 | context.Warnings.Add(new AdaptiveWarning((int)AdaptiveWarning.WarningStatusCode.NoErrorMessageForValidatedInput, 23 | "Inputs with validation should include an ErrorMessage")); 24 | } 25 | 26 | context.InputValues.Add(input.Id, new AdaptiveTimeInputValue(input, textBox)); 27 | 28 | return textBox; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/Helpers/TaskExtensions.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Threading; 5 | using System.Threading.Tasks; 6 | 7 | namespace AdaptiveCards.Rendering.Wpf 8 | { 9 | public static class TaskExtensions 10 | { 11 | private static readonly TaskScheduler _staScheduler = new StaTaskScheduler(1); //numberOfThreads: Environment.ProcessorCount); 12 | 13 | /// 14 | /// Starts a new STA thread. This is necessary for rendering WPF to bitmaps from a console app or server 15 | /// 16 | public static Task StartNewSta(this TaskFactory factory, Func action) 17 | { 18 | return factory.StartNew(action, CancellationToken.None, TaskCreationOptions.None, _staScheduler); 19 | } 20 | 21 | public static async Task WithCancellation(this Task task, CancellationToken cancellationToken) 22 | { 23 | var tcs = new TaskCompletionSource(); 24 | using (cancellationToken.Register( 25 | s => ((TaskCompletionSource)s).TrySetResult(new object()), tcs)) 26 | if (task != await Task.WhenAny(task, tcs.Task)) 27 | throw new OperationCanceledException(cancellationToken); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Samples/ImageRendererServer/ImageRendererServer.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net461 5 | false 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | PreserveNewest 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/AdaptiveNumberInputRenderer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | 7 | namespace AdaptiveCards.Rendering.Wpf 8 | { 9 | 10 | public static class AdaptiveNumberInputRenderer 11 | { 12 | public static FrameworkElement Render(AdaptiveNumberInput input, AdaptiveRenderContext context) 13 | { 14 | var textBox = new TextBox(); 15 | 16 | if (!Double.IsNaN(input.Value)) 17 | { 18 | textBox.Text = input.Value.ToString(); 19 | } 20 | textBox.SetPlaceholder(input.Placeholder); 21 | textBox.Style = context.GetStyle($"Adaptive.Input.Text.Number"); 22 | textBox.SetContext(input); 23 | 24 | if ((!Double.IsNaN(input.Max) || !Double.IsNaN(input.Min) || input.IsRequired) 25 | && string.IsNullOrEmpty(input.ErrorMessage)) 26 | { 27 | context.Warnings.Add(new AdaptiveWarning((int)AdaptiveWarning.WarningStatusCode.NoErrorMessageForValidatedInput, 28 | "Inputs with validation should include an ErrorMessage")); 29 | } 30 | 31 | context.InputValues.Add(input.Id, new AdaptiveNumberInputValue(input, textBox)); 32 | 33 | return textBox; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /Build/SignNugetConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveAuthCardButton.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System.Xml.Serialization; 5 | 6 | namespace AdaptiveCards 7 | { 8 | public class AdaptiveAuthCardButton 9 | { 10 | /// 11 | /// The type of the button. 12 | /// 13 | [JsonRequired] 14 | #if !NETSTANDARD1_3 15 | [XmlAttribute] 16 | #endif 17 | public string Type { get; set; } 18 | 19 | /// 20 | /// The caption of the button. 21 | /// 22 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 23 | #if !NETSTANDARD1_3 24 | [XmlAttribute] 25 | #endif 26 | public string Title { get; set; } 27 | 28 | /// 29 | /// A URL to an image to display alongside the button's caption. 30 | /// 31 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 32 | #if !NETSTANDARD1_3 33 | [XmlAttribute] 34 | #endif 35 | public string Image { get; set; } 36 | 37 | /// 38 | /// The value associated with the button. The meaning of value depends on the button's type. 39 | /// 40 | [JsonRequired] 41 | #if !NETSTANDARD1_3 42 | [XmlAttribute] 43 | #endif 44 | public string Value { get; set; } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/AdaptiveRenderTransformers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | public class AdaptiveRenderTransformers 9 | where TUIElement : class 10 | where TContext : class 11 | { 12 | private readonly Dictionary> _dictionary = new Dictionary>(); 13 | 14 | public void Register(Action transformer) 15 | where TElement : AdaptiveTypedElement 16 | { 17 | _dictionary[typeof(TElement)] = (typedElement, uiElement, context) => transformer((TElement)typedElement, uiElement, context); 18 | } 19 | 20 | public void Remove() 21 | where TElement : AdaptiveTypedElement 22 | { 23 | _dictionary.Remove(typeof(TElement)); 24 | } 25 | 26 | public void Apply(TElement element, TUIElement uiElement, TContext context) 27 | where TElement : AdaptiveTypedElement 28 | { 29 | if (_dictionary.ContainsKey(element.GetType())) 30 | _dictionary[element.GetType()].Invoke(element, uiElement, context); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/RenderedAdaptiveCardBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// The base class for RenderedAdaptiveCard. Renderers extend this class to provide their native UI element property. 10 | /// 11 | public abstract class RenderedAdaptiveCardBase 12 | { 13 | /// 14 | /// The card that the visual was rendered from. 15 | /// 16 | public AdaptiveCard OriginatingCard { get; } 17 | 18 | /// 19 | /// If any modifications were done to the rendered card they will be reported here 20 | /// 21 | public IList Warnings { get; } 22 | 23 | /// 24 | /// Provides access to the input fields on a card 25 | /// 26 | public RenderedAdaptiveCardInputs UserInputs { get; set; } = new RenderedAdaptiveCardInputs(); 27 | 28 | protected RenderedAdaptiveCardBase(AdaptiveCard originatingCard, IList warnings) 29 | { 30 | Warnings = warnings ?? throw new ArgumentNullException(nameof(warnings)); 31 | OriginatingCard = originatingCard ?? throw new ArgumentNullException(nameof(originatingCard)); 32 | } 33 | 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf.Xceed/XceedAdaptiveCardRenderer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | namespace AdaptiveCards.Rendering.Wpf 4 | { 5 | public static class XceedAdaptiveCardRenderer 6 | { 7 | public static void UseXceedElementRenderers(this AdaptiveCardRenderer renderer) 8 | { 9 | renderer.ElementRenderers.Set(XceedTextInput.Render); 10 | renderer.ElementRenderers.Set(XceedNumberInput.Render); 11 | renderer.ElementRenderers.Set(XceedDateInput.Render); 12 | renderer.ElementRenderers.Set(XceedTimeInput.Render); 13 | renderer.ElementRenderers.Set(XceedChoiceSetInput.Render); 14 | } 15 | 16 | public static void UseDefaultElementRenderers(this AdaptiveCardRenderer renderer) 17 | { 18 | renderer.ElementRenderers.Set(AdaptiveTextInputRenderer.Render); 19 | renderer.ElementRenderers.Set(AdaptiveNumberInputRenderer.Render); 20 | renderer.ElementRenderers.Set(AdaptiveDateInputRenderer.Render); 21 | renderer.ElementRenderers.Set(AdaptiveTimeInputRenderer.Render); 22 | renderer.ElementRenderers.Set(AdaptiveChoiceSetRenderer.Render); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/FontWeightsConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 9 | public class FontWeightsConfig 10 | { 11 | public int? Lighter { get; set; } 12 | 13 | public int? Default { get; set; } 14 | 15 | public int? Bolder { get; set; } 16 | 17 | public int? GetFontWeight(AdaptiveTextWeight fontWeight) 18 | { 19 | switch (fontWeight) 20 | { 21 | case AdaptiveTextWeight.Lighter: 22 | return Lighter; 23 | case AdaptiveTextWeight.Bolder: 24 | return Bolder; 25 | case AdaptiveTextWeight.Default: 26 | default: 27 | return Default; 28 | } 29 | } 30 | 31 | public static int GetDefaultFontWeight(AdaptiveTextWeight fontWeight) 32 | { 33 | switch (fontWeight) 34 | { 35 | case AdaptiveTextWeight.Lighter: 36 | return 200; 37 | case AdaptiveTextWeight.Bolder: 38 | return 600; 39 | case AdaptiveTextWeight.Default: 40 | default: 41 | return 400; 42 | } 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTextColor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | 5 | namespace AdaptiveCards 6 | { 7 | /// 8 | /// Controls the color style of TextBlock Elements 9 | /// 10 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 11 | public enum AdaptiveTextColor 12 | { 13 | /// 14 | /// The default color which guarentees appropriate contrast 15 | /// 16 | Default, 17 | 18 | /// 19 | /// Forces the text to be rendered in a dark color which is suitable when displayed over a light background 20 | /// 21 | Dark, 22 | 23 | /// 24 | /// Forces the text to be rendered in a light color which is suitable when displayed over a dark background 25 | /// 26 | Light, 27 | 28 | /// 29 | /// Accent the text 30 | /// 31 | Accent, 32 | 33 | /// 34 | /// Good (such as green) 35 | /// 36 | Good, 37 | 38 | /// 39 | /// Warning (such as yellow) 40 | /// 41 | Warning, 42 | 43 | /// 44 | /// Highlight as needing attention (such as red) 45 | /// 46 | Attention 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/AdaptiveToggleInputRenderer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Net.Http.Headers; 4 | using System.Windows; 5 | using System.Windows.Automation; 6 | using System.Windows.Controls; 7 | 8 | namespace AdaptiveCards.Rendering.Wpf 9 | { 10 | public static class AdaptiveToggleInputRenderer 11 | { 12 | public static FrameworkElement Render(AdaptiveToggleInput input, AdaptiveRenderContext context) 13 | { 14 | var uiToggle = new CheckBox(); 15 | AdaptiveChoiceSetRenderer.SetContent(uiToggle, input.Title, input.Wrap); 16 | uiToggle.Foreground = 17 | context.GetColorBrush(context.Config.ContainerStyles.Default.ForegroundColors.Default.Default); 18 | uiToggle.SetState(input.Value == (input.ValueOn ?? "true")); 19 | uiToggle.Style = context.GetStyle($"Adaptive.Input.Toggle"); 20 | uiToggle.SetContext(input); 21 | 22 | if (input.IsRequired && string.IsNullOrEmpty(input.ErrorMessage)) 23 | { 24 | context.Warnings.Add(new AdaptiveWarning((int)AdaptiveWarning.WarningStatusCode.NoErrorMessageForValidatedInput, 25 | "Inputs with validation should include an ErrorMessage")); 26 | } 27 | 28 | context.InputValues.Add(input.Id, new AdaptiveToggleInputValue(input, uiToggle)); 29 | 30 | return uiToggle; 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveImageSet.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Xml.Serialization; 6 | using Newtonsoft.Json; 7 | 8 | namespace AdaptiveCards 9 | { 10 | /// 11 | /// Represents an ImageSet element. 12 | /// 13 | #if !NETSTANDARD1_3 14 | [XmlType(TypeName = AdaptiveImageSet.TypeName)] 15 | #endif 16 | public class AdaptiveImageSet : AdaptiveElement 17 | { 18 | /// 19 | public const string TypeName = "ImageSet"; 20 | 21 | /// 22 | #if !NETSTANDARD1_3 23 | [XmlIgnore] 24 | #endif 25 | public override string Type { get; set; } = TypeName; 26 | 27 | /// 28 | /// Collection of images to display. 29 | /// 30 | [JsonRequired] 31 | #if !NETSTANDARD1_3 32 | [XmlElement(typeof(AdaptiveImage), ElementName = AdaptiveImage.TypeName)] 33 | #endif 34 | public List Images { get; set; } = new List(); 35 | 36 | /// 37 | /// Specifies the of each image in the set. 38 | /// 39 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 40 | #if !NETSTANDARD1_3 41 | [XmlAttribute] 42 | #endif 43 | [DefaultValue(typeof(AdaptiveImageSize), "auto")] 44 | public AdaptiveImageSize ImageSize { get; set; } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveColumnSet.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections; 4 | using System.Collections.Generic; 5 | using System.Xml.Serialization; 6 | using Newtonsoft.Json; 7 | 8 | namespace AdaptiveCards 9 | { 10 | /// 11 | /// Represents the ColumnSet element. 12 | /// 13 | #if !NETSTANDARD1_3 14 | [XmlType(TypeName = AdaptiveColumnSet.TypeName)] 15 | #endif 16 | public class AdaptiveColumnSet : AdaptiveCollectionElement 17 | { 18 | /// 19 | public const string TypeName = "ColumnSet"; 20 | 21 | /// 22 | #if !NETSTANDARD1_3 23 | [XmlIgnore] 24 | #endif 25 | public override string Type { get; set; } = TypeName; 26 | 27 | /// 28 | /// Collection of Columns that this ColumnSet contains. 29 | /// 30 | [JsonRequired] 31 | #if !NETSTANDARD1_3 32 | [XmlElement(Type = typeof(AdaptiveColumn), ElementName = AdaptiveColumn.TypeName)] 33 | #endif 34 | public List Columns { get; set; } = new List(); 35 | 36 | public override IEnumerator GetEnumerator() 37 | { 38 | return Columns.GetEnumerator(); 39 | } 40 | 41 | public override void Add(AdaptiveElement element) 42 | { 43 | if (element is AdaptiveColumn) 44 | { 45 | Columns.Add(element as AdaptiveColumn); 46 | } 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Test/AdaptiveCards.Test/AdaptiveInputTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Text; 6 | using Microsoft.VisualStudio.TestTools.UnitTesting; 7 | using Newtonsoft.Json; 8 | 9 | namespace AdaptiveCards.Test 10 | { 11 | [TestClass] 12 | public class AdaptiveInputTests 13 | { 14 | [TestMethod] 15 | public void TestThatInputsRequireId() 16 | { 17 | var json = @"{ 18 | ""type"": ""AdaptiveCard"", 19 | ""version"": ""1.0"", 20 | ""body"": [ 21 | { 22 | ""type"": ""Input.Text"" 23 | } 24 | ] 25 | }"; 26 | 27 | var ex = Assert.ThrowsException(() => 28 | { 29 | AdaptiveCard.FromJson(json); 30 | }); 31 | 32 | StringAssert.Contains(ex.Message, "'id'"); 33 | } 34 | 35 | [TestMethod] 36 | public void TestPassWordInputStyle() 37 | { 38 | var expectedJSON = Utilities.BuildExpectedCardJSON("textInput", new SerializableDictionary() { ["style"] = "Password" }); 39 | var testCard = AdaptiveCard.FromJson(expectedJSON); 40 | Assert.IsTrue(testCard.Warnings.Count == 0); 41 | AdaptiveTextInput textInput = Utilities.GetAdaptiveElementWithId(testCard.Card, "textInput") as AdaptiveTextInput; 42 | Assert.IsNotNull(textInput); 43 | Assert.AreEqual(AdaptiveTextInputStyle.Password, textInput.Style); 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveContainerStyle.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Newtonsoft.Json; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Controls which style to apply to a container. 10 | /// 11 | [JsonConverter(typeof(IgnoreDefaultStringEnumConverter), true)] 12 | public enum AdaptiveContainerStyle 13 | { 14 | /// 15 | /// The container is a normal container 16 | /// 17 | [Obsolete("ContainerStyle.Normal has been deprecated. Use ContainerStyle.Default", false)] 18 | Normal = 0, 19 | 20 | /// 21 | /// The container should be displayed using the default style 22 | /// 23 | Default = 0, 24 | 25 | /// 26 | /// The container should be displayed using the emphasis style 27 | /// 28 | Emphasis = 1, 29 | 30 | /// 31 | /// The container should be displayed using the good style 32 | /// 33 | Good = 2, 34 | 35 | /// 36 | /// The container should be displayed using the attention style 37 | /// 38 | Attention = 3, 39 | 40 | /// 41 | /// The container should be displayed using the warning style 42 | /// 43 | Warning = 4, 44 | 45 | /// 46 | /// The container should be displayed using the accent style 47 | /// 48 | Accent = 5 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/IAdaptiveTextElement.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace AdaptiveCards 5 | { 6 | /// 7 | /// Interface encapsulating the properties of an AdaptiveCards element that displays text. 8 | /// 9 | public interface IAdaptiveTextElement 10 | { 11 | /// 12 | /// The size to use while displaying the text. 13 | /// 14 | AdaptiveTextSize Size { get; set; } 15 | 16 | /// 17 | /// The weight to use while displaying the text. 18 | /// 19 | AdaptiveTextWeight Weight { get; set; } 20 | 21 | /// 22 | /// The color to use while displaying the text. 23 | /// 24 | AdaptiveTextColor Color { get; set; } 25 | 26 | /// 27 | /// Make the text less prominent when displayed. 28 | /// 29 | bool IsSubtle { get; set; } 30 | 31 | /// 32 | /// Display the text using italics. 33 | /// 34 | bool Italic { get; set; } 35 | 36 | /// 37 | /// Display this text with strikethrough. 38 | /// 39 | bool Strikethrough { get; set; } 40 | 41 | /// 42 | /// The text to display. 43 | /// 44 | string Text { get; set; } 45 | 46 | /// 47 | /// Controls which is used to display the text. 48 | /// 49 | AdaptiveFontType FontType { get; set; } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.ComponentModel; 6 | using System.Xml.Serialization; 7 | 8 | namespace AdaptiveCards 9 | { 10 | /// 11 | /// Represents any input element. 12 | /// 13 | public abstract class AdaptiveInput : AdaptiveElement 14 | { 15 | /// 16 | /// Sets the input as required for triggering Submit actions. 17 | /// 18 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 19 | #if !NETSTANDARD1_3 20 | [XmlAttribute] 21 | #endif 22 | [DefaultValue(false)] 23 | public bool IsRequired { get; set; } 24 | 25 | /// 26 | /// Label to be shown next to input. 27 | /// 28 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 29 | #if !NETSTANDARD1_3 30 | [XmlAttribute] 31 | #endif 32 | [DefaultValue(null)] 33 | public string Label { get; set; } 34 | 35 | /// 36 | /// Error message to be shown when validation fails. 37 | /// 38 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 39 | #if !NETSTANDARD1_3 40 | [XmlAttribute] 41 | #endif 42 | [DefaultValue(null)] 43 | public string ErrorMessage { get; set; } 44 | 45 | /// 46 | /// The string that will be rendered on a a host with "SupportsInteractivity" set to false. 47 | /// 48 | public abstract string GetNonInteractiveValue(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /Samples/ImageRendererServer/Startup.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading; 10 | using System.Threading.Tasks; 11 | using AdaptiveCards; 12 | using AdaptiveCards.Rendering; 13 | using AdaptiveCards.Rendering.Wpf; 14 | using Microsoft.AspNetCore.Builder; 15 | using Microsoft.AspNetCore.Hosting; 16 | using Microsoft.AspNetCore.Http; 17 | using Microsoft.Extensions.DependencyInjection; 18 | 19 | namespace ImageRendererServer 20 | { 21 | public class Startup 22 | { 23 | // This method gets called by the runtime. Use this method to add services to the container. 24 | // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 25 | public void ConfigureServices(IServiceCollection services) 26 | { 27 | services.AddMvc(); 28 | } 29 | 30 | // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. 31 | public void Configure(IApplicationBuilder app, IHostingEnvironment env) 32 | { 33 | if (env.IsDevelopment()) 34 | { 35 | app.UseDeveloperExceptionPage(); 36 | } 37 | 38 | app.UseMvc(routes => 39 | { 40 | routes.MapRoute( 41 | name: "default", 42 | template: "{controller=Render}/{action=Index}/{cardUrl?}"); 43 | } 44 | ); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveInline.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Xml.Serialization; 8 | 9 | namespace AdaptiveCards 10 | { 11 | /// 12 | /// Represents a single inline text entry. 13 | /// 14 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 15 | public abstract class AdaptiveInline 16 | { 17 | /// 18 | /// The type name of the inline. 19 | /// 20 | [JsonProperty(Order = -10, Required = Required.Always, DefaultValueHandling = DefaultValueHandling.Include)] 21 | #if !NETSTANDARD1_3 22 | // don't serialize type with xml, because we use element name or attribute for type 23 | [XmlIgnore] 24 | #endif 25 | public abstract string Type { get; set; } 26 | 27 | /// 28 | [JsonExtensionData] 29 | #if NETSTANDARD1_3 30 | public IDictionary AdditionalProperties { get; set; } = new Dictionary(StringComparer.OrdinalIgnoreCase); 31 | #else 32 | // Dictionary<> is not supported with XmlSerialization because Dictionary is not serializable, SerializableDictionary<> is 33 | [XmlElement] 34 | public SerializableDictionary AdditionalProperties { get; set; } = new SerializableDictionary(StringComparer.OrdinalIgnoreCase); 35 | 36 | /// 37 | public bool ShouldSerializeAdditionalProperties() => this.AdditionalProperties.Count > 0; 38 | #endif 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveRefresh.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | using System.Collections.Generic; 6 | using System.Xml.Serialization; 7 | 8 | namespace AdaptiveCards 9 | { 10 | /// 11 | /// Represents how a card can be refreshed by making a request to the target Bot 12 | /// 13 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 14 | #if !NETSTANDARD1_3 15 | [XmlType(TypeName = "Refresh")] 16 | #endif 17 | public class AdaptiveRefresh 18 | { 19 | /// 20 | /// The action to be executed to refresh the card. 21 | /// Clients can run this refresh action automatically or can provide an affordance for users to trigger it manually. 22 | /// 23 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 24 | #if !NETSTANDARD1_3 25 | [XmlElement(typeof(AdaptiveExecuteAction))] 26 | #endif 27 | public AdaptiveExecuteAction Action { get; set; } 28 | 29 | /// 30 | /// A list of user Ids informing the client for which users should the refresh action should be run automatically. 31 | /// Some clients will not run the refresh action automatically unless this property is specified. 32 | /// Some clients may ignore this property and always run the refresh action automatically. 33 | /// 34 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 35 | #if !NETSTANDARD1_3 36 | [XmlAttribute] 37 | #endif 38 | public List UserIds { get; set; } = new List(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/RenderedAdaptiveCard.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Windows; 6 | 7 | namespace AdaptiveCards.Rendering.Wpf 8 | { 9 | public class RenderedAdaptiveCard : RenderedAdaptiveCardBase 10 | { 11 | public RenderedAdaptiveCard( 12 | FrameworkElement frameworkElement, 13 | AdaptiveCard originatingCard, 14 | IList warnings, 15 | ref IDictionary> inputBindings) 16 | : base(originatingCard, warnings) 17 | { 18 | FrameworkElement = frameworkElement; 19 | UserInputs = new RenderedAdaptiveCardInputs(ref inputBindings); 20 | } 21 | 22 | /// 23 | /// The rendered card 24 | /// 25 | public FrameworkElement FrameworkElement { get; } 26 | 27 | /// 28 | /// Event handler for when user invokes an action. 29 | /// 30 | public event TypedEventHandler OnAction; 31 | 32 | internal void InvokeOnAction(AdaptiveActionEventArgs args) 33 | { 34 | OnAction?.Invoke(this, args); 35 | } 36 | 37 | /// 38 | /// Event handler for when user clicks a media. 39 | /// 40 | public event TypedEventHandler OnMediaClicked; 41 | 42 | internal void InvokeOnMediaClick(AdaptiveMediaEventArgs args) 43 | { 44 | OnMediaClicked?.Invoke(this, args); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveMediaSource.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Xml.Serialization; 4 | using Newtonsoft.Json; 5 | using Newtonsoft.Json.Serialization; 6 | 7 | namespace AdaptiveCards 8 | { 9 | /// 10 | /// Represents a "media source" for a Media element. 11 | /// 12 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 13 | #if !NETSTANDARD1_3 14 | [XmlType(TypeName = "MediaSource")] 15 | #endif 16 | public class AdaptiveMediaSource 17 | { 18 | /// 19 | /// Initializes an empty . 20 | /// 21 | public AdaptiveMediaSource() 22 | { 23 | } 24 | 25 | /// 26 | /// Initializes an instance with the given properties. 27 | /// 28 | /// The mime type of the media. 29 | /// The url from which to load the media. 30 | public AdaptiveMediaSource(string mimeType, string url) 31 | { 32 | MimeType = mimeType; 33 | Url = url; 34 | } 35 | 36 | /// 37 | /// The mime type of this media source. 38 | /// 39 | [JsonRequired] 40 | #if !NETSTANDARD1_3 41 | [XmlAttribute] 42 | #endif 43 | public string MimeType { get; set; } 44 | 45 | /// 46 | /// The URL of this media source. 47 | /// 48 | [JsonRequired] 49 | #if !NETSTANDARD1_3 50 | [XmlAttribute] 51 | #endif 52 | public string Url { get; set; } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveActionSet.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Newtonsoft.Json; 9 | using System.Xml.Serialization; 10 | 11 | namespace AdaptiveCards 12 | { 13 | /// 14 | /// Represents the ActionSet element. 15 | /// 16 | #if !NETSTANDARD1_3 17 | [XmlType(TypeName = AdaptiveActionSet.TypeName)] 18 | #endif 19 | public class AdaptiveActionSet : AdaptiveElement 20 | { 21 | /// 22 | /// The AdaptiveCard element that this class implements. 23 | /// 24 | public const string TypeName = "ActionSet"; 25 | 26 | /// 27 | /// The JSON property name that this class implements. 28 | /// 29 | #if !NETSTANDARD1_3 30 | [XmlIgnore] 31 | #endif 32 | [JsonProperty(Required = Required.Default)] 33 | public override string Type { get; set; } = TypeName; 34 | 35 | /// 36 | /// The actions contained within this ActionSet. 37 | /// 38 | [JsonConverter(typeof(IgnoreEmptyItemsConverter))] 39 | #if !NETSTANDARD1_3 40 | [XmlElement(typeof(AdaptiveOpenUrlAction))] 41 | [XmlElement(typeof(AdaptiveShowCardAction))] 42 | [XmlElement(typeof(AdaptiveSubmitAction))] 43 | [XmlElement(typeof(AdaptiveToggleVisibilityAction))] 44 | [XmlElement(typeof(AdaptiveExecuteAction))] 45 | [XmlElement(typeof(AdaptiveUnknownAction))] 46 | #endif 47 | public List Actions { get; set; } = new List(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveOpenUrlAction.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.ComponentModel; 6 | using System.Xml; 7 | using System.Xml.Schema; 8 | using System.Xml.Serialization; 9 | 10 | namespace AdaptiveCards 11 | { 12 | /// 13 | /// When ActionOpenUrl is invoked it will show the given url, either by launching it to an external web 14 | /// browser or showing in-situ with embedded web browser. 15 | /// 16 | #if !NETSTANDARD1_3 17 | [XmlType(TypeName = AdaptiveOpenUrlAction.TypeName)] 18 | #endif 19 | public class AdaptiveOpenUrlAction : AdaptiveAction 20 | { 21 | /// 22 | public const string TypeName = "Action.OpenUrl"; 23 | 24 | /// 25 | #if !NETSTANDARD1_3 26 | [XmlIgnore] 27 | #endif 28 | public override string Type { get; set; } = TypeName; 29 | 30 | /// 31 | /// Url to open using default operating system browser. 32 | /// 33 | [JsonRequired] 34 | #if !NETSTANDARD1_3 35 | [XmlIgnore] 36 | #endif 37 | [DefaultValue(null)] 38 | public Uri Url { get; set; } 39 | 40 | /// 41 | /// This is necessary for XML serialization. You should use the property directly. 42 | /// 43 | #if !NETSTANDARD1_3 44 | [XmlAttribute("Url")] 45 | [Browsable(false), EditorBrowsable(EditorBrowsableState.Never)] 46 | #endif 47 | [JsonIgnore] 48 | public string UrlString 49 | { 50 | get { return Url?.ToString(); } 51 | set { Url = new Uri(value); } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Test/AdaptiveCards.Test/AdaptiveSchemaVersionTests.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using Microsoft.VisualStudio.TestTools.UnitTesting; 9 | 10 | namespace AdaptiveCards.Test 11 | { 12 | [TestClass] 13 | public class AdaptiveSchemaVersionTests 14 | { 15 | [TestMethod] 16 | public void OperatorTests() 17 | { 18 | var v10 = new AdaptiveSchemaVersion(1, 0); 19 | var v11 = new AdaptiveSchemaVersion(1, 1); 20 | 21 | Assert.IsFalse(v10 == v11); 22 | Assert.IsFalse(v10.Equals(v11)); 23 | Assert.IsTrue(v11 > v10); 24 | Assert.IsTrue(v10 < v11); 25 | Assert.IsTrue(v11 >= v10); 26 | } 27 | 28 | 29 | [TestMethod] 30 | public void TestVersionParsing() 31 | { 32 | var json = @"{ 33 | ""type"": ""AdaptiveCard"", 34 | ""version"": ""1.1"" 35 | }"; 36 | 37 | var result = AdaptiveCard.FromJson(json); 38 | 39 | Assert.AreEqual(new AdaptiveSchemaVersion(1, 1), result.Card.Version); 40 | } 41 | 42 | [TestMethod] 43 | public void Test_InvalidVersionStringFailsParsing() 44 | { 45 | var json = @"{ 46 | ""type"": ""AdaptiveCard"", 47 | ""version"": ""invalid"", 48 | ""body"": [ 49 | { 50 | ""type"": ""TextBlock"", 51 | ""text"": ""Hello"" 52 | } 53 | ] 54 | }"; 55 | 56 | Assert.ThrowsException(() => 57 | { 58 | AdaptiveCard.FromJson(json); 59 | }); 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/InputsLabelConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// Properties which control rendering of media 10 | /// 11 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 12 | public class InputLabelConfig 13 | { 14 | /// 15 | /// The text color of the label 16 | /// 17 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 18 | public AdaptiveTextColor Color { get; set; } = AdaptiveTextColor.Default; 19 | 20 | /// 21 | /// Make the label less prominent 22 | /// 23 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 24 | public bool IsSubtle { get; set; } = false; 25 | 26 | /// 27 | /// The text size of the label 28 | /// 29 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 30 | public AdaptiveTextSize Size { get; set; } = AdaptiveTextSize.Default; 31 | 32 | /// 33 | /// Suffix to be displayed next to the label. Only respected for required inputs 34 | /// 35 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 36 | public string Suffix { get; set; } = " *"; 37 | 38 | /// 39 | /// The text weight of the label 40 | /// 41 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 42 | public AdaptiveTextWeight Weight { get; set; } = AdaptiveTextWeight.Default; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/AdaptiveImageSetRenderer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using System.Windows.Media; 6 | 7 | namespace AdaptiveCards.Rendering.Wpf 8 | { 9 | public static class AdaptiveImageSetRenderer 10 | { 11 | public static FrameworkElement Render(AdaptiveImageSet imageSet, AdaptiveRenderContext context) 12 | { 13 | var uiImageSet = new ListBox(); 14 | uiImageSet.BorderThickness = new Thickness(0); 15 | uiImageSet.Background = new SolidColorBrush(Colors.Transparent); 16 | ScrollViewer.SetHorizontalScrollBarVisibility(uiImageSet, ScrollBarVisibility.Disabled); 17 | var itemsPanelTemplate = new ItemsPanelTemplate(); 18 | var factory = new FrameworkElementFactory(typeof(WrapPanel)); 19 | // factory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal); 20 | itemsPanelTemplate.VisualTree = factory; 21 | uiImageSet.ItemsPanel = itemsPanelTemplate; 22 | 23 | uiImageSet.Style = context.GetStyle("Adaptive.ImageSet"); 24 | foreach (var image in imageSet.Images) 25 | { 26 | // Use the imageSize in imageSet for all images if present 27 | if (imageSet.ImageSize != AdaptiveImageSize.Auto) 28 | image.Size = imageSet.ImageSize; 29 | else if (image.Size == AdaptiveImageSize.Auto) 30 | image.Size = context.Config.ImageSet.ImageSize; 31 | 32 | var uiImage = context.Render(image); 33 | uiImageSet.Add(uiImage); 34 | } 35 | 36 | return uiImageSet; 37 | 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /.pipelines/dotnet-ci.yml: -------------------------------------------------------------------------------- 1 | name: $(Year:yy).$(Month).$(DayOfMonth).$(rev:r) 2 | 3 | pr: 4 | branches: 5 | include: 6 | - main 7 | - feature/* 8 | - release/* 9 | 10 | trigger: 11 | branches: 12 | include: 13 | - main 14 | - feature/* 15 | - release/* 16 | batch: True 17 | 18 | variables: 19 | solution: source/dotnet/AdaptiveCards.sln 20 | buildConfiguration: Release 21 | buildPlatform: any cpu 22 | 23 | pool: 24 | name: Azure Pipelines 25 | vmImage: windows-2019 26 | 27 | steps: 28 | - task: UseDotNet@2 29 | displayName: 'Use .NET Core SDK' 30 | inputs: 31 | version: 5.x 32 | - task: NuGetToolInstaller@0 33 | displayName: 'Use NuGet 5.x' 34 | inputs: 35 | versionSpec: 5.x 36 | - task: NuGetCommand@2 37 | displayName: 'NuGet restore' 38 | inputs: 39 | restoreSolution: '$(solution)' 40 | feedsToUse: config 41 | - task: VSBuild@1 42 | displayName: 'Build solution source/dotnet/AdaptiveCards.sln' 43 | inputs: 44 | solution: '$(solution)' 45 | platform: '$(buildPlatform)' 46 | configuration: '$(buildConfiguration)' 47 | - task: VSTest@2 48 | displayName: 'VsTest - testAssemblies' 49 | inputs: 50 | testAssemblyVer2: | 51 | **\!(ref)\*.test.dll 52 | !**\obj\** 53 | searchFolder: '$(System.DefaultWorkingDirectory)\source\dotnet' 54 | runInParallel: true 55 | runTestsInIsolation: true 56 | codeCoverageEnabled: true 57 | platform: '$(buildPlatform)' 58 | configuration: '$(buildConfiguration)' 59 | failOnMinTestsNotRun: true 60 | diagnosticsEnabled: True 61 | - task: PowerShell@1 62 | displayName: 'Run all tests' 63 | inputs: 64 | scriptName: source/dotnet/RunAllTests.ps1 65 | - task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0 66 | displayName: 'Component Detection' -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/RenderedAdaptiveCardInputs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using Newtonsoft.Json.Linq; 6 | 7 | namespace AdaptiveCards.Rendering 8 | { 9 | /// 10 | /// Provides access to the input fields on a card 11 | /// 12 | public class RenderedAdaptiveCardInputs 13 | { 14 | private readonly IDictionary> _inputBindings; 15 | 16 | public RenderedAdaptiveCardInputs() 17 | { 18 | _inputBindings = new Dictionary>(); 19 | } 20 | 21 | public RenderedAdaptiveCardInputs(ref IDictionary> inputBindings) 22 | { 23 | _inputBindings = inputBindings; 24 | } 25 | 26 | /// 27 | /// Read the input fields as a JSON object. All input values will serialize to strings 28 | /// 29 | /// 30 | public JObject AsJson() 31 | { 32 | return JObject.FromObject(AsDictionary()); 33 | } 34 | 35 | /// 36 | /// Read the input fields as a Dictionary. All input values will serialize the strings 37 | /// 38 | /// 39 | public IReadOnlyDictionary AsDictionary() 40 | { 41 | var dic = new Dictionary(); 42 | foreach (var id in _inputBindings.Keys) 43 | { 44 | var value = _inputBindings[id](); 45 | if (value != null) 46 | { 47 | dic[id] = value; 48 | } 49 | } 50 | 51 | return dic; 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveMedia.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Collections.Generic; 4 | using System.ComponentModel; 5 | using System.Xml.Serialization; 6 | using Newtonsoft.Json; 7 | 8 | namespace AdaptiveCards 9 | { 10 | /// 11 | /// Represents the Media element. 12 | /// 13 | #if !NETSTANDARD1_3 14 | [XmlType(TypeName = TypeName)] 15 | #endif 16 | public class AdaptiveMedia : AdaptiveElement 17 | { 18 | /// 19 | public const string TypeName = "Media"; 20 | 21 | /// 22 | #if !NETSTANDARD1_3 23 | [XmlIgnore] 24 | #endif 25 | public override string Type { get; set; } = TypeName; 26 | 27 | /// 28 | /// A collection of source from which to retrieve the media. 29 | /// 30 | [JsonRequired] 31 | #if !NETSTANDARD1_3 32 | [XmlElement(Type = typeof(AdaptiveMediaSource), ElementName = "MediaSource")] 33 | #endif 34 | public List Sources { get; set; } = new List(); 35 | 36 | /// 37 | /// URL for the poster image to show for this media element. 38 | /// 39 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 40 | #if !NETSTANDARD1_3 41 | [XmlAttribute] 42 | #endif 43 | [DefaultValue(null)] 44 | public string Poster { get; set; } 45 | 46 | /// 47 | /// Alternate text to display for this media element. 48 | /// 49 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 50 | #if !NETSTANDARD1_3 51 | [XmlAttribute] 52 | #endif 53 | [DefaultValue(null)] 54 | public string AltText { get; set; } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/TextBlockConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 9 | public class TextBlockConfig 10 | { 11 | /// 12 | /// The size of the text 13 | /// 14 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 15 | public AdaptiveTextSize Size { get; set; } = AdaptiveTextSize.Default; 16 | 17 | /// 18 | /// The weight of the text 19 | /// 20 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 21 | public AdaptiveTextWeight Weight { get; set; } = AdaptiveTextWeight.Default; 22 | 23 | /// 24 | /// The color of the text 25 | /// 26 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 27 | public AdaptiveTextColor Color { get; set; } = AdaptiveTextColor.Default; 28 | 29 | /// 30 | /// Should it be subtle? 31 | /// 32 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 33 | public bool IsSubtle { get; set; } = false; 34 | 35 | /// 36 | /// Is it allowed for the text to wrap 37 | /// 38 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 39 | public bool Wrap { get; set; } 40 | 41 | /// 42 | /// The maximum width for text 43 | /// 44 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.Ignore)] 45 | public int MaxWidth { get; set; } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveRichTextBlock.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | using System.Collections.Generic; 6 | using System.ComponentModel; 7 | using System.Xml.Serialization; 8 | 9 | namespace AdaptiveCards 10 | { 11 | /// 12 | /// Represents the RichTextBlock element. 13 | /// 14 | #if !NETSTANDARD1_3 15 | [XmlType(TypeName = AdaptiveRichTextBlock.TypeName)] 16 | #endif 17 | public class AdaptiveRichTextBlock : AdaptiveElement 18 | { 19 | /// 20 | public const string TypeName = "RichTextBlock"; 21 | 22 | /// 23 | #if !NETSTANDARD1_3 24 | [XmlIgnore] 25 | #endif 26 | public override string Type { get; set; } = TypeName; 27 | 28 | /// 29 | /// Initializes an empty . 30 | /// 31 | public AdaptiveRichTextBlock() 32 | { 33 | } 34 | 35 | /// 36 | /// Horizontal alignment for element. 37 | /// 38 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 39 | #if !NETSTANDARD1_3 40 | [XmlAttribute] 41 | #endif 42 | [DefaultValue(typeof(AdaptiveHorizontalAlignment), "left")] 43 | public AdaptiveHorizontalAlignment HorizontalAlignment { get; set; } 44 | 45 | /// 46 | /// A list of text inlines in this RichTextBlock. 47 | /// 48 | [JsonRequired] 49 | [JsonConverter(typeof(AdaptiveInlinesConverter))] 50 | #if !NETSTANDARD1_3 51 | [XmlElement(typeof(AdaptiveTextRun))] 52 | #endif 53 | public List Inlines { get; set; } = new List(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf.Xceed/XceedNumberInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Windows; 5 | using Xceed.Wpf.Toolkit; 6 | 7 | namespace AdaptiveCards.Rendering.Wpf 8 | { 9 | 10 | public static class XceedNumberInput 11 | { 12 | public static FrameworkElement Render(AdaptiveNumberInput input, AdaptiveRenderContext context) 13 | { 14 | if (context.Config.SupportsInteractivity) 15 | { 16 | 17 | DoubleUpDown numberPicker = new DoubleUpDown(); 18 | 19 | if (!Double.IsNaN(input.Value)) 20 | numberPicker.Value = input.Value; 21 | 22 | numberPicker.Watermark = input.Placeholder; 23 | numberPicker.Style = context.GetStyle("Adaptive.Input.Number"); 24 | numberPicker.DataContext = input; 25 | 26 | numberPicker.Maximum = input.Max; 27 | numberPicker.Minimum = input.Min; 28 | 29 | if (input.IsRequired && string.IsNullOrEmpty(input.ErrorMessage)) 30 | { 31 | context.Warnings.Add(new AdaptiveWarning((int)AdaptiveWarning.WarningStatusCode.NoErrorMessageForValidatedInput, "Inputs with validation should include an ErrorMessage")); 32 | } 33 | 34 | context.InputValues.Add(input.Id, new AdaptiveXceedNumberInputValue(input, numberPicker)); 35 | 36 | return numberPicker; 37 | } 38 | else 39 | { 40 | var textBlock = AdaptiveTypedElementConverter.CreateElement(); 41 | textBlock.Text = XamlUtilities.GetFallbackText(input) ?? input.Placeholder; 42 | return context.Render(textBlock); 43 | } 44 | 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/TagContent.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | using System.Windows; 9 | using System.Windows.Controls; 10 | 11 | namespace AdaptiveCards.Rendering.Wpf 12 | { 13 | /// 14 | /// Class to add to all rendered items so ToggleVisibility can hide the separators or deduct the spacing from the margin 15 | /// 16 | public class TagContent 17 | { 18 | 19 | public TagContent(Grid separator, Grid elementContainer) 20 | { 21 | Separator = separator; 22 | ParentContainerElement = elementContainer; 23 | } 24 | 25 | public Grid Separator { get; set; } = null; 26 | 27 | /// 28 | /// Grid that contains the rendered element 29 | /// 30 | public Grid ParentContainerElement { get; set; } 31 | 32 | /// 33 | /// Column Definition for the rendered column in the columnset 34 | /// 35 | public ColumnDefinition ColumnDefinition { get; set; } = null; 36 | 37 | /// 38 | /// Row Definition for the rendered element in the container 39 | /// 40 | public RowDefinition RowDefinition { get; set; } = null; 41 | 42 | public int ViewIndex { get; set; } 43 | 44 | /// 45 | /// Row Definition for the rendered element in the container 46 | /// 47 | public Panel EnclosingElement { get; set; } 48 | 49 | /// 50 | /// Row Definition for the rendered element in the container 51 | /// 52 | public UIElement ErrorMessage { get; set; } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/AdaptiveRenderArgs.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | // This class contains all properties that are used for rendering and need to be passed down between parent and child elements 10 | namespace AdaptiveCards.Rendering 11 | { 12 | public enum BleedDirection 13 | { 14 | BleedNone = 0x0000, 15 | BleedLeft = 0x0001, 16 | BleedRight = 0x0010, 17 | BleedUp = 0x0100, 18 | BleedDown = 0x1000, 19 | BleedAll = 0x1111 20 | }; 21 | 22 | public class AdaptiveRenderArgs 23 | { 24 | public AdaptiveRenderArgs() { } 25 | 26 | public AdaptiveRenderArgs(AdaptiveRenderArgs previousRenderArgs) 27 | { 28 | ParentStyle = previousRenderArgs.ParentStyle; 29 | ForegroundColors = previousRenderArgs.ForegroundColors; 30 | BleedDirection = previousRenderArgs.BleedDirection; 31 | HasParentWithPadding = previousRenderArgs.HasParentWithPadding; 32 | ContainerCardId = previousRenderArgs.ContainerCardId; 33 | } 34 | 35 | // Default value for the container style of the first adaptiveCard 36 | public AdaptiveContainerStyle ParentStyle { get; set; } = AdaptiveContainerStyle.Default; 37 | 38 | public ForegroundColorsConfig ForegroundColors { get; set; } 39 | 40 | // Default value for the direction where the elements of the adaptive card can bleed to 41 | public BleedDirection BleedDirection { get; set; } = BleedDirection.BleedAll; 42 | 43 | public bool HasParentWithPadding { get; set; } = true; 44 | 45 | public AdaptiveInternalID ContainerCardId { get; set; } = new AdaptiveInternalID(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf.Xceed/AdaptiveCards.Rendering.Wpf.Xceed.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net4.5.2 5 | Microsoft 6 | Adaptive Card renderer for WPF with enhanced input controls provided by the Xceed WPF toolkit 7 | This library implements classes for rendering Adaptive Cards into WPF controls 8 | false 9 | adaptivecards;adaptive-cards 10 | https://adaptivecards.io 11 | https://adaptivecards.io/content/icons_blue/blue-48.png 12 | https://github.com/Microsoft/AdaptiveCards 13 | EULA-Windows.txt 14 | AdaptiveCards.Rendering.Wpf 15 | WPF;$(DefineConstants);$(AdditionalConstants) 16 | © Microsoft Corporation. All rights reserved. 17 | false 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/FontSizesConfig.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Serialization; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | 9 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 10 | public class FontSizesConfig 11 | { 12 | public int? Small { get; set; } 13 | 14 | public int? Default { get; set; } 15 | 16 | public int? Medium { get; set; } 17 | 18 | public int? Large { get; set; } 19 | 20 | public int? ExtraLarge { get; set; } 21 | 22 | public int? GetFontSize(AdaptiveTextSize fontSize) 23 | { 24 | switch (fontSize) 25 | { 26 | case AdaptiveTextSize.Small: 27 | return Small; 28 | case AdaptiveTextSize.Medium: 29 | return Medium; 30 | case AdaptiveTextSize.Large: 31 | return Large; 32 | case AdaptiveTextSize.ExtraLarge: 33 | return ExtraLarge; 34 | case AdaptiveTextSize.Default: 35 | default: 36 | return Default; 37 | } 38 | } 39 | 40 | public static int GetDefaultFontSize(AdaptiveTextSize fontSize) 41 | { 42 | switch (fontSize) 43 | { 44 | case AdaptiveTextSize.Small: 45 | return 12; 46 | case AdaptiveTextSize.Medium: 47 | return 17; 48 | case AdaptiveTextSize.Large: 49 | return 21; 50 | case AdaptiveTextSize.ExtraLarge: 51 | return 26; 52 | case AdaptiveTextSize.Default: 53 | default: 54 | return 14; 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/AdaptiveCards.Rendering.Wpf.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net4.5.2 5 | Microsoft 6 | Adaptive Card renderer for WPF 7 | This library implements classes for rendering Adaptive Cards into WPF controls 8 | false 9 | adaptivecards;adaptive-cards 10 | https://adaptivecards.io 11 | https://adaptivecards.io/content/icons_blue/blue-48.png 12 | https://github.com/Microsoft/AdaptiveCards 13 | EULA-Windows.txt 14 | WPF;$(DefineConstants);$(AdditionalConstants) 15 | © Microsoft Corporation. All rights reserved. 16 | false 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | MSBuild:Compile 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/AdaptiveCardRendererBase.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | 5 | namespace AdaptiveCards.Rendering 6 | { 7 | /// 8 | /// Abstract base class that every AdaptiveCards renderer must implement. 9 | /// 10 | /// The base UI element type the renderer implements (e.g. "HTMLElement" or 11 | /// "FrameworkElement"). 12 | /// The type of the renderer context to use (e.g. "AdaptiveRenderContext"). 13 | public abstract class AdaptiveCardRendererBase 14 | where TUIElement : class 15 | where TContext : class 16 | { 17 | /// 18 | /// Provides the highest schema version that this renderer supports. 19 | /// 20 | protected abstract AdaptiveSchemaVersion GetSupportedSchemaVersion(); 21 | 22 | private AdaptiveSchemaVersion _supportedSchemaVersion; 23 | 24 | /// 25 | /// Provides the highest schema version that this renderer supports. 26 | /// 27 | public AdaptiveSchemaVersion SupportedSchemaVersion => _supportedSchemaVersion ?? (_supportedSchemaVersion = GetSupportedSchemaVersion()); 28 | 29 | /// 30 | /// A Host Configuration object to determine base styling and behavior of the rendered card 31 | /// 32 | public virtual AdaptiveHostConfig HostConfig { get; set; } = new AdaptiveHostConfig(); 33 | 34 | /// 35 | /// The dictionary of supported element types and their associated rendering functions 36 | /// 37 | public virtual AdaptiveElementRenderers ElementRenderers { get; } = new AdaptiveElementRenderers(); 38 | 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveChoice.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.ComponentModel; 5 | using System.Xml.Serialization; 6 | using Newtonsoft.Json; 7 | using Newtonsoft.Json.Serialization; 8 | 9 | namespace AdaptiveCards 10 | { 11 | /// 12 | /// Choice as part of a Input.AdaptiveChoiceSetInput element 13 | /// 14 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 15 | #if !NETSTANDARD1_3 16 | [XmlType(TypeName = "Choice")] 17 | #endif 18 | public class AdaptiveChoice 19 | { 20 | /// 21 | /// Display text for the choice 22 | /// 23 | [JsonRequired] 24 | #if !NETSTANDARD1_3 25 | [XmlAttribute] 26 | #endif 27 | [DefaultValue(null)] 28 | public string Title { get; set; } 29 | 30 | /// 31 | /// Internal value which will be collected as input if the choice is selected 32 | /// 33 | [JsonRequired] 34 | #if !NETSTANDARD1_3 35 | [XmlAttribute] 36 | #endif 37 | [DefaultValue(null)] 38 | public string Value { get; set; } 39 | 40 | /// 41 | /// Is this choice selected? 42 | /// 43 | [Obsolete("Choice.IsSelected has been deprecated. Use AdaptiveChoiceSetInput.Value", false)] 44 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 45 | public bool IsSelected { get; set; } = false; 46 | 47 | /// 48 | /// (OPTIONAL) Speech description of the choice 49 | /// 50 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 51 | [Obsolete("AdaptiveChoiceSetInput.Speak has been deprecated. Use AdaptiveCard.Speak", false)] 52 | public string Speak { get; set; } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveAuthentication.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System.Collections.Generic; 5 | using System.Xml.Serialization; 6 | 7 | namespace AdaptiveCards 8 | { 9 | public class AdaptiveAuthentication 10 | { 11 | /// 12 | /// Text that can be displayed to the end user when prompting them to authenticate. 13 | /// 14 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 15 | #if !NETSTANDARD1_3 16 | [XmlAttribute] 17 | #endif 18 | public string Text { get; set; } 19 | 20 | /// 21 | /// The identifier for registered OAuth connection setting information. 22 | /// 23 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 24 | #if !NETSTANDARD1_3 25 | [XmlAttribute] 26 | #endif 27 | public string ConnectionName { get; set; } 28 | 29 | /// 30 | /// Provides information required to enable on-behalf-of single sign-on user authentication. 31 | /// 32 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 33 | #if !NETSTANDARD1_3 34 | [XmlElement(typeof(AdaptiveTokenExchangeResource))] 35 | #endif 36 | public AdaptiveTokenExchangeResource TokenExchangeResource { get; set; } 37 | 38 | /// 39 | /// Buttons that should be displayed to the user when prompting for authentication. The array MUST contain one button of type \"signin\". Other button types are not currently supported. 40 | /// 41 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 42 | #if !NETSTANDARD1_3 43 | [XmlElement(typeof(AdaptiveAuthCardButton))] 44 | #endif 45 | public List Buttons { get; set; } = new List(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf.Xceed/XceedInputValue.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Windows; 5 | using System.Windows.Controls; 6 | using System.Text.RegularExpressions; 7 | using Xceed.Wpf.Toolkit; 8 | 9 | namespace AdaptiveCards.Rendering.Wpf 10 | { 11 | 12 | public class AdaptiveXceedTextInputValue : AdaptiveTextInputValue 13 | { 14 | public AdaptiveXceedTextInputValue(AdaptiveTextInput inputElement, UIElement renderedElement) : base(inputElement, renderedElement) { } 15 | 16 | public override string GetValue() 17 | { 18 | return (RenderedInputElement as WatermarkTextBox).Text; 19 | } 20 | } 21 | 22 | public class AdaptiveXceedNumberInputValue : AdaptiveNumberInputValue 23 | { 24 | public AdaptiveXceedNumberInputValue(AdaptiveNumberInput inputElement, UIElement renderedElement) : base(inputElement, renderedElement) { } 25 | 26 | public override string GetValue() 27 | { 28 | return (RenderedInputElement as DoubleUpDown).Value?.ToString(); 29 | } 30 | } 31 | 32 | public class AdaptiveXceedDateInputValue : AdaptiveDateInputValue 33 | { 34 | public AdaptiveXceedDateInputValue(AdaptiveDateInput inputElement, UIElement renderedElement) : base(inputElement, renderedElement) { } 35 | 36 | public override string GetValue() 37 | { 38 | return ToIso8601Date((RenderedInputElement as DatePicker).Text); 39 | } 40 | } 41 | 42 | public class AdaptiveXceedTimeInputValue : AdaptiveTimeInputValue 43 | { 44 | public AdaptiveXceedTimeInputValue(AdaptiveTimeInput inputElement, UIElement renderedElement) : base(inputElement, renderedElement) { } 45 | 46 | public override string GetValue() 47 | { 48 | return ToIso8601Time((RenderedInputElement as TimePicker).Text); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveColumn.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System; 5 | using System.ComponentModel; 6 | using System.Xml.Serialization; 7 | 8 | namespace AdaptiveCards 9 | { 10 | /// 11 | /// Represents the Column element. 12 | /// 13 | #if !NETSTANDARD1_3 14 | [XmlType(TypeName = AdaptiveColumn.TypeName)] 15 | #endif 16 | public class AdaptiveColumn : AdaptiveContainer 17 | { 18 | /// 19 | public new const string TypeName = "Column"; 20 | 21 | /// 22 | #if !NETSTANDARD1_3 23 | [XmlIgnore] 24 | #endif 25 | [JsonProperty(Required = Required.Default)] 26 | public override string Type { get; set; } = TypeName; 27 | 28 | /// 29 | /// Size for the column (either ColumnSize string or number which is relative size of the column). 30 | /// 31 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 32 | [Obsolete("Column.Size has been deprecated. Use Column.Width", false)] 33 | public string Size { get; set; } 34 | 35 | /// 36 | /// Width for the column (either ColumnWidth string or number which is relative size of the column). 37 | /// 38 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 39 | #if !NETSTANDARD1_3 40 | [XmlAttribute] 41 | #endif 42 | [DefaultValue(null)] 43 | public string Width { get; set; } // TODO: this should be a ColumnWidth type with implicit converter 44 | 45 | /// 46 | /// Sets the text flow direction 47 | /// 48 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 49 | #if !NETSTANDARD1_3 50 | [XmlElement] 51 | #endif 52 | [DefaultValue(null)] 53 | public bool? Rtl { get; set; } = null; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer.PackageProject/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Adaptive Cards WPF Visualizer (Local) 6 | Adaptive Cards 7 | Images\StoreLogo.png 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveFact.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.ComponentModel; 5 | using System.Xml.Serialization; 6 | using Newtonsoft.Json; 7 | using Newtonsoft.Json.Serialization; 8 | 9 | namespace AdaptiveCards 10 | { 11 | /// 12 | /// Represents a "fact" in a FactSet element. 13 | /// 14 | [JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))] 15 | #if !NETSTANDARD1_3 16 | [XmlType(TypeName = "Fact")] 17 | #endif 18 | public class AdaptiveFact 19 | { 20 | /// 21 | /// Initializes an empty Fact. 22 | /// 23 | public AdaptiveFact() 24 | { } 25 | 26 | /// 27 | /// Initializes a Fact with the given properties. 28 | /// 29 | /// The title of the Fact. 30 | /// The value of the Fact. 31 | public AdaptiveFact(string title, string value) 32 | { 33 | Title = title; 34 | Value = value; 35 | } 36 | 37 | /// 38 | /// The Fact's title. 39 | /// 40 | [JsonRequired] 41 | #if !NETSTANDARD1_3 42 | [XmlAttribute] 43 | #endif 44 | public string Title { get; set; } 45 | 46 | /// 47 | /// The Fact's value. 48 | /// 49 | [JsonRequired] 50 | #if !NETSTANDARD1_3 51 | [XmlAttribute] 52 | #endif 53 | public string Value { get; set; } 54 | 55 | /// 56 | /// (Optional) Specifies what should be spoken for this entire element. This is simple text or SSML fragment. 57 | /// 58 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 59 | [Obsolete("FactSet.Speak has been deprecated. Use AdaptiveCard.Speak", false)] 60 | public string Speak { get; set; } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/MarkedNet/MarkedNet/Options.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace Microsoft.MarkedNet 7 | { 8 | public class Options 9 | { 10 | #region Fields 11 | 12 | private MarkdownRenderer _renderer; 13 | 14 | #endregion 15 | 16 | #region Properties 17 | 18 | public Func Highlight { get; set; } 19 | 20 | public Func Sanitizer { get; set; } 21 | 22 | public MarkdownRenderer Renderer 23 | { 24 | get { return _renderer; } 25 | set { _renderer = value; if (_renderer != null) _renderer.Options = this; } 26 | } 27 | 28 | public string LangPrefix { get; set; } 29 | 30 | public string HeaderPrefix { get; set; } 31 | 32 | public bool XHtml { get; set; } 33 | 34 | public bool Sanitize { get; set; } 35 | 36 | public bool Pedantic { get; set; } 37 | 38 | public bool Mangle { get; set; } 39 | 40 | public bool Smartypants { get; set; } 41 | 42 | public bool Breaks { get; set; } 43 | 44 | public bool Gfm { get; set; } 45 | 46 | public bool Tables { get; set; } 47 | 48 | public bool SmartLists { get; set; } 49 | 50 | public bool EscapeHtml { get; set; } 51 | 52 | #endregion 53 | 54 | #region Constructors 55 | 56 | public Options() 57 | { 58 | Highlight = null; 59 | Sanitizer = null; 60 | Renderer = new MarkdownRenderer(this); 61 | 62 | LangPrefix = "lang-"; 63 | HeaderPrefix = ""; 64 | XHtml = false; 65 | Sanitize = false; 66 | Pedantic = false; 67 | Mangle = false; 68 | Smartypants = false; 69 | Breaks = false; 70 | Gfm = true; 71 | Tables = true; 72 | SmartLists = false; 73 | EscapeHtml = true; 74 | } 75 | 76 | #endregion 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/Rendering/AdaptiveActionHandlers.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | 6 | namespace AdaptiveCards.Rendering 7 | { 8 | /// 9 | /// A collection of actions known by the host. 10 | /// 11 | public class AdaptiveActionHandlers 12 | { 13 | private readonly List _supportedActions = new List() 14 | { 15 | typeof(AdaptiveOpenUrlAction), 16 | typeof(AdaptiveSubmitAction), 17 | typeof(AdaptiveShowCardAction), 18 | typeof(AdaptiveToggleVisibilityAction), 19 | typeof(AdaptiveExecuteAction) 20 | }; 21 | 22 | /// 23 | /// Adds a given action type. Any action in a payload not specified here will be dropped from the rendered card. 24 | /// 25 | /// The type of the action to add. 26 | public void AddSupportedAction() 27 | where TAction : AdaptiveAction 28 | { 29 | _supportedActions.Add(typeof(TAction)); 30 | } 31 | 32 | /// 33 | /// Remove support for an action type. This will prevent these actions from appearing in the rendered card. 34 | /// 35 | /// The type of the action to remove. 36 | public void RemoveSupportedAction() 37 | where TAction : AdaptiveAction 38 | { 39 | _supportedActions.Remove(typeof(TAction)); 40 | } 41 | 42 | /// 43 | /// Determines whether or not the action is supported by the renderer. 44 | /// 45 | /// The Type for which to determine support. 46 | /// true iff the Type is supported. 47 | public bool IsSupported(Type type) 48 | { 49 | return _supportedActions.Contains(type); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveCollectionWithContentAlignment.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | using System.Xml.Serialization; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Serialization; 7 | using System.ComponentModel; 8 | using System.Collections.Generic; 9 | using System.Collections; 10 | 11 | namespace AdaptiveCards 12 | { 13 | /// 14 | /// AdaptiveCard element with content alignment properties 15 | /// 16 | public abstract class AdaptiveCollectionWithContentAlignment : AdaptiveElement, IEnumerable 17 | { 18 | /// 19 | /// The content alignment for the TableCells inside the TableRow. 20 | /// 21 | [JsonProperty("verticalCellContentAlignment", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 22 | #if !NETSTANDARD1_3 23 | [XmlAttribute] 24 | #endif 25 | [DefaultValue(typeof(AdaptiveVerticalContentAlignment), "top")] 26 | public AdaptiveVerticalContentAlignment VerticalContentAlignment { get; set; } 27 | 28 | /// 29 | /// The content alignment for the TableCells inside the TableRow. 30 | /// 31 | [JsonProperty("horizontalCellContentAlignment", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 32 | #if !NETSTANDARD1_3 33 | [XmlAttribute] 34 | #endif 35 | [DefaultValue(typeof(AdaptiveHorizontalContentAlignment), "left")] 36 | public AdaptiveHorizontalContentAlignment HorizontalContentAlignment { get; set; } 37 | 38 | /// 39 | /// Returns enumerator 40 | /// 41 | /// 42 | public abstract IEnumerator GetEnumerator(); 43 | 44 | IEnumerator IEnumerable.GetEnumerator() 45 | { 46 | throw new System.NotImplementedException(); 47 | } 48 | 49 | public void Add(AdaptiveElement element) 50 | { 51 | throw new System.NotImplementedException(); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/IgnoreNullEnumConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | using System; 6 | using System.Collections.Generic; 7 | 8 | namespace AdaptiveCards 9 | { 10 | /// 11 | /// JSON converter that will ignore enum values that can't be parsed correctly. 12 | /// 13 | public class IgnoreNullEnumConverter : StringEnumConverter, ILogWarnings 14 | { 15 | /// 16 | public List Warnings { get; set; } = new List(); 17 | 18 | // TODO: temporary warning code for invalid value. Remove when common set of error codes created and integrated. 19 | private enum WarningStatusCode { UnknownElementType = 0 }; 20 | 21 | /// 22 | public IgnoreNullEnumConverter() 23 | { 24 | } 25 | 26 | /// 27 | public IgnoreNullEnumConverter(bool camelCase) : base(camelCase) 28 | { 29 | } 30 | 31 | /// 32 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 33 | { 34 | try 35 | { 36 | // Try to read regularly 37 | return base.ReadJson(reader, objectType, existingValue, serializer); 38 | } 39 | catch 40 | { 41 | // Catch invalid values and replace them with default value 42 | // Add warning stating behavior 43 | Warnings.Add(new AdaptiveWarning((int)WarningStatusCode.UnknownElementType, $"Value \"{reader.Value.ToString()}\" could not be converted to \"{typeof(TEnum).ToString()}\", using null instead.")); 44 | return null; 45 | } 46 | } 47 | 48 | /// 49 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 50 | { 51 | base.WriteJson(writer, value, serializer); 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Library/AdaptiveCards.Rendering.Wpf/PreFetchImageVisitor.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Concurrent; 5 | using System.Collections.Generic; 6 | using System.IO; 7 | using System.Net; 8 | using System.Threading; 9 | using System.Threading.Tasks; 10 | 11 | namespace AdaptiveCards.Rendering.Wpf 12 | { 13 | /// 14 | /// Walk tree and fetch any images referenced 15 | /// 16 | internal class PreFetchImageVisitor : AdaptiveVisitor 17 | { 18 | private readonly ResourceResolver _resourceResolver; 19 | private readonly List _tasks = new List(); 20 | 21 | public ConcurrentDictionary LoadedImages { get; } = new ConcurrentDictionary(); 22 | 23 | public PreFetchImageVisitor(ResourceResolver resourceResolver) 24 | { 25 | _resourceResolver = resourceResolver; 26 | } 27 | 28 | /// 29 | /// Get all images 30 | /// 31 | public async Task GetAllImages(AdaptiveCard card) 32 | { 33 | Visit(card); 34 | 35 | await Task.WhenAll(_tasks.ToArray()).ConfigureAwait(false); 36 | } 37 | 38 | public MemoryStream GetCachedImageStream(Uri url) 39 | { 40 | if (LoadedImages.TryGetValue(url, out var stream)) 41 | { 42 | return stream; 43 | } 44 | return null; 45 | } 46 | 47 | protected async Task GetImage(Uri url) 48 | { 49 | LoadedImages[url] = await _resourceResolver.LoadAssetAsync(url).ConfigureAwait(false); 50 | } 51 | 52 | public override void Visit(AdaptiveCard card) 53 | { 54 | if (card.BackgroundImage != null) 55 | _tasks.Add(GetImage(card.BackgroundImage.Url)); 56 | base.Visit(card); 57 | } 58 | 59 | public override void Visit(AdaptiveImage image) 60 | { 61 | _tasks.Add(GetImage(image.Url)); 62 | base.Visit(image); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/ShowCardWindow.xaml.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Diagnostics; 5 | using System.Windows; 6 | using AdaptiveCards; 7 | using AdaptiveCards.Rendering; 8 | using AdaptiveCards.Rendering.Wpf; 9 | 10 | namespace WpfVisualizer 11 | { 12 | /// 13 | /// Interaction logic for ShowCardWindow.xaml 14 | /// 15 | public partial class ShowCardWindow : Window 16 | { 17 | private readonly AdaptiveShowCardAction _card; 18 | private readonly ResourceDictionary _resources; 19 | 20 | public ShowCardWindow(string title, AdaptiveShowCardAction action, ResourceDictionary resources) 21 | { 22 | InitializeComponent(); 23 | 24 | _resources = resources; 25 | _card = action; 26 | Title = title; 27 | } 28 | 29 | private void Window_Loaded(object sender, RoutedEventArgs e) 30 | { 31 | var renderer = new AdaptiveCardRenderer(new AdaptiveHostConfig()) 32 | { 33 | Resources = _resources 34 | }; 35 | var result = renderer.RenderCard(_card.Card); 36 | 37 | if (result.FrameworkElement != null) 38 | { 39 | // Wire up click handler 40 | result.OnAction += OnAction; 41 | 42 | Body.Children.Add(result.FrameworkElement); 43 | } 44 | } 45 | 46 | private void OnAction(object sender, AdaptiveActionEventArgs e) 47 | { 48 | if (e.Action is AdaptiveOpenUrlAction openUrlAction) 49 | { 50 | Process.Start(openUrlAction.Url.AbsoluteUri); 51 | } 52 | else if (e.Action is AdaptiveShowCardAction) 53 | { 54 | MessageBox.Show("Action.ShowCard is not alloed from within a sub-card"); 55 | } 56 | else if (e.Action is AdaptiveSubmitAction submitAction) 57 | { 58 | MessageBox.Show(this, submitAction.DataJson, "SubmitAction"); 59 | Close(); 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveImageFillMode.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Converters; 5 | 6 | namespace AdaptiveCards 7 | { 8 | /// 9 | /// Controls how an image fills a space. 10 | /// 11 | [JsonConverter(typeof(StringEnumConverter), true)] 12 | public enum AdaptiveImageFillMode 13 | { 14 | /// 15 | /// Image covers the entire width of its container (preserving aspect ratio). The image may be clipped if the 16 | /// aspect ratio of the image doesn't match the aspect ratio of its container. is respected, but is ignored 18 | /// (as it's irrelevant). 19 | /// 20 | Cover, 21 | 22 | /// 23 | /// The image isn't stretched. Rather, it's repeated on the x-axis as many times as needed to cover the 24 | /// container's width. is respected (defaults to ). is ignored. 26 | /// 27 | RepeatHorizontally, 28 | 29 | /// 30 | /// The image isn't stretched. Rather, it's repeated on the y-axis as many times as needed to cover the 31 | /// container's width. is respected (defaults to ). is ignored. 33 | /// 34 | RepeatVertically, 35 | 36 | /// The image isn't stretched. Rather, it's repeated on the x-axis and then on the y-axis as many 37 | /// times as needed to cover the container's width. Both and ) are respected. (defaults to and 40 | /// 41 | Repeat 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/IgnoreEmptyItemsConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Reflection; 7 | using Newtonsoft.Json; 8 | using Newtonsoft.Json.Linq; 9 | 10 | namespace AdaptiveCards 11 | { 12 | /// 13 | /// JSON converter that will drop empty element items. 14 | /// 15 | /// Type of the objects to be converted. 16 | public class IgnoreEmptyItemsConverter : AdaptiveTypedBaseElementConverter 17 | { 18 | /// 19 | public override bool CanConvert(Type objectType) 20 | { 21 | return typeof(List).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); 22 | } 23 | 24 | /// 25 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 26 | { 27 | JToken jToken = JToken.Load(reader); 28 | 29 | if (jToken is JObject jObject && jObject.HasValues) 30 | { 31 | jToken = jObject.GetValue("$values"); 32 | } 33 | 34 | JArray jArray = new JArray(); 35 | 36 | if (jToken is JArray) 37 | { 38 | jArray = jToken as JArray; 39 | } 40 | 41 | ParseContext.Type = (objectType == typeof(List)) ? ParseContext.ContextType.Element : ParseContext.ContextType.Action; 42 | 43 | return jArray.Children() 44 | .Where(obj => obj.HasValues) 45 | .Select(obj => serializer.Deserialize(obj.CreateReader(), typeof(T))) 46 | .Where(value => value != null) 47 | .Select(value => (T) value).ToList(); 48 | } 49 | 50 | /// 51 | public override bool CanWrite => false; 52 | 53 | /// 54 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 55 | { 56 | throw new NotImplementedException(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/StrictIntConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using Newtonsoft.Json; 5 | 6 | namespace AdaptiveCards 7 | { 8 | public class StrictIntConverter : JsonConverter 9 | { 10 | readonly JsonSerializer defaultSerializer = new JsonSerializer(); 11 | 12 | public override bool CanConvert(Type objectType) 13 | { 14 | // Only use this converter for Integer types 15 | return objectType.IsIntegerType(); 16 | } 17 | 18 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 19 | { 20 | switch (reader.TokenType) 21 | { 22 | // Only allow Integer or Null 23 | case JsonToken.Integer: 24 | case JsonToken.Null: 25 | return defaultSerializer.Deserialize(reader, objectType); 26 | default: 27 | throw new JsonSerializationException(string.Format("Token \"{0}\" of type {1} was not a JSON integer", reader.Value, reader.TokenType)); 28 | } 29 | } 30 | 31 | public override bool CanWrite { get { return false; } } 32 | 33 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 34 | { 35 | throw new NotImplementedException(); 36 | } 37 | } 38 | 39 | public static partial class JsonExtensions 40 | { 41 | public static bool IsIntegerType(this Type type) 42 | { 43 | type = Nullable.GetUnderlyingType(type) ?? type; 44 | if (type == typeof(long) 45 | || type == typeof(ulong) 46 | || type == typeof(int) 47 | || type == typeof(uint) 48 | || type == typeof(short) 49 | || type == typeof(ushort) 50 | || type == typeof(byte) 51 | || type == typeof(sbyte) 52 | || type == typeof(System.Numerics.BigInteger)) 53 | { 54 | return true; 55 | } 56 | 57 | return false; 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/ToggleElementsConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Reflection; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace AdaptiveCards 13 | { 14 | public class ToggleElementsConverter : JsonConverter 15 | { 16 | 17 | public override bool CanConvert(Type objectType) 18 | { 19 | return typeof(List).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); 20 | } 21 | 22 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 23 | { 24 | var array = JArray.Load(reader); 25 | List list = array.ToObject>(); 26 | List arrayList = new List(); 27 | 28 | foreach(object obj in list) 29 | { 30 | if(obj is string s) 31 | { 32 | arrayList.Add(new AdaptiveTargetElement(s)); 33 | } 34 | else 35 | { 36 | JObject jobj = (JObject)obj; 37 | arrayList.Add((AdaptiveTargetElement)jobj.ToObject(typeof(AdaptiveTargetElement))); 38 | } 39 | } 40 | return arrayList; 41 | } 42 | 43 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 44 | { 45 | List targetElements = (List)value; 46 | 47 | JArray jArray = new JArray(); 48 | 49 | foreach (var el in targetElements) 50 | { 51 | if (el.IsVisible == null) 52 | { 53 | jArray.Add(JToken.FromObject(el.ElementId)); 54 | } 55 | else 56 | { 57 | jArray.Add(JToken.FromObject(el)); 58 | } 59 | } 60 | 61 | jArray.WriteTo(writer); 62 | } 63 | 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveDateInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System.ComponentModel; 5 | using System.Xml.Serialization; 6 | 7 | namespace AdaptiveCards 8 | { 9 | /// 10 | /// Represents the Input.Date element. 11 | /// 12 | #if !NETSTANDARD1_3 13 | [XmlType(TypeName = AdaptiveDateInput.TypeName)] 14 | #endif 15 | public class AdaptiveDateInput : AdaptiveInput 16 | { 17 | /// 18 | public const string TypeName = "Input.Date"; 19 | 20 | /// 21 | #if !NETSTANDARD1_3 22 | [XmlIgnore] 23 | #endif 24 | public override string Type { get; set; } = TypeName; 25 | 26 | /// 27 | /// Placeholder text to display. 28 | /// 29 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 30 | #if !NETSTANDARD1_3 31 | [XmlAttribute] 32 | #endif 33 | [DefaultValue(null)] 34 | public string Placeholder { get; set; } 35 | 36 | /// 37 | /// The initial value for the field. 38 | /// 39 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 40 | #if !NETSTANDARD1_3 41 | [XmlAttribute] 42 | #endif 43 | [DefaultValue(null)] 44 | public string Value { get; set; } 45 | 46 | /// 47 | /// Hint of minimum value (note: may be ignored by some clients). 48 | /// 49 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 50 | #if !NETSTANDARD1_3 51 | [XmlAttribute] 52 | #endif 53 | [DefaultValue(null)] 54 | public string Min { get; set; } 55 | 56 | /// 57 | /// Hint of maximum value (note: may be ignored by some clients). 58 | /// 59 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 60 | #if !NETSTANDARD1_3 61 | [XmlAttribute] 62 | #endif 63 | [DefaultValue(null)] 64 | public string Max { get; set; } 65 | 66 | /// 67 | public override string GetNonInteractiveValue() 68 | { 69 | return Value ?? $"*[{Placeholder}]*"; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveTimeInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System.ComponentModel; 5 | using System.Xml.Serialization; 6 | 7 | namespace AdaptiveCards 8 | { 9 | /// 10 | /// Represents the Input.Time element. 11 | /// 12 | #if !NETSTANDARD1_3 13 | [XmlType(TypeName = AdaptiveTimeInput.TypeName)] 14 | #endif 15 | public class AdaptiveTimeInput : AdaptiveInput 16 | { 17 | /// 18 | public const string TypeName = "Input.Time"; 19 | 20 | /// 21 | #if !NETSTANDARD1_3 22 | [XmlIgnore] 23 | #endif 24 | public override string Type { get; set; } = TypeName; 25 | 26 | /// 27 | /// Placeholder text to display when the input is empty. 28 | /// 29 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 30 | #if !NETSTANDARD1_3 31 | [XmlAttribute] 32 | #endif 33 | [DefaultValue(null)] 34 | public string Placeholder { get; set; } 35 | 36 | /// 37 | /// The initial value for the field. 38 | /// 39 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 40 | #if !NETSTANDARD1_3 41 | [XmlAttribute] 42 | #endif 43 | [DefaultValue(null)] 44 | public string Value { get; set; } 45 | 46 | /// 47 | /// Hint of minimum value (may be ignored by some clients). 48 | /// 49 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 50 | #if !NETSTANDARD1_3 51 | [XmlAttribute] 52 | #endif 53 | [DefaultValue(null)] 54 | public string Min { get; set; } 55 | 56 | /// 57 | /// Hint of maximum value (may be ignored by some clients) 58 | /// 59 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 60 | #if !NETSTANDARD1_3 61 | [XmlAttribute] 62 | #endif 63 | [DefaultValue(null)] 64 | public string Max { get; set; } 65 | 66 | /// 67 | public override string GetNonInteractiveValue() 68 | { 69 | return Value ?? $"*[{Placeholder}]*"; 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/IgnoreDefaultStringEnumConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System; 4 | using System.Collections.Generic; 5 | using Newtonsoft.Json; 6 | using Newtonsoft.Json.Converters; 7 | 8 | 9 | namespace AdaptiveCards 10 | { 11 | internal class IgnoreDefaultStringEnumConverter : StringEnumConverter, ILogWarnings 12 | { 13 | public List Warnings { get; set; } = new List(); 14 | 15 | // TODO: temporary warning code for invalid value. Remove when common set of error codes created and integrated. 16 | private enum WarningStatusCode {UnknownElementType = 0}; 17 | 18 | private readonly string defaultValue; 19 | 20 | private string GetDefaultValueFromEnum() 21 | { 22 | return Enum.Parse(typeof(TEnum), "0").ToString(); 23 | } 24 | 25 | public IgnoreDefaultStringEnumConverter() 26 | { 27 | defaultValue = GetDefaultValueFromEnum(); 28 | } 29 | 30 | public IgnoreDefaultStringEnumConverter(bool camelCaseText) : base(camelCaseText) 31 | { 32 | defaultValue = GetDefaultValueFromEnum(); 33 | } 34 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 35 | { 36 | try 37 | { 38 | // Try to read regularly 39 | return base.ReadJson(reader, objectType, existingValue, serializer); 40 | } 41 | catch 42 | { 43 | // Catch invalid values and replace them with default value 44 | // Add warning stating behavior 45 | Warnings.Add(new AdaptiveWarning((int)WarningStatusCode.UnknownElementType, $"Value \"{reader.Value}\" could not be converted to \"{typeof(TEnum).ToString()}\", using the default value of \"{defaultValue}\" instead.")); 46 | return Enum.Parse(typeof(TEnum), "0"); 47 | } 48 | } 49 | 50 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 51 | { 52 | if (value?.ToString() == defaultValue) 53 | value = null; 54 | base.WriteJson(writer, value, serializer); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveInlinesConverter.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using Newtonsoft.Json.Linq; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Reflection; 8 | 9 | namespace AdaptiveCards 10 | { 11 | class AdaptiveInlinesConverter : AdaptiveTypedBaseElementConverter 12 | { 13 | public override bool CanRead => true; 14 | 15 | public override bool CanWrite => false; 16 | 17 | public override bool CanConvert(Type objectType) 18 | { 19 | return typeof(List).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo()); 20 | } 21 | 22 | public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) 23 | { 24 | var array = JArray.Load(reader); 25 | List list = array.ToObject>(); 26 | List arrayList = new List(); 27 | var serializerSettigns = new JsonSerializerSettings 28 | { 29 | ContractResolver = new WarningLoggingContractResolver(new AdaptiveCardParseResult(), ParseContext), 30 | Converters = { new StrictIntConverter() } 31 | }; 32 | 33 | // We only support text runs for now, which can be specified as either a string or an object 34 | foreach (object obj in list) 35 | { 36 | if (obj is string s) 37 | { 38 | arrayList.Add(new AdaptiveTextRun(s)); 39 | } 40 | else 41 | { 42 | JObject jobj = (JObject)obj; 43 | if (jobj.Value("type") != AdaptiveTextRun.TypeName) 44 | { 45 | throw new AdaptiveSerializationException($"Property 'type' must be '{AdaptiveTextRun.TypeName}'"); 46 | } 47 | 48 | arrayList.Add(JsonConvert.DeserializeObject(jobj.ToString(), serializerSettigns)); 49 | } 50 | } 51 | return arrayList; 52 | } 53 | 54 | public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) 55 | { 56 | throw new NotImplementedException(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Samples/WPFVisualizer/CustomElements/MyCustomRating.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.Windows; 4 | using System.Windows.Controls; 5 | using AdaptiveCards; 6 | using AdaptiveCards.Rendering.Wpf; 7 | 8 | namespace WpfVisualizer 9 | { 10 | public class MyCustomRating : AdaptiveElement 11 | { 12 | public override string Type { get; set; } = "Rating"; 13 | 14 | public double Rating { get; set; } 15 | 16 | public AdaptiveTextSize Size { get; set; } 17 | 18 | public AdaptiveTextColor Color { get; set; } 19 | 20 | public static FrameworkElement Render(MyCustomRating rating, AdaptiveRenderContext context) 21 | { 22 | var textBlock = new AdaptiveTextBlock 23 | { 24 | Size = rating.Size, 25 | Color = rating.Color 26 | }; 27 | for (int i = 0; i < rating.Rating; i++) 28 | { 29 | textBlock.Text += "\u2605"; 30 | } 31 | textBlock.Text += $" ({rating.Rating})"; 32 | return context.Render(textBlock); 33 | } 34 | } 35 | 36 | public class MyCustomInput : AdaptiveInput 37 | { 38 | public override string Type { get; set; } = "customInput"; 39 | 40 | public string Value { get; set; } 41 | 42 | public class CustomInputValue : AdaptiveInputValue 43 | { 44 | public CustomInputValue(AdaptiveInput inputElement, UIElement renderedElement) : base(inputElement, renderedElement) { } 45 | 46 | public override string GetValue() 47 | { 48 | return ((TextBox)RenderedInputElement).Text; 49 | } 50 | 51 | public override void SetFocus() 52 | { 53 | ((TextBox)RenderedInputElement).Focus(); 54 | } 55 | 56 | public override bool Validate() 57 | { 58 | return true; 59 | } 60 | } 61 | 62 | public static FrameworkElement Render(MyCustomInput input, AdaptiveRenderContext context) 63 | { 64 | var textBox = new TextBox(); 65 | textBox.Text = input.Value; 66 | 67 | context.InputValues.Add(input.Id, new CustomInputValue(input, textBox)); 68 | 69 | return textBox; 70 | } 71 | 72 | public override string GetNonInteractiveValue() 73 | { 74 | return Value; 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveNumberInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using System.ComponentModel; 4 | using System.Globalization; 5 | using System.Xml.Serialization; 6 | using Newtonsoft.Json; 7 | 8 | namespace AdaptiveCards 9 | { 10 | /// 11 | /// Represents the Input.Number element. 12 | /// 13 | #if !NETSTANDARD1_3 14 | [XmlType(TypeName = AdaptiveNumberInput.TypeName)] 15 | #endif 16 | public class AdaptiveNumberInput : AdaptiveInput 17 | { 18 | /// 19 | public const string TypeName = "Input.Number"; 20 | 21 | /// 22 | #if !NETSTANDARD1_3 23 | [XmlIgnore] 24 | #endif 25 | public override string Type { get; set; } = TypeName; 26 | 27 | /// 28 | /// Text to display as a placeholder. 29 | /// 30 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 31 | #if !NETSTANDARD1_3 32 | [XmlAttribute] 33 | #endif 34 | [DefaultValue(null)] 35 | public string Placeholder { get; set; } 36 | 37 | /// 38 | /// The initial value for the field. 39 | /// 40 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 41 | #if !NETSTANDARD1_3 42 | [XmlAttribute] 43 | #endif 44 | [DefaultValue(double.NaN)] 45 | public double Value { get; set; } = double.NaN; 46 | 47 | /// 48 | /// Hint of minimum value (may be ignored by some clients). 49 | /// 50 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 51 | #if !NETSTANDARD1_3 52 | [XmlAttribute] 53 | #endif 54 | [DefaultValue(double.NaN)] 55 | public double Min { get; set; } = double.NaN; 56 | 57 | /// 58 | /// Hint of maximum value (may be ignored by some clients). 59 | /// 60 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 61 | #if !NETSTANDARD1_3 62 | [XmlAttribute] 63 | #endif 64 | [DefaultValue(double.NaN)] 65 | public double Max { get; set; } = double.NaN; 66 | 67 | /// 68 | public override string GetNonInteractiveValue() 69 | { 70 | return double.IsNaN(Value) 71 | ? Value.ToString(CultureInfo.InvariantCulture) 72 | : $"*[{Placeholder}]*"; 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Build/SignConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /Library/AdaptiveCards/AdaptiveToggleInput.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | using Newtonsoft.Json; 4 | using System.ComponentModel; 5 | using System.Xml.Serialization; 6 | 7 | namespace AdaptiveCards 8 | { 9 | /// 10 | /// Represents the Input.Toggle element. 11 | /// 12 | #if !NETSTANDARD1_3 13 | [XmlType(TypeName = AdaptiveToggleInput.TypeName)] 14 | #endif 15 | public class AdaptiveToggleInput : AdaptiveInput 16 | { 17 | /// 18 | public const string TypeName = "Input.Toggle"; 19 | 20 | /// 21 | #if !NETSTANDARD1_3 22 | [XmlIgnore] 23 | #endif 24 | public override string Type { get; set; } = TypeName; 25 | 26 | /// 27 | /// Title text for this element. 28 | /// 29 | [JsonRequired] 30 | #if !NETSTANDARD1_3 31 | [XmlAttribute] 32 | #endif 33 | [DefaultValue(null)] 34 | public string Title { get; set; } 35 | 36 | /// 37 | /// Value to use when toggle is on. 38 | /// 39 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 40 | #if !NETSTANDARD1_3 41 | [XmlAttribute] 42 | #endif 43 | [DefaultValue(null)] 44 | public string ValueOn { get; set; } = bool.TrueString; 45 | 46 | /// 47 | /// Value to use when toggle is off. 48 | /// 49 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 50 | #if !NETSTANDARD1_3 51 | [XmlAttribute] 52 | #endif 53 | [DefaultValue(null)] 54 | public string ValueOff { get; set; } = bool.FalseString; 55 | 56 | /// 57 | /// Controls text wrapping behavior. 58 | /// 59 | [JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] 60 | #if !NETSTANDARD1_3 61 | [XmlAttribute] 62 | #endif 63 | [DefaultValue(false)] 64 | public bool Wrap { get; set; } 65 | 66 | /// 67 | /// The value for the field. 68 | /// 69 | [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] 70 | #if !NETSTANDARD1_3 71 | [XmlAttribute] 72 | #endif 73 | [DefaultValue(null)] 74 | public string Value { get; set; } 75 | 76 | /// 77 | public override string GetNonInteractiveValue() 78 | { 79 | var x = Value == ValueOn ? "X" : " "; 80 | return $"[{x}] {Title}"; 81 | } 82 | } 83 | } 84 | --------------------------------------------------------------------------------