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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
47 deletions
+47
-47
AddPerson.cs
csharp/src/AddressBook/AddPerson.cs
+2
-2
Addressbook.cs
csharp/src/AddressBook/Addressbook.cs
+39
-39
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
...
@@ -86,7 +86,7 @@ namespace Google.Protobuf.Examples.AddressBook
break
;
break
;
}
}
person
.
Phone
.
Add
(
phoneNumber
);
person
.
Phone
s
.
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
.
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.
// Write the new address book back to disk.
using
(
Stream
output
=
File
.
OpenWrite
(
args
[
0
]))
using
(
Stream
output
=
File
.
OpenWrite
(
args
[
0
]))
...
...
csharp/src/AddressBook/Addressbook.cs
View file @
c792db5d
...
@@ -26,27 +26,27 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -26,27 +26,27 @@ namespace Google.Protobuf.Examples.AddressBook {
static
Addressbook
()
{
static
Addressbook
()
{
byte
[]
descriptorData
=
global
::
System
.
Convert
.
FromBase64String
(
byte
[]
descriptorData
=
global
::
System
.
Convert
.
FromBase64String
(
string
.
Concat
(
string
.
Concat
(
"ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi1
A
EKBlBlcnNvbhIMCgRu"
,
"ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi1
Q
EKBlBlcnNvbhIMCgRu"
,
"YW1lGAEgASgJEgoKAmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEi
sKBX
Bob25l"
,
"YW1lGAEgASgJEgoKAmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEi
wKBn
Bob25l"
,
"
GAQgAygLMhwudHV0b3JpYWwuUGVyc29uLlBob25lTnVtYmVyGkcKC1Bob25l
"
,
"
cxgEIAMoCzIcLnR1dG9yaWFsLlBlcnNvbi5QaG9uZU51bWJlchpHCgtQaG9u
"
,
"
TnVtYmVyEg4KBm51bWJlchgBIAEoCRIoCgR0eXBlGAIgASgOMhoudHV0b3Jp
"
,
"
ZU51bWJlchIOCgZudW1iZXIYASABKAkSKAoEdHlwZRgCIAEoDjIaLnR1dG9y
"
,
"
YWwuUGVyc29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAAS
"
,
"
aWFsLlBlcnNvbi5QaG9uZVR5cGUiKwoJUGhvbmVUeXBlEgoKBk1PQklMRRAA
"
,
"
CAoESE9NRRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZXJzb24Y
"
,
"
EggKBEhPTUUQARIICgRXT1JLEAIiLwoLQWRkcmVzc0Jvb2sSIAoGcGVvcGxl
"
,
"
ASADKAsyEC50dXRvcmlhbC5QZXJzb25CUAoUY29tLmV4YW1wbGUudHV0b3Jp
"
,
"
GAEgAygLMhAudHV0b3JpYWwuUGVyc29uQlAKFGNvbS5leGFtcGxlLnR1dG9y
"
,
"
YWxCEUFkZHJlc3NCb29rUHJvdG9zqgIkR29vZ2xlLlByb3RvYnVmLkV4YW1w
"
,
"
aWFsQhFBZGRyZXNzQm9va1Byb3Rvc6oCJEdvb2dsZS5Qcm90b2J1Zi5FeGFt
"
,
"
bGVzLkFkZHJlc3NCb29rYgZwcm90bzM=
"
));
"
cGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z
"
));
descriptor
=
pbr
::
FileDescriptor
.
InternalBuildGeneratedFileFrom
(
descriptorData
,
descriptor
=
pbr
::
FileDescriptor
.
InternalBuildGeneratedFileFrom
(
descriptorData
,
new
pbr
::
FileDescriptor
[]
{
new
pbr
::
FileDescriptor
[]
{
});
});
internal__static_tutorial_Person__FieldAccessorTable
=
internal__static_tutorial_Person__FieldAccessorTable
=
new
pbr
::
FieldAccessorTable
(
typeof
(
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
),
descriptor
.
MessageTypes
[
0
],
new
pbr
::
FieldAccessorTable
(
typeof
(
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
),
descriptor
.
MessageTypes
[
0
],
new
string
[]
{
"Name"
,
"Id"
,
"Email"
,
"Phone"
,
},
new
string
[]
{
});
new
string
[]
{
"Name"
,
"Id"
,
"Email"
,
"Phone
s
"
,
},
new
string
[]
{
});
internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable
=
internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable
=
new
pbr
::
FieldAccessorTable
(
typeof
(
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
),
descriptor
.
MessageTypes
[
0
].
NestedTypes
[
0
],
new
pbr
::
FieldAccessorTable
(
typeof
(
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
),
descriptor
.
MessageTypes
[
0
].
NestedTypes
[
0
],
new
string
[]
{
"Number"
,
"Type"
,
},
new
string
[]
{
});
new
string
[]
{
"Number"
,
"Type"
,
},
new
string
[]
{
});
internal__static_tutorial_AddressBook__FieldAccessorTable
=
internal__static_tutorial_AddressBook__FieldAccessorTable
=
new
pbr
::
FieldAccessorTable
(
typeof
(
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
AddressBook
),
descriptor
.
MessageTypes
[
1
],
new
pbr
::
FieldAccessorTable
(
typeof
(
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
AddressBook
),
descriptor
.
MessageTypes
[
1
],
new
string
[]
{
"Pe
rson
"
,
},
new
string
[]
{
});
new
string
[]
{
"Pe
ople
"
,
},
new
string
[]
{
});
}
}
#
endregion
#
endregion
...
@@ -57,7 +57,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -57,7 +57,7 @@ namespace Google.Protobuf.Examples.AddressBook {
private
static
readonly
pb
::
MessageParser
<
Person
>
_parser
=
new
pb
::
MessageParser
<
Person
>(()
=>
new
Person
());
private
static
readonly
pb
::
MessageParser
<
Person
>
_parser
=
new
pb
::
MessageParser
<
Person
>(()
=>
new
Person
());
public
static
pb
::
MessageParser
<
Person
>
Parser
{
get
{
return
_parser
;
}
}
public
static
pb
::
MessageParser
<
Person
>
Parser
{
get
{
return
_parser
;
}
}
private
static
readonly
string
[]
_fieldNames
=
new
string
[]
{
"email"
,
"id"
,
"name"
,
"phone"
};
private
static
readonly
string
[]
_fieldNames
=
new
string
[]
{
"email"
,
"id"
,
"name"
,
"phone
s
"
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
26
,
16
,
10
,
34
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
26
,
16
,
10
,
34
};
public
static
pbr
::
MessageDescriptor
Descriptor
{
public
static
pbr
::
MessageDescriptor
Descriptor
{
get
{
return
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Addressbook
.
Descriptor
.
MessageTypes
[
0
];
}
get
{
return
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Addressbook
.
Descriptor
.
MessageTypes
[
0
];
}
...
@@ -80,7 +80,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -80,7 +80,7 @@ namespace Google.Protobuf.Examples.AddressBook {
name_
=
other
.
name_
;
name_
=
other
.
name_
;
id_
=
other
.
id_
;
id_
=
other
.
id_
;
email_
=
other
.
email_
;
email_
=
other
.
email_
;
phone
_
=
other
.
phone
_
.
Clone
();
phone
s_
=
other
.
phones
_
.
Clone
();
}
}
public
Person
Clone
()
{
public
Person
Clone
()
{
...
@@ -92,7 +92,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -92,7 +92,7 @@ namespace Google.Protobuf.Examples.AddressBook {
return
;
return
;
}
}
_frozen
=
true
;
_frozen
=
true
;
phone_
.
Freeze
();
phone
s
_
.
Freeze
();
}
}
public
const
int
NameFieldNumber
=
1
;
public
const
int
NameFieldNumber
=
1
;
...
@@ -125,12 +125,12 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -125,12 +125,12 @@ namespace Google.Protobuf.Examples.AddressBook {
}
}
}
}
public
const
int
PhoneFieldNumber
=
4
;
public
const
int
Phone
s
FieldNumber
=
4
;
private
static
readonly
pb
::
FieldCodec
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
>
_repeated_phone_codec
private
static
readonly
pb
::
FieldCodec
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
>
_repeated_phone
s
_codec
=
pb
::
FieldCodec
.
ForMessage
(
34
,
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
.
Parser
);
=
pb
::
FieldCodec
.
ForMessage
(
34
,
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
.
Parser
);
private
readonly
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
>
phone_
=
new
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
>();
private
readonly
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
>
phone
s
_
=
new
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
>();
public
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
>
Phone
{
public
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Types
.
PhoneNumber
>
Phone
s
{
get
{
return
phone_
;
}
get
{
return
phone
s
_
;
}
}
}
public
override
bool
Equals
(
object
other
)
{
public
override
bool
Equals
(
object
other
)
{
...
@@ -147,7 +147,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -147,7 +147,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if
(
Name
!=
other
.
Name
)
return
false
;
if
(
Name
!=
other
.
Name
)
return
false
;
if
(
Id
!=
other
.
Id
)
return
false
;
if
(
Id
!=
other
.
Id
)
return
false
;
if
(
Email
!=
other
.
Email
)
return
false
;
if
(
Email
!=
other
.
Email
)
return
false
;
if
(!
phone
_
.
Equals
(
other
.
phone
_
))
return
false
;
if
(!
phone
s_
.
Equals
(
other
.
phones
_
))
return
false
;
return
true
;
return
true
;
}
}
...
@@ -156,7 +156,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -156,7 +156,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if
(
Name
.
Length
!=
0
)
hash
^=
Name
.
GetHashCode
();
if
(
Name
.
Length
!=
0
)
hash
^=
Name
.
GetHashCode
();
if
(
Id
!=
0
)
hash
^=
Id
.
GetHashCode
();
if
(
Id
!=
0
)
hash
^=
Id
.
GetHashCode
();
if
(
Email
.
Length
!=
0
)
hash
^=
Email
.
GetHashCode
();
if
(
Email
.
Length
!=
0
)
hash
^=
Email
.
GetHashCode
();
hash
^=
phone_
.
GetHashCode
();
hash
^=
phone
s
_
.
GetHashCode
();
return
hash
;
return
hash
;
}
}
...
@@ -177,7 +177,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -177,7 +177,7 @@ namespace Google.Protobuf.Examples.AddressBook {
output
.
WriteRawTag
(
26
);
output
.
WriteRawTag
(
26
);
output
.
WriteString
(
Email
);
output
.
WriteString
(
Email
);
}
}
phone
_
.
WriteTo
(
output
,
_repeated_phone
_codec
);
phone
s_
.
WriteTo
(
output
,
_repeated_phones
_codec
);
}
}
public
int
CalculateSize
()
{
public
int
CalculateSize
()
{
...
@@ -191,7 +191,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -191,7 +191,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if
(
Email
.
Length
!=
0
)
{
if
(
Email
.
Length
!=
0
)
{
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Email
);
size
+=
1
+
pb
::
CodedOutputStream
.
ComputeStringSize
(
Email
);
}
}
size
+=
phone
_
.
CalculateSize
(
_repeated_phone
_codec
);
size
+=
phone
s_
.
CalculateSize
(
_repeated_phones
_codec
);
return
size
;
return
size
;
}
}
...
@@ -208,7 +208,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -208,7 +208,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if
(
other
.
Email
.
Length
!=
0
)
{
if
(
other
.
Email
.
Length
!=
0
)
{
Email
=
other
.
Email
;
Email
=
other
.
Email
;
}
}
phone
_
.
Add
(
other
.
phone
_
);
phone
s_
.
Add
(
other
.
phones
_
);
}
}
public
void
MergeFrom
(
pb
::
CodedInputStream
input
)
{
public
void
MergeFrom
(
pb
::
CodedInputStream
input
)
{
...
@@ -235,7 +235,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -235,7 +235,7 @@ namespace Google.Protobuf.Examples.AddressBook {
break
;
break
;
}
}
case
34
:
{
case
34
:
{
phone
_
.
AddEntriesFrom
(
input
,
_repeated_phone
_codec
);
phone
s_
.
AddEntriesFrom
(
input
,
_repeated_phones
_codec
);
break
;
break
;
}
}
}
}
...
@@ -407,7 +407,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -407,7 +407,7 @@ namespace Google.Protobuf.Examples.AddressBook {
private
static
readonly
pb
::
MessageParser
<
AddressBook
>
_parser
=
new
pb
::
MessageParser
<
AddressBook
>(()
=>
new
AddressBook
());
private
static
readonly
pb
::
MessageParser
<
AddressBook
>
_parser
=
new
pb
::
MessageParser
<
AddressBook
>(()
=>
new
AddressBook
());
public
static
pb
::
MessageParser
<
AddressBook
>
Parser
{
get
{
return
_parser
;
}
}
public
static
pb
::
MessageParser
<
AddressBook
>
Parser
{
get
{
return
_parser
;
}
}
private
static
readonly
string
[]
_fieldNames
=
new
string
[]
{
"pe
rson
"
};
private
static
readonly
string
[]
_fieldNames
=
new
string
[]
{
"pe
ople
"
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
10
};
private
static
readonly
uint
[]
_fieldTags
=
new
uint
[]
{
10
};
public
static
pbr
::
MessageDescriptor
Descriptor
{
public
static
pbr
::
MessageDescriptor
Descriptor
{
get
{
return
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Addressbook
.
Descriptor
.
MessageTypes
[
1
];
}
get
{
return
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Addressbook
.
Descriptor
.
MessageTypes
[
1
];
}
...
@@ -427,7 +427,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -427,7 +427,7 @@ namespace Google.Protobuf.Examples.AddressBook {
partial
void
OnConstruction
();
partial
void
OnConstruction
();
public
AddressBook
(
AddressBook
other
)
:
this
()
{
public
AddressBook
(
AddressBook
other
)
:
this
()
{
pe
rson_
=
other
.
person
_
.
Clone
();
pe
ople_
=
other
.
people
_
.
Clone
();
}
}
public
AddressBook
Clone
()
{
public
AddressBook
Clone
()
{
...
@@ -439,15 +439,15 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -439,15 +439,15 @@ namespace Google.Protobuf.Examples.AddressBook {
return
;
return
;
}
}
_frozen
=
true
;
_frozen
=
true
;
pe
rson
_
.
Freeze
();
pe
ople
_
.
Freeze
();
}
}
public
const
int
Pe
rson
FieldNumber
=
1
;
public
const
int
Pe
ople
FieldNumber
=
1
;
private
static
readonly
pb
::
FieldCodec
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
>
_repeated_pe
rson
_codec
private
static
readonly
pb
::
FieldCodec
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
>
_repeated_pe
ople
_codec
=
pb
::
FieldCodec
.
ForMessage
(
10
,
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Parser
);
=
pb
::
FieldCodec
.
ForMessage
(
10
,
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
.
Parser
);
private
readonly
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
>
pe
rson
_
=
new
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
>();
private
readonly
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
>
pe
ople
_
=
new
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
>();
public
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
>
Pe
rson
{
public
pbc
::
RepeatedField
<
global
::
Google
.
Protobuf
.
Examples
.
AddressBook
.
Person
>
Pe
ople
{
get
{
return
pe
rson
_
;
}
get
{
return
pe
ople
_
;
}
}
}
public
override
bool
Equals
(
object
other
)
{
public
override
bool
Equals
(
object
other
)
{
...
@@ -461,13 +461,13 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -461,13 +461,13 @@ namespace Google.Protobuf.Examples.AddressBook {
if
(
ReferenceEquals
(
other
,
this
))
{
if
(
ReferenceEquals
(
other
,
this
))
{
return
true
;
return
true
;
}
}
if
(!
pe
rson_
.
Equals
(
other
.
person
_
))
return
false
;
if
(!
pe
ople_
.
Equals
(
other
.
people
_
))
return
false
;
return
true
;
return
true
;
}
}
public
override
int
GetHashCode
()
{
public
override
int
GetHashCode
()
{
int
hash
=
1
;
int
hash
=
1
;
hash
^=
pe
rson
_
.
GetHashCode
();
hash
^=
pe
ople
_
.
GetHashCode
();
return
hash
;
return
hash
;
}
}
...
@@ -476,12 +476,12 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -476,12 +476,12 @@ namespace Google.Protobuf.Examples.AddressBook {
}
}
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
pe
rson_
.
WriteTo
(
output
,
_repeated_person
_codec
);
pe
ople_
.
WriteTo
(
output
,
_repeated_people
_codec
);
}
}
public
int
CalculateSize
()
{
public
int
CalculateSize
()
{
int
size
=
0
;
int
size
=
0
;
size
+=
pe
rson_
.
CalculateSize
(
_repeated_person
_codec
);
size
+=
pe
ople_
.
CalculateSize
(
_repeated_people
_codec
);
return
size
;
return
size
;
}
}
...
@@ -489,7 +489,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -489,7 +489,7 @@ namespace Google.Protobuf.Examples.AddressBook {
if
(
other
==
null
)
{
if
(
other
==
null
)
{
return
;
return
;
}
}
pe
rson_
.
Add
(
other
.
person
_
);
pe
ople_
.
Add
(
other
.
people
_
);
}
}
public
void
MergeFrom
(
pb
::
CodedInputStream
input
)
{
public
void
MergeFrom
(
pb
::
CodedInputStream
input
)
{
...
@@ -504,7 +504,7 @@ namespace Google.Protobuf.Examples.AddressBook {
...
@@ -504,7 +504,7 @@ namespace Google.Protobuf.Examples.AddressBook {
}
}
break
;
break
;
case
10
:
{
case
10
:
{
pe
rson_
.
AddEntriesFrom
(
input
,
_repeated_person
_codec
);
pe
ople_
.
AddEntriesFrom
(
input
,
_repeated_people
_codec
);
break
;
break
;
}
}
}
}
...
...
csharp/src/AddressBook/ListPeople.cs
View file @
c792db5d
...
@@ -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
.
Pe
rson
)
foreach
(
Person
person
in
addressBook
.
Pe
ople
)
{
{
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
.
Phone
s
)
{
{
switch
(
phoneNumber
.
Type
)
switch
(
phoneNumber
.
Type
)
{
{
...
...
csharp/src/AddressBook/SampleUsage.cs
View file @
c792db5d
...
@@ -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"
}
}
Phone
s
=
{
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
.
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!"
);
throw
new
ApplicationException
(
"There is a bad person in here!"
);
}
}
...
...
examples/addressbook.proto
View file @
c792db5d
...
@@ -24,10 +24,10 @@ message Person {
...
@@ -24,10 +24,10 @@ message Person {
PhoneType
type
=
2
;
PhoneType
type
=
2
;
}
}
repeated
PhoneNumber
phone
=
4
;
repeated
PhoneNumber
phone
s
=
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
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