Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
c792db5d
Commit
c792db5d
authored
Jul 21, 2015
by
Jan Tattermusch
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #628 from jtattermusch/csharp_addressbook_update
C# addressbook update
parents
bd3367c8
43b17376
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
8 additions
and
8 deletions
+8
-8
AddPerson.cs
csharp/src/AddressBook/AddPerson.cs
+2
-2
Addressbook.cs
csharp/src/AddressBook/Addressbook.cs
+0
-0
ListPeople.cs
csharp/src/AddressBook/ListPeople.cs
+2
-2
SampleUsage.cs
csharp/src/AddressBook/SampleUsage.cs
+2
-2
addressbook.proto
examples/addressbook.proto
+2
-2
No files found.
csharp/src/AddressBook/AddPerson.cs
View file @
c792db5d
...
...
@@ -86,7 +86,7 @@ namespace Google.Protobuf.Examples.AddressBook
break
;
}
person
.
Phone
.
Add
(
phoneNumber
);
person
.
Phone
s
.
Add
(
phoneNumber
);
}
return
person
;
}
...
...
@@ -119,7 +119,7 @@ namespace Google.Protobuf.Examples.AddressBook
}
// Add an address.
addressBook
.
Pe
rson
.
Add
(
PromptForAddress
(
Console
.
In
,
Console
.
Out
));
addressBook
.
Pe
ople
.
Add
(
PromptForAddress
(
Console
.
In
,
Console
.
Out
));
// Write the new address book back to disk.
using
(
Stream
output
=
File
.
OpenWrite
(
args
[
0
]))
...
...
csharp/src/AddressBook/Addressbook.cs
View file @
c792db5d
This diff is collapsed.
Click to expand it.
csharp/src/AddressBook/ListPeople.cs
View file @
c792db5d
...
...
@@ -42,7 +42,7 @@ namespace Google.Protobuf.Examples.AddressBook
/// </summary>
private
static
void
Print
(
AddressBook
addressBook
)
{
foreach
(
Person
person
in
addressBook
.
Pe
rson
)
foreach
(
Person
person
in
addressBook
.
Pe
ople
)
{
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
.
Phone
s
)
{
switch
(
phoneNumber
.
Type
)
{
...
...
csharp/src/AddressBook/SampleUsage.cs
View file @
c792db5d
...
...
@@ -46,7 +46,7 @@ namespace Google.Protobuf.Examples.AddressBook
Id
=
1
,
Name
=
"Foo"
,
Email
=
"foo@bar"
,
Phone
=
{
new
Person
.
Types
.
PhoneNumber
{
Number
=
"555-1212"
}
}
Phone
s
=
{
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
.
Pe
rson
.
Count
!=
1
||
!
person
.
Equals
(
restored
.
Person
[
0
]))
if
(
restored
.
Pe
ople
.
Count
!=
1
||
!
person
.
Equals
(
restored
.
People
[
0
]))
{
throw
new
ApplicationException
(
"There is a bad person in here!"
);
}
...
...
examples/addressbook.proto
View file @
c792db5d
...
...
@@ -24,10 +24,10 @@ message Person {
PhoneType
type
=
2
;
}
repeated
PhoneNumber
phone
=
4
;
repeated
PhoneNumber
phone
s
=
4
;
}
// Our address book file is just one of these.
message
AddressBook
{
repeated
Person
pe
rson
=
1
;
repeated
Person
pe
ople
=
1
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment