Addressbook.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520
  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. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  11. public static partial class Addressbook {
  12. #region Static variables
  13. internal static pbr::FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable;
  14. internal static pbr::FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable;
  15. internal static pbr::FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable;
  16. #endregion
  17. #region Descriptor
  18. public static pbr::FileDescriptor Descriptor {
  19. get { return descriptor; }
  20. }
  21. private static pbr::FileDescriptor descriptor;
  22. static Addressbook() {
  23. byte[] descriptorData = global::System.Convert.FromBase64String(
  24. string.Concat(
  25. "ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi1AEKBlBlcnNvbhIMCgRu",
  26. "YW1lGAEgASgJEgoKAmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEisKBXBob25l",
  27. "GAQgAygLMhwudHV0b3JpYWwuUGVyc29uLlBob25lTnVtYmVyGkcKC1Bob25l",
  28. "TnVtYmVyEg4KBm51bWJlchgBIAEoCRIoCgR0eXBlGAIgASgOMhoudHV0b3Jp",
  29. "YWwuUGVyc29uLlBob25lVHlwZSIrCglQaG9uZVR5cGUSCgoGTU9CSUxFEAAS",
  30. "CAoESE9NRRABEggKBFdPUksQAiIvCgtBZGRyZXNzQm9vaxIgCgZwZXJzb24Y",
  31. "ASADKAsyEC50dXRvcmlhbC5QZXJzb25CUAoUY29tLmV4YW1wbGUudHV0b3Jp",
  32. "YWxCEUFkZHJlc3NCb29rUHJvdG9zqgIkR29vZ2xlLlByb3RvYnVmLkV4YW1w",
  33. "bGVzLkFkZHJlc3NCb29rYgZwcm90bzM="));
  34. descriptor = pbr::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
  35. new pbr::FileDescriptor[] {
  36. });
  37. internal__static_tutorial_Person__FieldAccessorTable =
  38. new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person), descriptor.MessageTypes[0],
  39. new string[] { "Name", "Id", "Email", "Phone", }, new string[] { });
  40. internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable =
  41. new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), descriptor.MessageTypes[0].NestedTypes[0],
  42. new string[] { "Number", "Type", }, new string[] { });
  43. internal__static_tutorial_AddressBook__FieldAccessorTable =
  44. new pbr::FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), descriptor.MessageTypes[1],
  45. new string[] { "Person", }, new string[] { });
  46. }
  47. #endregion
  48. }
  49. #region Messages
  50. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  51. public sealed partial class Person : pb::IMessage<Person> {
  52. private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person());
  53. public static pb::MessageParser<Person> Parser { get { return _parser; } }
  54. private static readonly string[] _fieldNames = new string[] { "email", "id", "name", "phone" };
  55. private static readonly uint[] _fieldTags = new uint[] { 26, 16, 10, 34 };
  56. public static pbr::MessageDescriptor Descriptor {
  57. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.Descriptor.MessageTypes[0]; }
  58. }
  59. pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
  60. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person__FieldAccessorTable; }
  61. }
  62. private bool _frozen = false;
  63. public bool IsFrozen { get { return _frozen; } }
  64. public Person() {
  65. OnConstruction();
  66. }
  67. partial void OnConstruction();
  68. public Person(Person other) : this() {
  69. name_ = other.name_;
  70. id_ = other.id_;
  71. email_ = other.email_;
  72. phone_ = other.phone_.Clone();
  73. }
  74. public Person Clone() {
  75. return new Person(this);
  76. }
  77. public void Freeze() {
  78. if (IsFrozen) {
  79. return;
  80. }
  81. _frozen = true;
  82. phone_.Freeze();
  83. }
  84. public const int NameFieldNumber = 1;
  85. private string name_ = "";
  86. public string Name {
  87. get { return name_; }
  88. set {
  89. pb::Freezable.CheckMutable(this);
  90. name_ = value ?? "";
  91. }
  92. }
  93. public const int IdFieldNumber = 2;
  94. private int id_;
  95. public int Id {
  96. get { return id_; }
  97. set {
  98. pb::Freezable.CheckMutable(this);
  99. id_ = value;
  100. }
  101. }
  102. public const int EmailFieldNumber = 3;
  103. private string email_ = "";
  104. public string Email {
  105. get { return email_; }
  106. set {
  107. pb::Freezable.CheckMutable(this);
  108. email_ = value ?? "";
  109. }
  110. }
  111. public const int PhoneFieldNumber = 4;
  112. private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> _repeated_phone_codec
  113. = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser);
  114. private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> phone_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber>();
  115. public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> Phone {
  116. get { return phone_; }
  117. }
  118. public override bool Equals(object other) {
  119. return Equals(other as Person);
  120. }
  121. public bool Equals(Person other) {
  122. if (ReferenceEquals(other, null)) {
  123. return false;
  124. }
  125. if (ReferenceEquals(other, this)) {
  126. return true;
  127. }
  128. if (Name != other.Name) return false;
  129. if (Id != other.Id) return false;
  130. if (Email != other.Email) return false;
  131. if(!phone_.Equals(other.phone_)) return false;
  132. return true;
  133. }
  134. public override int GetHashCode() {
  135. int hash = 1;
  136. if (Name.Length != 0) hash ^= Name.GetHashCode();
  137. if (Id != 0) hash ^= Id.GetHashCode();
  138. if (Email.Length != 0) hash ^= Email.GetHashCode();
  139. hash ^= phone_.GetHashCode();
  140. return hash;
  141. }
  142. public override string ToString() {
  143. return pb::JsonFormatter.Default.Format(this);
  144. }
  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. phone_.WriteTo(output, _repeated_phone_codec);
  159. }
  160. public int CalculateSize() {
  161. int size = 0;
  162. if (Name.Length != 0) {
  163. size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
  164. }
  165. if (Id != 0) {
  166. size += 1 + pb::CodedOutputStream.ComputeInt32Size(Id);
  167. }
  168. if (Email.Length != 0) {
  169. size += 1 + pb::CodedOutputStream.ComputeStringSize(Email);
  170. }
  171. size += phone_.CalculateSize(_repeated_phone_codec);
  172. return size;
  173. }
  174. public void MergeFrom(Person other) {
  175. if (other == null) {
  176. return;
  177. }
  178. if (other.Name.Length != 0) {
  179. Name = other.Name;
  180. }
  181. if (other.Id != 0) {
  182. Id = other.Id;
  183. }
  184. if (other.Email.Length != 0) {
  185. Email = other.Email;
  186. }
  187. phone_.Add(other.phone_);
  188. }
  189. public void MergeFrom(pb::CodedInputStream input) {
  190. uint tag;
  191. while (input.ReadTag(out tag)) {
  192. switch(tag) {
  193. case 0:
  194. throw pb::InvalidProtocolBufferException.InvalidTag();
  195. default:
  196. if (pb::WireFormat.IsEndGroupTag(tag)) {
  197. return;
  198. }
  199. break;
  200. case 10: {
  201. Name = input.ReadString();
  202. break;
  203. }
  204. case 16: {
  205. Id = input.ReadInt32();
  206. break;
  207. }
  208. case 26: {
  209. Email = input.ReadString();
  210. break;
  211. }
  212. case 34: {
  213. phone_.AddEntriesFrom(input, _repeated_phone_codec);
  214. break;
  215. }
  216. }
  217. }
  218. }
  219. #region Nested types
  220. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  221. public static partial class Types {
  222. public enum PhoneType {
  223. MOBILE = 0,
  224. HOME = 1,
  225. WORK = 2,
  226. }
  227. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  228. public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> {
  229. private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber());
  230. public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } }
  231. private static readonly string[] _fieldNames = new string[] { "number", "type" };
  232. private static readonly uint[] _fieldTags = new uint[] { 10, 16 };
  233. public static pbr::MessageDescriptor Descriptor {
  234. get { return global::Google.Protobuf.Examples.AddressBook.Person.Descriptor.NestedTypes[0]; }
  235. }
  236. pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
  237. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; }
  238. }
  239. private bool _frozen = false;
  240. public bool IsFrozen { get { return _frozen; } }
  241. public PhoneNumber() {
  242. OnConstruction();
  243. }
  244. partial void OnConstruction();
  245. public PhoneNumber(PhoneNumber other) : this() {
  246. number_ = other.number_;
  247. type_ = other.type_;
  248. }
  249. public PhoneNumber Clone() {
  250. return new PhoneNumber(this);
  251. }
  252. public void Freeze() {
  253. if (IsFrozen) {
  254. return;
  255. }
  256. _frozen = true;
  257. }
  258. public const int NumberFieldNumber = 1;
  259. private string number_ = "";
  260. public string Number {
  261. get { return number_; }
  262. set {
  263. pb::Freezable.CheckMutable(this);
  264. number_ = value ?? "";
  265. }
  266. }
  267. public const int TypeFieldNumber = 2;
  268. private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE;
  269. public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type {
  270. get { return type_; }
  271. set {
  272. pb::Freezable.CheckMutable(this);
  273. type_ = value;
  274. }
  275. }
  276. public override bool Equals(object other) {
  277. return Equals(other as PhoneNumber);
  278. }
  279. public bool Equals(PhoneNumber other) {
  280. if (ReferenceEquals(other, null)) {
  281. return false;
  282. }
  283. if (ReferenceEquals(other, this)) {
  284. return true;
  285. }
  286. if (Number != other.Number) return false;
  287. if (Type != other.Type) return false;
  288. return true;
  289. }
  290. public override int GetHashCode() {
  291. int hash = 1;
  292. if (Number.Length != 0) hash ^= Number.GetHashCode();
  293. if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) hash ^= Type.GetHashCode();
  294. return hash;
  295. }
  296. public override string ToString() {
  297. return pb::JsonFormatter.Default.Format(this);
  298. }
  299. public void WriteTo(pb::CodedOutputStream output) {
  300. if (Number.Length != 0) {
  301. output.WriteRawTag(10);
  302. output.WriteString(Number);
  303. }
  304. if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
  305. output.WriteRawTag(16);
  306. output.WriteEnum((int) Type);
  307. }
  308. }
  309. public int CalculateSize() {
  310. int size = 0;
  311. if (Number.Length != 0) {
  312. size += 1 + pb::CodedOutputStream.ComputeStringSize(Number);
  313. }
  314. if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
  315. size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
  316. }
  317. return size;
  318. }
  319. public void MergeFrom(PhoneNumber other) {
  320. if (other == null) {
  321. return;
  322. }
  323. if (other.Number.Length != 0) {
  324. Number = other.Number;
  325. }
  326. if (other.Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
  327. Type = other.Type;
  328. }
  329. }
  330. public void MergeFrom(pb::CodedInputStream input) {
  331. uint tag;
  332. while (input.ReadTag(out tag)) {
  333. switch(tag) {
  334. case 0:
  335. throw pb::InvalidProtocolBufferException.InvalidTag();
  336. default:
  337. if (pb::WireFormat.IsEndGroupTag(tag)) {
  338. return;
  339. }
  340. break;
  341. case 10: {
  342. Number = input.ReadString();
  343. break;
  344. }
  345. case 16: {
  346. type_ = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum();
  347. break;
  348. }
  349. }
  350. }
  351. }
  352. }
  353. }
  354. #endregion
  355. }
  356. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  357. public sealed partial class AddressBook : pb::IMessage<AddressBook> {
  358. private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
  359. public static pb::MessageParser<AddressBook> Parser { get { return _parser; } }
  360. private static readonly string[] _fieldNames = new string[] { "person" };
  361. private static readonly uint[] _fieldTags = new uint[] { 10 };
  362. public static pbr::MessageDescriptor Descriptor {
  363. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.Descriptor.MessageTypes[1]; }
  364. }
  365. pbr::FieldAccessorTable pb::IReflectedMessage.Fields {
  366. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; }
  367. }
  368. private bool _frozen = false;
  369. public bool IsFrozen { get { return _frozen; } }
  370. public AddressBook() {
  371. OnConstruction();
  372. }
  373. partial void OnConstruction();
  374. public AddressBook(AddressBook other) : this() {
  375. person_ = other.person_.Clone();
  376. }
  377. public AddressBook Clone() {
  378. return new AddressBook(this);
  379. }
  380. public void Freeze() {
  381. if (IsFrozen) {
  382. return;
  383. }
  384. _frozen = true;
  385. person_.Freeze();
  386. }
  387. public const int PersonFieldNumber = 1;
  388. private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person> _repeated_person_codec
  389. = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser);
  390. private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> person_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person>();
  391. public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> Person {
  392. get { return person_; }
  393. }
  394. public override bool Equals(object other) {
  395. return Equals(other as AddressBook);
  396. }
  397. public bool Equals(AddressBook other) {
  398. if (ReferenceEquals(other, null)) {
  399. return false;
  400. }
  401. if (ReferenceEquals(other, this)) {
  402. return true;
  403. }
  404. if(!person_.Equals(other.person_)) return false;
  405. return true;
  406. }
  407. public override int GetHashCode() {
  408. int hash = 1;
  409. hash ^= person_.GetHashCode();
  410. return hash;
  411. }
  412. public override string ToString() {
  413. return pb::JsonFormatter.Default.Format(this);
  414. }
  415. public void WriteTo(pb::CodedOutputStream output) {
  416. person_.WriteTo(output, _repeated_person_codec);
  417. }
  418. public int CalculateSize() {
  419. int size = 0;
  420. size += person_.CalculateSize(_repeated_person_codec);
  421. return size;
  422. }
  423. public void MergeFrom(AddressBook other) {
  424. if (other == null) {
  425. return;
  426. }
  427. person_.Add(other.person_);
  428. }
  429. public void MergeFrom(pb::CodedInputStream input) {
  430. uint tag;
  431. while (input.ReadTag(out tag)) {
  432. switch(tag) {
  433. case 0:
  434. throw pb::InvalidProtocolBufferException.InvalidTag();
  435. default:
  436. if (pb::WireFormat.IsEndGroupTag(tag)) {
  437. return;
  438. }
  439. break;
  440. case 10: {
  441. person_.AddEntriesFrom(input, _repeated_person_codec);
  442. break;
  443. }
  444. }
  445. }
  446. }
  447. }
  448. #endregion
  449. }
  450. #endregion Designer generated code