Commit c792db5d authored by Jan Tattermusch's avatar Jan Tattermusch

Merge pull request #628 from jtattermusch/csharp_addressbook_update

C# addressbook update
parents bd3367c8 43b17376
...@@ -86,7 +86,7 @@ namespace Google.Protobuf.Examples.AddressBook ...@@ -86,7 +86,7 @@ namespace Google.Protobuf.Examples.AddressBook
break; break;
} }
person.Phone.Add(phoneNumber); person.Phones.Add(phoneNumber);
} }
return person; return person;
} }
...@@ -119,7 +119,7 @@ namespace Google.Protobuf.Examples.AddressBook ...@@ -119,7 +119,7 @@ namespace Google.Protobuf.Examples.AddressBook
} }
// Add an address. // Add an address.
addressBook.Person.Add(PromptForAddress(Console.In, Console.Out)); addressBook.People.Add(PromptForAddress(Console.In, Console.Out));
// Write the new address book back to disk. // Write the new address book back to disk.
using (Stream output = File.OpenWrite(args[0])) using (Stream output = File.OpenWrite(args[0]))
......
This diff is collapsed.
...@@ -42,7 +42,7 @@ namespace Google.Protobuf.Examples.AddressBook ...@@ -42,7 +42,7 @@ namespace Google.Protobuf.Examples.AddressBook
/// </summary> /// </summary>
private static void Print(AddressBook addressBook) private static void Print(AddressBook addressBook)
{ {
foreach (Person person in addressBook.Person) foreach (Person person in addressBook.People)
{ {
Console.WriteLine("Person ID: {0}", person.Id); Console.WriteLine("Person ID: {0}", person.Id);
Console.WriteLine(" Name: {0}", person.Name); Console.WriteLine(" Name: {0}", person.Name);
...@@ -51,7 +51,7 @@ namespace Google.Protobuf.Examples.AddressBook ...@@ -51,7 +51,7 @@ namespace Google.Protobuf.Examples.AddressBook
Console.WriteLine(" E-mail address: {0}", person.Email); Console.WriteLine(" E-mail address: {0}", person.Email);
} }
foreach (Person.Types.PhoneNumber phoneNumber in person.Phone) foreach (Person.Types.PhoneNumber phoneNumber in person.Phones)
{ {
switch (phoneNumber.Type) switch (phoneNumber.Type)
{ {
......
...@@ -46,7 +46,7 @@ namespace Google.Protobuf.Examples.AddressBook ...@@ -46,7 +46,7 @@ namespace Google.Protobuf.Examples.AddressBook
Id = 1, Id = 1,
Name = "Foo", Name = "Foo",
Email = "foo@bar", Email = "foo@bar",
Phone = { new Person.Types.PhoneNumber { Number = "555-1212" } } Phones = { new Person.Types.PhoneNumber { Number = "555-1212" } }
}; };
using (MemoryStream stream = new MemoryStream()) using (MemoryStream stream = new MemoryStream())
{ {
...@@ -61,7 +61,7 @@ namespace Google.Protobuf.Examples.AddressBook ...@@ -61,7 +61,7 @@ namespace Google.Protobuf.Examples.AddressBook
// And read the address book back again // And read the address book back again
AddressBook restored = AddressBook.Parser.ParseFrom(bytes); AddressBook restored = AddressBook.Parser.ParseFrom(bytes);
// The message performs a deep-comparison on equality: // The message performs a deep-comparison on equality:
if (restored.Person.Count != 1 || !person.Equals(restored.Person[0])) if (restored.People.Count != 1 || !person.Equals(restored.People[0]))
{ {
throw new ApplicationException("There is a bad person in here!"); throw new ApplicationException("There is a bad person in here!");
} }
......
...@@ -24,10 +24,10 @@ message Person { ...@@ -24,10 +24,10 @@ message Person {
PhoneType type = 2; PhoneType type = 2;
} }
repeated PhoneNumber phone = 4; repeated PhoneNumber phones = 4;
} }
// Our address book file is just one of these. // Our address book file is just one of these.
message AddressBook { message AddressBook {
repeated Person person = 1; repeated Person people = 1;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment