Skip to content

Instantly share code, notes, and snippets.

@beachside-project
Created October 2, 2019 09:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beachside-project/d762b2318485b1f276007e74f9223229 to your computer and use it in GitHub Desktop.
Save beachside-project/d762b2318485b1f276007e74f9223229 to your computer and use it in GitHub Desktop.
CustomBindingsSamples.TeamsBinding
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
namespace CustomBindingsSamples.TeamsBinding
{
public class TeamsMessage
{
private readonly JsonSerializerSettings _settings = new JsonSerializerSettings()
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
public string Title { get; set; } // TODO: validation check
public string Text { get; set; } // TODO: validation check
public string LinkUri
{
get => PotentialAction[0].Targets[0].Uri;
set
{
// TODO: validation check
PotentialAction[0].Targets[0].Uri = value;
}
}
public string ThemeColor { get; set; } = "0072C6";
[JsonProperty("@context")]
private string Context => "https://schema.org/extensions";
[JsonProperty("@type")]
private string CardType => "MessageCard";
[JsonProperty]
private PotentialAction[] PotentialAction { get; } = { new PotentialAction() };
public string ToJson() => JsonConvert.SerializeObject(this, settings: _settings);
}
internal class PotentialAction
{
[JsonProperty("@type")]
private string Type => "OpenUri";
[JsonProperty]
private string Name => "View More";
public Target[] Targets { get; } = { new Target() };
}
internal class Target
{
[JsonProperty]
private string Os => "default";
public string Uri { get; internal set; }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment