create .net library for schema

This commit is contained in:
Tom Laird-McConnell 2017-02-03 12:44:46 -08:00
Родитель f9960dd6be
Коммит 74110e8267
28 изменённых файлов: 876 добавлений и 10 удалений

63
.gitattributes поставляемый Normal file
Просмотреть файл

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

Просмотреть файл

@ -3,27 +3,32 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InteractiveVisualizer", "src\InteractiveVisualizer\InteractiveVisualizer.csproj", "{AE93161A-244A-4410-BC34-466189AEFAF7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Renderers", "Renderers", "{412460AB-E5CC-4605-8813-7EFFC924D990}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Visualizer", "Visualizer", "{CD8C128A-ABFB-43F8-B86A-8CC06FB0C7AA}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Builders", "Builders", "{CB015F2B-73A6-45E8-9066-77154240257B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".NET", ".NET", "{38D9E098-DD38-49B7-B861-917FA527D346}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adaptive.Schema.Net", "builders\.NET\Adaptive.Schema.Net\Adaptive.Schema.Net.csproj", "{692311B2-E537-4700-8EF7-A5F83D90383C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AE93161A-244A-4410-BC34-466189AEFAF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{AE93161A-244A-4410-BC34-466189AEFAF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{AE93161A-244A-4410-BC34-466189AEFAF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{AE93161A-244A-4410-BC34-466189AEFAF7}.Release|Any CPU.Build.0 = Release|Any CPU
{692311B2-E537-4700-8EF7-A5F83D90383C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{692311B2-E537-4700-8EF7-A5F83D90383C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{692311B2-E537-4700-8EF7-A5F83D90383C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692311B2-E537-4700-8EF7-A5F83D90383C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{AE93161A-244A-4410-BC34-466189AEFAF7} = {CD8C128A-ABFB-43F8-B86A-8CC06FB0C7AA}
{38D9E098-DD38-49B7-B861-917FA527D346} = {CB015F2B-73A6-45E8-9066-77154240257B}
{692311B2-E537-4700-8EF7-A5F83D90383C} = {38D9E098-DD38-49B7-B861-917FA527D346}
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,22 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Adaptive.Schema.Net", "Adaptive.Schema.Net\Adaptive.Schema.Net.csproj", "{692311B2-E537-4700-8EF7-A5F83D90383C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{692311B2-E537-4700-8EF7-A5F83D90383C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{692311B2-E537-4700-8EF7-A5F83D90383C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{692311B2-E537-4700-8EF7-A5F83D90383C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{692311B2-E537-4700-8EF7-A5F83D90383C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{692311B2-E537-4700-8EF7-A5F83D90383C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Adaptive.Schema.Net</RootNamespace>
<AssemblyName>Adaptive.Schema.Net</AssemblyName>
<DefaultLanguage>en-US</DefaultLanguage>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Compile Include="AdaptiveCard.cs" />
<Compile Include="CardElement.cs" />
<Compile Include="Choice.cs" />
<Compile Include="Column.cs" />
<Compile Include="ColumnGroup.cs" />
<Compile Include="Container.cs" />
<Compile Include="DateInput.cs" />
<Compile Include="Enums.cs" />
<Compile Include="Fact.cs" />
<Compile Include="FactGroup.cs" />
<Compile Include="Image.cs" />
<Compile Include="ImageGallery.cs" />
<Compile Include="Input.cs" />
<Compile Include="MultichoiceInput.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Seperator.cs" />
<Compile Include="TextBlock.cs" />
<Compile Include="TextInput.cs" />
<Compile Include="ToggleInput.cs" />
<Compile Include="TypedElementConverter.cs" />
<Compile Include="TypedElement.cs" />
</ItemGroup>
<ItemGroup>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\packages\Newtonsoft.Json.9.0.1\lib\portable-net45+wp80+win8+wpa81\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

Просмотреть файл

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// Adaptive card which has flexible container
/// </summary>
public class AdaptiveCard : TypedElement
{
public AdaptiveCard() { }
public string Speak { get; set; }
public Container Body { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// Base class for all elements in a container
/// </summary>
public class CardElement : TypedElement
{
public CardElement() : base()
{
}
/// <summary>
/// SSML fragment for spoken interaction
/// </summary>
public string Speak { get; set; }
/// <summary>
/// Size hint for the element
/// </summary>
public Size Size { get; set; } = Size.Auto;
/// <summary>
/// Horizontal alignment for element
/// </summary>
public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Left;
}
}

Просмотреть файл

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// Choice as part of a MultichoiceInput element
/// </summary>
public class Choice
{
public Choice()
{ }
/// <summary>
/// Display text for the choice
/// </summary>
public string Display { get; set; }
/// <summary>
/// Internal value which will be collected as input if the choice is selected
/// </summary>
public string Value { get; set; }
/// <summary>
/// (OPTIONAL) Speech description of the choice
/// </summary>
// ISSUE: I think we need speak here...
public string Speak { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// A column container inside of a columngroup
/// </summary>
public class Column : Container
{
public Column() { }
// ISSUE Number? I thought we had "Auto" and stuff..
public int Weight { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// A container for grouping columns together
/// </summary>
public class ColumnGroup : CardElement
{
public ColumnGroup() { }
// ISSUE? Should this be called columns, it only can take Column elements, right?
public List<Column> Items { get; set; } = new List<Column>();
}
}

Просмотреть файл

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// Container for a collection of elements
/// </summary>
public class Container : TypedElement
{
public Container()
{ }
// Issue: Should this be Elements?
public List<CardElement> Items { get; set; } = new List<CardElement>();
/// <summary>
/// Image to use for the background of a card
/// </summary>
public string BackgroundImageUrl { get; set; }
/// <summary>
/// Background color to use for the card
/// </summary>
// ISSUE: Why is this a string?
public string BackgroundColor { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// Input control for date
/// </summary>
public class DateInput : Input
{
public DateInput()
{
this.Size = Size.Medium;
}
public bool IncludeTime { get; set; }
// ISSUE: WE NEED MORE PARAMETERS HERE
}
}

Просмотреть файл

@ -0,0 +1,170 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// Controls the horizontal size (width) of element.
/// </summary>
public enum Size
{
/// <summary>
/// The width of the element is optimally chosen depending on the space available in the element's container
/// </summary>
Auto,
/// <summary>
/// The width of the element adjusts to match that of its container
/// </summary>
Stretch,
/// <summary>
/// Small width
/// </summary>
Small,
/// <summary>
/// Medium width
/// </summary>
Medium,
/// <summary>
/// Large width
/// </summary>
Large
}
/// <summary>
/// Controls the relative size of TextBlock elements
/// </summary>
public enum TextSize
{
/// <summary>
/// Smallest text size
/// </summary>
Small,
/// <summary>
/// Default text size
/// </summary>
Normal,
/// <summary>
/// Slightly larger than normal
/// </summary>
Medium,
/// <summary>
/// Slightly larger then medium
/// </summary>
Large,
/// <summary>
/// The largest text size
/// </summary>
ExtraLarge
}
/// <summary>
/// Controls the weight of TextBock Elements
/// </summary>
public enum TextWeight
{
/// <summary>
/// Lighter text (thinner stroke)
/// </summary>
Lighter,
/// <summary>
/// The default text weight
/// </summary>
Normal,
/// <summary>
/// Bolder text (wider stroke)
/// </summary>
Bolder
}
/// <summary>
/// Controls the color style of TextBlock Elements
/// </summary>
public enum TextColor
{
/// <summary>
/// The default color which guarentees appropriate contrast
/// </summary>
Default,
/// <summary>
/// Forces the text to be rendered in a dark color which is suitable when displayed over a light background
/// </summary>
Dark,
/// <summary>
/// Forces the text to be rendered in a light color which is suitable when displayed over a dark background
/// </summary>
Light,
/// <summary>
/// Accent the text
/// </summary>
Accent,
/// <summary>
/// Good (such as green)
/// </summary>
Good,
/// <summary>
/// Warning (such as yellow)
/// </summary>
Warning,
/// <summary>
/// Highlight as needing attention (such as red)
/// </summary>
Attention
}
/// <summary>
/// Controls how elements are horizontally positioned within their container.
/// </summary>
public enum HorizontalAlignment
{
/// <summary>
/// The element is left aligned
/// </summary>
Left,
/// <summary>
/// The element is centered inside its container
/// </summary>
Center,
/// <summary>
/// The element is right aligned
/// </summary>
Right
}
/// <summary>
/// Controls the way Image elements are displayed.
/// </summary>
public enum ImageStyle
{
/// <summary>
/// The image is displayed within a rectangle.
/// </summary>
Normal,
/// <summary>
/// The image is cropped to a circle, a common way to represent people photos.
/// </summary>
Person
}
}

Просмотреть файл

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// Represents one "fact" in a FactGroup element.
/// </summary>
public class Fact
{
public Fact(string name, string value, string speak=null)
{
this.Name = name;
this.Value = value;
this.Speak = speak;
}
/// <summary>
/// The facts label
/// </summary>
public string Name { get; set; }
/// <summary>
/// The fact's value
/// </summary>
public string Value { get; set; }
/// <summary>
/// (Optional) Specifies what should be spoken for this entire element. This is simple text or SSML fragment
/// </summary>
public string Speak { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// The FactGroup element makes it simple to display a se ries of "facts" (e.g. name/value pairs) in a tabular form.
/// </summary>
public class FactGroup : CardElement
{
public FactGroup()
{ }
/// <summary>
/// The facts to be displayed.
/// </summary>
// ISSUE: This only takes Fact objects, should this be called Facts?
public List<Fact> Items { get; set; } = new List<Fact>();
}
}

Просмотреть файл

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// The Image element allows for the inclusion of images in an Adaptive Card.
/// </summary>
public class Image : CardElement
{
public Image()
{ }
/// <summary>
/// The style in which the image is displayed.
/// </summary>
public ImageStyle Style { get; set; } = ImageStyle.Normal;
/// <summary>
/// A url pointing to an image to display
/// </summary>
public string Url { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// The ImageGallery allows for the inclusion of a collection images like a photogallery.
/// </summary>
public class ImageGallery : CardElement
{
public ImageGallery()
{
}
/// <summary>
/// Collection of image objects to display
/// </summary>
// ISSUE: Shouldn't this be called Images since it can only contain Image
public List<Image> Items { get; set; } = new List<Image>();
/// <summary>
/// Specifies the horizontal size of each image in the gallery.
/// </summary>
public Size ImageSize { get; set; } = Size.Medium;
}
}

Просмотреть файл

@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
/// <summary>
/// Input is used as part of a Form CardElement to collect information from a user
/// </summary>
public class Input : CardElement
{
public Input()
{ }
public string Id { get; set; }
public string Title { get; set; }
public string Value { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
public class MultichoiceInput : Input
{
public MultichoiceInput()
{
this.Size = Size.Medium;
}
public List<Choice> Items { get; set; } = new List<Choice>();
}
}

Просмотреть файл

@ -0,0 +1,30 @@
using System.Resources;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Adaptive.Schema.Net")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Adaptive.Schema.Net")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: NeutralResourcesLanguage("en")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Просмотреть файл

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
public class Seperator : CardElement
{
public Seperator()
{
}
}
}

Просмотреть файл

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
public class TextBlock : CardElement
{
public TextBlock()
{
}
public TextSize TextSize { get; set; } = TextSize.Normal;
public TextWeight TextWeight { get; set; } = TextWeight.Normal;
public TextColor TextColor { get; set; } = TextColor.Default;
public string Text { get; set; }
public string Speak { get; set; }
public bool IsSubtle { get; set; } = false;
public bool Wrap { get; set; } = false;
}
}

Просмотреть файл

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
public class TextInput : Input
{
public TextInput()
{
this.Size = Size.Stretch;
}
public int MaxLength { get; set; } = int.MaxValue;
public bool IsMultiline { get; set; } = false;
}
}

Просмотреть файл

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Adaptive.Schema.Net
{
public class ToggleInput : Input
{
public ToggleInput()
{ }
}
}

Просмотреть файл

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace Adaptive.Schema.Net
{
[JsonConverter(typeof(TypeConverter))]
[JsonObject(NamingStrategyType = typeof(CamelCaseNamingStrategy))]
public class TypedElement
{
public TypedElement()
{
this.Type = GetType().Name;
}
[JsonProperty("@type", Order = -2)]
public string Type { get; set; }
}
}

Просмотреть файл

@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Adaptive.Schema.Net
{
/// <summary>
/// This handles using @type field to instantiate strongly typed object on deserialization
/// </summary>
public class TypeConverter : JsonConverter
{
public override bool CanConvert(Type objectType)
{
return typeof(TypedElement).GetTypeInfo().IsAssignableFrom(objectType.GetTypeInfo());
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
JObject jObject = JObject.Load(reader);
// Create target object based on JObject
string typeName = jObject["@type"]?.Value<string>();
object result = jObject;
if (typeName != null)
{
var type = typeof(TypedElement).GetTypeInfo().Assembly.ExportedTypes.FirstOrDefault(t => t.Name == typeName);
if (type != null)
{
result = Activator.CreateInstance(type);
}
// Populate the object properties
serializer.Populate(jObject.CreateReader(), result);
}
return result;
}
public override bool CanRead { get { return true; } }
public override bool CanWrite { get { return false; } }
}
}

Просмотреть файл

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Newtonsoft.Json" version="9.0.1" targetFramework="portable45-net45+win8+wpa81" />
</packages>

Просмотреть файл

@ -22,14 +22,14 @@ The TextBlock element allows for the inclusion of text, with various font sizes,
| **text** | string | The actual text to display |
| **speak** | [Speak](/Microsoft/AdaptiveCards/blob/master/docs/SpeechAndAdvancedCustomization.md) | (Optional) Specifies what should be spoken for this entire element. This is simple text or SSML fragment |
## Image
## Image Object
*Extends [CardElement](#cardelement)*
The Image element allows for the inclusion of images in an Adaptive Card.
| Property | Type | Description |
|---|---|---|
| **url** | The URL to the image. |
| **url** | string | The URL to the image. |
| **style** | [ImageStyle](#imagestyle) | The style in which the image is displayed. |
## ImageGallery
@ -39,6 +39,7 @@ The ImageGallery allows for the inclusion of a collection images like a photogal
| Property | Type | Description |
|---|---|---|
| **Items**| Image[] | Array of Image objects |
| **size** | [Size](#size) | Specifies the horizontal size of each image in the gallery. |
## Separator

Просмотреть файл

@ -32,7 +32,7 @@
"json-loader": "0.5.4",
"ts-loader": "1.3.0",
"tslint": "3.15.1",
"typescript": "2.0.10",
"typescript": "2.1.5",
"webpack": "1.14.0"
},
"author": "Microsoft",