Addressbook.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. // Generated by the protocol buffer compiler. DO NOT EDIT!
  2. // source: addressbook.proto
  3. #pragma warning disable 1591, 0612, 3021
  4. #region Designer generated code
  5. using pb = global::Google.Protobuf;
  6. using pbc = global::Google.Protobuf.Collections;
  7. using pbr = global::Google.Protobuf.Reflection;
  8. using scg = global::System.Collections.Generic;
  9. namespace Google.Protobuf.Examples.AddressBook {
  10. /// <summary>Holder for reflection information generated from addressbook.proto</summary>
  11. public static partial class AddressbookReflection {
  12. #region Descriptor
  13. /// <summary>File descriptor for addressbook.proto</summary>
  14. public static pbr::FileDescriptor Descriptor {
  15. get { return descriptor; }
  16. }
  17. private static pbr::FileDescriptor descriptor;
  18. static AddressbookReflection() {
  19. byte[] descriptorData = global::System.Convert.FromBase64String(
  20. string.Concat(
  21. "ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi1QEKBlBlcnNvbhIMCgRu",
  22. "YW1lGAEgASgJEgoKAmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEiwKBnBob25l",
  23. "cxgEIAMoCzIcLnR1dG9yaWFsLlBlcnNvbi5QaG9uZU51bWJlchpHCgtQaG9u",
  24. "ZU51bWJlchIOCgZudW1iZXIYASABKAkSKAoEdHlwZRgCIAEoDjIaLnR1dG9y",
  25. "aWFsLlBlcnNvbi5QaG9uZVR5cGUiKwoJUGhvbmVUeXBlEgoKBk1PQklMRRAA",
  26. "EggKBEhPTUUQARIICgRXT1JLEAIiLwoLQWRkcmVzc0Jvb2sSIAoGcGVvcGxl",
  27. "GAEgAygLMhAudHV0b3JpYWwuUGVyc29uQlAKFGNvbS5leGFtcGxlLnR1dG9y",
  28. "aWFsQhFBZGRyZXNzQm9va1Byb3Rvc6oCJEdvb2dsZS5Qcm90b2J1Zi5FeGFt",
  29. "cGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z"));
  30. descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
  31. new pbr::FileDescriptor[] { },
  32. new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
  33. new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.Person), global::Google.Protobuf.Examples.AddressBook.Person.Parser, new[]{ "Name", "Id", "Email", "Phones" }, null, new[]{ typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser, new[]{ "Number", "Type" }, null, null, null)}),
  34. new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), global::Google.Protobuf.Examples.AddressBook.AddressBook.Parser, new[]{ "People" }, null, null, null)
  35. }));
  36. }
  37. #endregion
  38. }
  39. #region Messages
  40. /// <summary>
  41. /// [START messages]
  42. /// </summary>
  43. public sealed partial class Person : pb::IMessage<Person> {
  44. private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person());
  45. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  46. public static pb::MessageParser<Person> Parser { get { return _parser; } }
  47. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  48. public static pbr::MessageDescriptor Descriptor {
  49. get { return global::Google.Protobuf.Examples.AddressBook.AddressbookReflection.Descriptor.MessageTypes[0]; }
  50. }
  51. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  52. pbr::MessageDescriptor pb::IMessage.Descriptor {
  53. get { return Descriptor; }
  54. }
  55. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  56. public Person() {
  57. OnConstruction();
  58. }
  59. partial void OnConstruction();
  60. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  61. public Person(Person other) : this() {
  62. name_ = other.name_;
  63. id_ = other.id_;
  64. email_ = other.email_;
  65. phones_ = other.phones_.Clone();
  66. }
  67. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  68. public Person Clone() {
  69. return new Person(this);
  70. }
  71. /// <summary>Field number for the "name" field.</summary>
  72. public const int NameFieldNumber = 1;
  73. private string name_ = "";
  74. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  75. public string Name {
  76. get { return name_; }
  77. set {
  78. name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
  79. }
  80. }
  81. /// <summary>Field number for the "id" field.</summary>
  82. public const int IdFieldNumber = 2;
  83. private int id_;
  84. /// <summary>
  85. /// Unique ID number for this person.
  86. /// </summary>
  87. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  88. public int Id {
  89. get { return id_; }
  90. set {
  91. id_ = value;
  92. }
  93. }
  94. /// <summary>Field number for the "email" field.</summary>
  95. public const int EmailFieldNumber = 3;
  96. private string email_ = "";
  97. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  98. public string Email {
  99. get { return email_; }
  100. set {
  101. email_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
  102. }
  103. }
  104. /// <summary>Field number for the "phones" field.</summary>
  105. public const int PhonesFieldNumber = 4;
  106. private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> _repeated_phones_codec
  107. = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser);
  108. private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> phones_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber>();
  109. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  110. public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> Phones {
  111. get { return phones_; }
  112. }
  113. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  114. public override bool Equals(object other) {
  115. return Equals(other as Person);
  116. }
  117. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  118. public bool Equals(Person other) {
  119. if (ReferenceEquals(other, null)) {
  120. return false;
  121. }
  122. if (ReferenceEquals(other, this)) {
  123. return true;
  124. }
  125. if (Name != other.Name) return false;
  126. if (Id != other.Id) return false;
  127. if (Email != other.Email) return false;
  128. if(!phones_.Equals(other.phones_)) return false;
  129. return true;
  130. }
  131. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  132. public override int GetHashCode() {
  133. int hash = 1;
  134. if (Name.Length != 0) hash ^= Name.GetHashCode();
  135. if (Id != 0) hash ^= Id.GetHashCode();
  136. if (Email.Length != 0) hash ^= Email.GetHashCode();
  137. hash ^= phones_.GetHashCode();
  138. return hash;
  139. }
  140. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  141. public override string ToString() {
  142. return pb::JsonFormatter.ToDiagnosticString(this);
  143. }
  144. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  145. public void WriteTo(pb::CodedOutputStream output) {
  146. if (Name.Length != 0) {
  147. output.WriteRawTag(10);
  148. output.WriteString(Name);
  149. }
  150. if (Id != 0) {
  151. output.WriteRawTag(16);
  152. output.WriteInt32(Id);
  153. }
  154. if (Email.Length != 0) {
  155. output.WriteRawTag(26);
  156. output.WriteString(Email);
  157. }
  158. phones_.WriteTo(output, _repeated_phones_codec);
  159. }
  160. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  161. public int CalculateSize() {
  162. int size = 0;
  163. if (Name.Length != 0) {
  164. size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
  165. }
  166. if (Id != 0) {
  167. size += 1 + pb::CodedOutputStream.ComputeInt32Size(Id);
  168. }
  169. if (Email.Length != 0) {
  170. size += 1 + pb::CodedOutputStream.ComputeStringSize(Email);
  171. }
  172. size += phones_.CalculateSize(_repeated_phones_codec);
  173. return size;
  174. }
  175. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  176. public void MergeFrom(Person other) {
  177. if (other == null) {
  178. return;
  179. }
  180. if (other.Name.Length != 0) {
  181. Name = other.Name;
  182. }
  183. if (other.Id != 0) {
  184. Id = other.Id;
  185. }
  186. if (other.Email.Length != 0) {
  187. Email = other.Email;
  188. }
  189. phones_.Add(other.phones_);
  190. }
  191. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  192. public void MergeFrom(pb::CodedInputStream input) {
  193. uint tag;
  194. while ((tag = input.ReadTag()) != 0) {
  195. switch(tag) {
  196. default:
  197. input.SkipLastField();
  198. break;
  199. case 10: {
  200. Name = input.ReadString();
  201. break;
  202. }
  203. case 16: {
  204. Id = input.ReadInt32();
  205. break;
  206. }
  207. case 26: {
  208. Email = input.ReadString();
  209. break;
  210. }
  211. case 34: {
  212. phones_.AddEntriesFrom(input, _repeated_phones_codec);
  213. break;
  214. }
  215. }
  216. }
  217. }
  218. #region Nested types
  219. /// <summary>Container for nested types declared in the Person message type.</summary>
  220. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  221. public static partial class Types {
  222. public enum PhoneType {
  223. [pbr::OriginalName("MOBILE")] Mobile = 0,
  224. [pbr::OriginalName("HOME")] Home = 1,
  225. [pbr::OriginalName("WORK")] Work = 2,
  226. }
  227. public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> {
  228. private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber());
  229. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  230. public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } }
  231. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  232. public static pbr::MessageDescriptor Descriptor {
  233. get { return global::Google.Protobuf.Examples.AddressBook.Person.Descriptor.NestedTypes[0]; }
  234. }
  235. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  236. pbr::MessageDescriptor pb::IMessage.Descriptor {
  237. get { return Descriptor; }
  238. }
  239. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  240. public PhoneNumber() {
  241. OnConstruction();
  242. }
  243. partial void OnConstruction();
  244. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  245. public PhoneNumber(PhoneNumber other) : this() {
  246. number_ = other.number_;
  247. type_ = other.type_;
  248. }
  249. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  250. public PhoneNumber Clone() {
  251. return new PhoneNumber(this);
  252. }
  253. /// <summary>Field number for the "number" field.</summary>
  254. public const int NumberFieldNumber = 1;
  255. private string number_ = "";
  256. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  257. public string Number {
  258. get { return number_; }
  259. set {
  260. number_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
  261. }
  262. }
  263. /// <summary>Field number for the "type" field.</summary>
  264. public const int TypeFieldNumber = 2;
  265. private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = 0;
  266. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  267. public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type {
  268. get { return type_; }
  269. set {
  270. type_ = value;
  271. }
  272. }
  273. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  274. public override bool Equals(object other) {
  275. return Equals(other as PhoneNumber);
  276. }
  277. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  278. public bool Equals(PhoneNumber other) {
  279. if (ReferenceEquals(other, null)) {
  280. return false;
  281. }
  282. if (ReferenceEquals(other, this)) {
  283. return true;
  284. }
  285. if (Number != other.Number) return false;
  286. if (Type != other.Type) return false;
  287. return true;
  288. }
  289. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  290. public override int GetHashCode() {
  291. int hash = 1;
  292. if (Number.Length != 0) hash ^= Number.GetHashCode();
  293. if (Type != 0) hash ^= Type.GetHashCode();
  294. return hash;
  295. }
  296. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  297. public override string ToString() {
  298. return pb::JsonFormatter.ToDiagnosticString(this);
  299. }
  300. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  301. public void WriteTo(pb::CodedOutputStream output) {
  302. if (Number.Length != 0) {
  303. output.WriteRawTag(10);
  304. output.WriteString(Number);
  305. }
  306. if (Type != 0) {
  307. output.WriteRawTag(16);
  308. output.WriteEnum((int) Type);
  309. }
  310. }
  311. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  312. public int CalculateSize() {
  313. int size = 0;
  314. if (Number.Length != 0) {
  315. size += 1 + pb::CodedOutputStream.ComputeStringSize(Number);
  316. }
  317. if (Type != 0) {
  318. size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
  319. }
  320. return size;
  321. }
  322. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  323. public void MergeFrom(PhoneNumber other) {
  324. if (other == null) {
  325. return;
  326. }
  327. if (other.Number.Length != 0) {
  328. Number = other.Number;
  329. }
  330. if (other.Type != 0) {
  331. Type = other.Type;
  332. }
  333. }
  334. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  335. public void MergeFrom(pb::CodedInputStream input) {
  336. uint tag;
  337. while ((tag = input.ReadTag()) != 0) {
  338. switch(tag) {
  339. default:
  340. input.SkipLastField();
  341. break;
  342. case 10: {
  343. Number = input.ReadString();
  344. break;
  345. }
  346. case 16: {
  347. type_ = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum();
  348. break;
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. #endregion
  356. }
  357. /// <summary>
  358. /// Our address book file is just one of these.
  359. /// </summary>
  360. public sealed partial class AddressBook : pb::IMessage<AddressBook> {
  361. private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
  362. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  363. public static pb::MessageParser<AddressBook> Parser { get { return _parser; } }
  364. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  365. public static pbr::MessageDescriptor Descriptor {
  366. get { return global::Google.Protobuf.Examples.AddressBook.AddressbookReflection.Descriptor.MessageTypes[1]; }
  367. }
  368. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  369. pbr::MessageDescriptor pb::IMessage.Descriptor {
  370. get { return Descriptor; }
  371. }
  372. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  373. public AddressBook() {
  374. OnConstruction();
  375. }
  376. partial void OnConstruction();
  377. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  378. public AddressBook(AddressBook other) : this() {
  379. people_ = other.people_.Clone();
  380. }
  381. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  382. public AddressBook Clone() {
  383. return new AddressBook(this);
  384. }
  385. /// <summary>Field number for the "people" field.</summary>
  386. public const int PeopleFieldNumber = 1;
  387. private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person> _repeated_people_codec
  388. = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser);
  389. private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> people_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person>();
  390. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  391. public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> People {
  392. get { return people_; }
  393. }
  394. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  395. public override bool Equals(object other) {
  396. return Equals(other as AddressBook);
  397. }
  398. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  399. public bool Equals(AddressBook other) {
  400. if (ReferenceEquals(other, null)) {
  401. return false;
  402. }
  403. if (ReferenceEquals(other, this)) {
  404. return true;
  405. }
  406. if(!people_.Equals(other.people_)) return false;
  407. return true;
  408. }
  409. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  410. public override int GetHashCode() {
  411. int hash = 1;
  412. hash ^= people_.GetHashCode();
  413. return hash;
  414. }
  415. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  416. public override string ToString() {
  417. return pb::JsonFormatter.ToDiagnosticString(this);
  418. }
  419. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  420. public void WriteTo(pb::CodedOutputStream output) {
  421. people_.WriteTo(output, _repeated_people_codec);
  422. }
  423. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  424. public int CalculateSize() {
  425. int size = 0;
  426. size += people_.CalculateSize(_repeated_people_codec);
  427. return size;
  428. }
  429. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  430. public void MergeFrom(AddressBook other) {
  431. if (other == null) {
  432. return;
  433. }
  434. people_.Add(other.people_);
  435. }
  436. [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
  437. public void MergeFrom(pb::CodedInputStream input) {
  438. uint tag;
  439. while ((tag = input.ReadTag()) != 0) {
  440. switch(tag) {
  441. default:
  442. input.SkipLastField();
  443. break;
  444. case 10: {
  445. people_.AddEntriesFrom(input, _repeated_people_codec);
  446. break;
  447. }
  448. }
  449. }
  450. }
  451. }
  452. #endregion
  453. }
  454. #endregion Designer generated code