update addressbook example
This commit is contained in:
parent
352690efc7
commit
43b17376f7
3 changed files with 6 additions and 6 deletions
|
@ -86,7 +86,7 @@ namespace Google.Protobuf.Examples.AddressBook
|
|||
break;
|
||||
}
|
||||
|
||||
person.Phone.Add(phoneNumber);
|
||||
person.Phones.Add(phoneNumber);
|
||||
}
|
||||
return person;
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ namespace Google.Protobuf.Examples.AddressBook
|
|||
}
|
||||
|
||||
// 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.
|
||||
using (Stream output = File.OpenWrite(args[0]))
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace Google.Protobuf.Examples.AddressBook
|
|||
/// </summary>
|
||||
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(" Name: {0}", person.Name);
|
||||
|
@ -51,7 +51,7 @@ namespace Google.Protobuf.Examples.AddressBook
|
|||
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)
|
||||
{
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace Google.Protobuf.Examples.AddressBook
|
|||
Id = 1,
|
||||
Name = "Foo",
|
||||
Email = "foo@bar",
|
||||
Phone = { new Person.Types.PhoneNumber { Number = "555-1212" } }
|
||||
Phones = { new Person.Types.PhoneNumber { Number = "555-1212" } }
|
||||
};
|
||||
using (MemoryStream stream = new MemoryStream())
|
||||
{
|
||||
|
@ -61,7 +61,7 @@ namespace Google.Protobuf.Examples.AddressBook
|
|||
// And read the address book back again
|
||||
AddressBook restored = AddressBook.Parser.ParseFrom(bytes);
|
||||
// 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!");
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue