コード例 #1
0
 public DictionaryInterfaceClass()
 {
     Dictionary = new Dictionary <string, int> {
         { "existing", 1 }
     };
     Collection = new List <int> {
         1, 2, 3
     };
     Employee = new EmployeeReference {
         Name = "EmployeeName!"
     };
 }
コード例 #2
0
 public DictionaryInterfaceClass()
 {
   Dictionary = new Dictionary<string, int>
     {
       { "existing", 1 }
     };
   Collection = new List<int>
     {
       1,
       2,
       3
     };
   Employee = new EmployeeReference
     {
       Name = "EmployeeName!"
     };
 }
コード例 #3
0
    public void WriteTypeNameForObjects()
    {
      string employeeRef = ReflectionUtils.GetTypeName(typeof(EmployeeReference), FormatterAssemblyStyle.Simple);

      EmployeeReference employee = new EmployeeReference();

      string json = JsonConvert.SerializeObject(employee, Formatting.Indented, new JsonSerializerSettings
      {
        TypeNameHandling = TypeNameHandling.Objects
      });

      Assert.AreEqual(@"{
  ""$id"": ""1"",
  ""$type"": """ + employeeRef + @""",
  ""Name"": null,
  ""Manager"": null
}", json);
    }