public void SerializeReferenceInList() { EmployeeReference e1 = new EmployeeReference { Name = "e1" }; EmployeeReference e2 = new EmployeeReference { Name = "e2" }; List <EmployeeReference> employees = new List <EmployeeReference> { e1, e2, e1, e2 }; string json = JsonConvert.SerializeObject(employees, Formatting.Indented); StringAssert.AreEqual(@"[ { ""$id"": ""1"", ""Name"": ""e1"", ""Manager"": null }, { ""$id"": ""2"", ""Name"": ""e2"", ""Manager"": null }, { ""$ref"": ""1"" }, { ""$ref"": ""2"" } ]", json); }
public void DeserializeReferenceInDictionary() { string json = @"{ ""One"": { ""$id"": ""1"", ""Name"": ""e1"", ""Manager"": null }, ""Two"": { ""$id"": ""2"", ""Name"": ""e2"", ""Manager"": null }, ""Three"": { ""$ref"": ""1"" }, ""Four"": { ""$ref"": ""2"" } }"; Dictionary <string, EmployeeReference> employees = JsonConvert.DeserializeObject <Dictionary <string, EmployeeReference> >(json); Assert.AreEqual(4, employees.Count); EmployeeReference e1 = employees["One"]; EmployeeReference e2 = employees["Two"]; Assert.AreEqual("e1", e1.Name); Assert.AreEqual("e2", e2.Name); Assert.AreEqual(e1, employees["Three"]); Assert.AreEqual(e2, employees["Four"]); }
public void SerializeEmployeeReference() { EmployeeReference mikeManager = new EmployeeReference { Name = "Mike Manager" }; EmployeeReference joeUser = new EmployeeReference { Name = "Joe User", Manager = mikeManager }; List <EmployeeReference> employees = new List <EmployeeReference> { mikeManager, joeUser }; string json = JsonConvert.SerializeObject(employees, Formatting.Indented); StringAssert.AreEqual(@"[ { ""$id"": ""1"", ""Name"": ""Mike Manager"", ""Manager"": null }, { ""$id"": ""2"", ""Name"": ""Joe User"", ""Manager"": { ""$ref"": ""1"" } } ]", json); }
void Create(object sender, EmployeeReference.EmployeeCompletedEventArgs e) { if (e.Result > -1) { MessageBox.Show("Record Inserted Sucessfully", "Insert", MessageBoxButton.OK); Clear(); } }
public void DeserializeGenericObjectListWithTypeName() { string employeeRef = typeof(EmployeeReference).AssemblyQualifiedName; string personRef = typeof(Person).AssemblyQualifiedName; string json = @"[ { ""Name"": ""Bob"", ""$id"": ""1"", ""$type"": """ + employeeRef + @""", ""Manager"": { ""$id"": ""2"", ""$type"": """ + employeeRef + @""", ""Name"": ""Frank"", ""Manager"": null } }, { ""Name"": null, ""$type"": """ + personRef + @""", ""BirthDate"": ""\/Date(978134400000)\/"", ""LastModified"": ""\/Date(978134400000)\/"" }, ""String!"", -2147483648 ]"; List <object> values = (List <object>)JsonConvert.DeserializeObject(json, typeof(List <object>), new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.Objects, #pragma warning disable 618 TypeNameAssemblyFormat = FormatterAssemblyStyle.Full, #pragma warning restore 618 MetadataPropertyHandling = MetadataPropertyHandling.ReadAhead }); Assert.AreEqual(4, values.Count); EmployeeReference e = (EmployeeReference)values[0]; Person p = (Person)values[1]; Assert.AreEqual("Bob", e.Name); Assert.AreEqual("Frank", e.Manager.Name); Assert.AreEqual(null, p.Name); Assert.AreEqual(new DateTime(2000, 12, 30, 0, 0, 0, DateTimeKind.Utc), p.BirthDate); Assert.AreEqual(new DateTime(2000, 12, 30, 0, 0, 0, DateTimeKind.Utc), p.LastModified); Assert.AreEqual("String!", values[2]); Assert.AreEqual((long)int.MinValue, values[3]); }
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); }
public void SerializeReferenceInDictionary() { EmployeeReference e1 = new EmployeeReference { Name = "e1" }; EmployeeReference e2 = new EmployeeReference { Name = "e2" }; Dictionary <string, EmployeeReference> employees = new Dictionary < string, EmployeeReference > { { "One", e1 }, { "Two", e2 }, { "Three", e1 }, { "Four", e2 } }; string json = JsonConvert.SerializeObject(employees, Formatting.Indented); StringAssert.AreEqual( @"{ ""One"": { ""$id"": ""1"", ""Name"": ""e1"", ""Manager"": null }, ""Two"": { ""$id"": ""2"", ""Name"": ""e2"", ""Manager"": null }, ""Three"": { ""$ref"": ""1"" }, ""Four"": { ""$ref"": ""2"" } }", json ); }
public static object _Copier(object original) { EmployeeReference input = ((EmployeeReference)(original)); return((EmployeeReference)(global::Orleans.Runtime.GrainReference.CopyGrainReference(input))); }
public static HrGrainInterfaces.IEmployee Cast(global::Orleans.Runtime.IAddressable grainRef) { return(EmployeeReference.Cast(grainRef)); }
public static object _Deserializer(System.Type expected, global::Orleans.Serialization.BinaryTokenStreamReader stream) { return(EmployeeReference.Cast(((global::Orleans.Runtime.GrainReference)(global::Orleans.Runtime.GrainReference.DeserializeGrainReference(expected, stream))))); }
public static void _Serializer(object original, global::Orleans.Serialization.BinaryTokenStreamWriter stream, System.Type expected) { EmployeeReference input = ((EmployeeReference)(original)); global::Orleans.Runtime.GrainReference.SerializeGrainReference(input, stream, expected); }