This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public int Age { get; set; } | |
public string[] Hobbies{ get; set; } | |
public List<Phone> Phones { get; set; } | |
public string FullName => $"{FirstName} {LastName}"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Jsonにインデントつけるには... +JsonSerializerSettingsでキャメルケース出力 | |
var shinobuJsonWithIndention = JsonConvert.SerializeObject(shinobu, Formatting.Indented, new JsonSerializerSettings() | |
{ | |
ContractResolver = new CamelCasePropertyNamesContractResolver() | |
}); | |
Console.WriteLine(shinobuJsonWithIndention); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class JsonSerializable | |
{ | |
private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings | |
{ | |
ContractResolver = new CamelCasePropertyNamesContractResolver() | |
}; | |
public string ToJsonString() => JsonConvert.SerializeObject(this, Settings); | |
public string ToJsonString(JsonSerializerSettings settings) => JsonConvert.SerializeObject(this, settings); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var shinobu = new Person() | |
{ | |
FirstName = "shinobu", | |
LastName = "oshino", | |
Age = 598, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Person | |
{ | |
[JsonProperty(PropertyName = "firstName")] | |
public string FirstName { get; set; } | |
[JsonProperty(PropertyName = "lastName")] | |
public string LastName { get; set; } | |
[JsonProperty(PropertyName = "age")] | |
public int Age { get; set; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SnakeCaseContractResolver : DefaultContractResolver | |
{ | |
private const string SnakeDelimiter = "_"; | |
protected override IList<JsonProperty> CreateProperties(System.Type type, MemberSerialization memberSerialization) | |
=> base.CreateProperties(type, memberSerialization).Select(ConvertSnakeCasePropertyName).ToList(); | |
private static JsonProperty ConvertSnakeCasePropertyName(JsonProperty p) | |
{ | |
var target = p.PropertyName; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var shinobu = new Person() | |
{ | |
FirstName = "shinobu", | |
LastName = "oshino", | |
Age = 598, | |
Favorites = new[] { "golden chocolate", "pon de ring" }, | |
Phones = new List<Phone>() | |
{ | |
new Phone() {PhoneNumber = "000-000-111",ModelName = "Lumia"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EnumerableExtension | |
{ | |
public static HashSet<T> ToHashSet<T>(this IEnumerable<T> source) => new HashSet<T>(source); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class EnumerableExtension | |
{ | |
public static bool ContainsDuplicate(this IEnumerable<string> source) => source.GroupBy(i => i).SelectMany(g => g.Skip(1)).Any(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using Microsoft.Bot.Builder.FormFlow; | |
namespace FormFlow1.Dialogs | |
{ | |
[Serializable] | |
public class SandwichOrder | |
{ | |
public SandwichOptions? Sandwich; |
OlderNewer