Addressbook.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508
  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 pbd = global::Google.Protobuf.Descriptors;
  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 pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person__FieldAccessorTable;
  14. internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable;
  15. internal static pb::FieldAccess.FieldAccessorTable internal__static_tutorial_AddressBook__FieldAccessorTable;
  16. #endregion
  17. #region Descriptor
  18. public static pbd::FileDescriptor Descriptor {
  19. get { return descriptor; }
  20. }
  21. private static pbd::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 = pbd::FileDescriptor.InternalBuildGeneratedFileFrom(descriptorData,
  35. new pbd::FileDescriptor[] {
  36. });
  37. internal__static_tutorial_Person__FieldAccessorTable =
  38. new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person), descriptor.MessageTypes[0],
  39. new string[] { "Name", "Id", "Email", "Phone", });
  40. internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable =
  41. new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber), descriptor.MessageTypes[0].NestedTypes[0],
  42. new string[] { "Number", "Type", });
  43. internal__static_tutorial_AddressBook__FieldAccessorTable =
  44. new pb::FieldAccess.FieldAccessorTable(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), descriptor.MessageTypes[1],
  45. new string[] { "Person", });
  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 pbd::MessageDescriptor Descriptor {
  57. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.Descriptor.MessageTypes[0]; }
  58. }
  59. public pb::FieldAccess.FieldAccessorTable 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 void WriteTo(pb::CodedOutputStream output) {
  143. if (Name.Length != 0) {
  144. output.WriteRawTag(10);
  145. output.WriteString(Name);
  146. }
  147. if (Id != 0) {
  148. output.WriteRawTag(16);
  149. output.WriteInt32(Id);
  150. }
  151. if (Email.Length != 0) {
  152. output.WriteRawTag(26);
  153. output.WriteString(Email);
  154. }
  155. phone_.WriteTo(output, _repeated_phone_codec);
  156. }
  157. public int CalculateSize() {
  158. int size = 0;
  159. if (Name.Length != 0) {
  160. size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
  161. }
  162. if (Id != 0) {
  163. size += 1 + pb::CodedOutputStream.ComputeInt32Size(Id);
  164. }
  165. if (Email.Length != 0) {
  166. size += 1 + pb::CodedOutputStream.ComputeStringSize(Email);
  167. }
  168. size += phone_.CalculateSize(_repeated_phone_codec);
  169. return size;
  170. }
  171. public void MergeFrom(Person other) {
  172. if (other == null) {
  173. return;
  174. }
  175. if (other.Name.Length != 0) {
  176. Name = other.Name;
  177. }
  178. if (other.Id != 0) {
  179. Id = other.Id;
  180. }
  181. if (other.Email.Length != 0) {
  182. Email = other.Email;
  183. }
  184. phone_.Add(other.phone_);
  185. }
  186. public void MergeFrom(pb::CodedInputStream input) {
  187. uint tag;
  188. while (input.ReadTag(out tag)) {
  189. switch(tag) {
  190. case 0:
  191. throw pb::InvalidProtocolBufferException.InvalidTag();
  192. default:
  193. if (pb::WireFormat.IsEndGroupTag(tag)) {
  194. return;
  195. }
  196. break;
  197. case 10: {
  198. Name = input.ReadString();
  199. break;
  200. }
  201. case 16: {
  202. Id = input.ReadInt32();
  203. break;
  204. }
  205. case 26: {
  206. Email = input.ReadString();
  207. break;
  208. }
  209. case 34: {
  210. phone_.AddEntriesFrom(input, _repeated_phone_codec);
  211. break;
  212. }
  213. }
  214. }
  215. }
  216. #region Nested types
  217. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  218. public static partial class Types {
  219. public enum PhoneType {
  220. MOBILE = 0,
  221. HOME = 1,
  222. WORK = 2,
  223. }
  224. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  225. public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> {
  226. private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber());
  227. public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } }
  228. private static readonly string[] _fieldNames = new string[] { "number", "type" };
  229. private static readonly uint[] _fieldTags = new uint[] { 10, 16 };
  230. public static pbd::MessageDescriptor Descriptor {
  231. get { return global::Google.Protobuf.Examples.AddressBook.Person.Descriptor.NestedTypes[0]; }
  232. }
  233. public pb::FieldAccess.FieldAccessorTable Fields {
  234. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_Person_PhoneNumber__FieldAccessorTable; }
  235. }
  236. private bool _frozen = false;
  237. public bool IsFrozen { get { return _frozen; } }
  238. public PhoneNumber() {
  239. OnConstruction();
  240. }
  241. partial void OnConstruction();
  242. public PhoneNumber(PhoneNumber other) : this() {
  243. number_ = other.number_;
  244. type_ = other.type_;
  245. }
  246. public PhoneNumber Clone() {
  247. return new PhoneNumber(this);
  248. }
  249. public void Freeze() {
  250. if (IsFrozen) {
  251. return;
  252. }
  253. _frozen = true;
  254. }
  255. public const int NumberFieldNumber = 1;
  256. private string number_ = "";
  257. public string Number {
  258. get { return number_; }
  259. set {
  260. pb::Freezable.CheckMutable(this);
  261. number_ = value ?? "";
  262. }
  263. }
  264. public const int TypeFieldNumber = 2;
  265. private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE;
  266. public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type {
  267. get { return type_; }
  268. set {
  269. pb::Freezable.CheckMutable(this);
  270. type_ = value;
  271. }
  272. }
  273. public override bool Equals(object other) {
  274. return Equals(other as PhoneNumber);
  275. }
  276. public bool Equals(PhoneNumber other) {
  277. if (ReferenceEquals(other, null)) {
  278. return false;
  279. }
  280. if (ReferenceEquals(other, this)) {
  281. return true;
  282. }
  283. if (Number != other.Number) return false;
  284. if (Type != other.Type) return false;
  285. return true;
  286. }
  287. public override int GetHashCode() {
  288. int hash = 1;
  289. if (Number.Length != 0) hash ^= Number.GetHashCode();
  290. if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) hash ^= Type.GetHashCode();
  291. return hash;
  292. }
  293. public void WriteTo(pb::CodedOutputStream output) {
  294. if (Number.Length != 0) {
  295. output.WriteRawTag(10);
  296. output.WriteString(Number);
  297. }
  298. if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
  299. output.WriteRawTag(16);
  300. output.WriteEnum((int) Type);
  301. }
  302. }
  303. public int CalculateSize() {
  304. int size = 0;
  305. if (Number.Length != 0) {
  306. size += 1 + pb::CodedOutputStream.ComputeStringSize(Number);
  307. }
  308. if (Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
  309. size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
  310. }
  311. return size;
  312. }
  313. public void MergeFrom(PhoneNumber other) {
  314. if (other == null) {
  315. return;
  316. }
  317. if (other.Number.Length != 0) {
  318. Number = other.Number;
  319. }
  320. if (other.Type != global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType.MOBILE) {
  321. Type = other.Type;
  322. }
  323. }
  324. public void MergeFrom(pb::CodedInputStream input) {
  325. uint tag;
  326. while (input.ReadTag(out tag)) {
  327. switch(tag) {
  328. case 0:
  329. throw pb::InvalidProtocolBufferException.InvalidTag();
  330. default:
  331. if (pb::WireFormat.IsEndGroupTag(tag)) {
  332. return;
  333. }
  334. break;
  335. case 10: {
  336. Number = input.ReadString();
  337. break;
  338. }
  339. case 16: {
  340. type_ = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum();
  341. break;
  342. }
  343. }
  344. }
  345. }
  346. }
  347. }
  348. #endregion
  349. }
  350. [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
  351. public sealed partial class AddressBook : pb::IMessage<AddressBook> {
  352. private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
  353. public static pb::MessageParser<AddressBook> Parser { get { return _parser; } }
  354. private static readonly string[] _fieldNames = new string[] { "person" };
  355. private static readonly uint[] _fieldTags = new uint[] { 10 };
  356. public static pbd::MessageDescriptor Descriptor {
  357. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.Descriptor.MessageTypes[1]; }
  358. }
  359. public pb::FieldAccess.FieldAccessorTable Fields {
  360. get { return global::Google.Protobuf.Examples.AddressBook.Addressbook.internal__static_tutorial_AddressBook__FieldAccessorTable; }
  361. }
  362. private bool _frozen = false;
  363. public bool IsFrozen { get { return _frozen; } }
  364. public AddressBook() {
  365. OnConstruction();
  366. }
  367. partial void OnConstruction();
  368. public AddressBook(AddressBook other) : this() {
  369. person_ = other.person_.Clone();
  370. }
  371. public AddressBook Clone() {
  372. return new AddressBook(this);
  373. }
  374. public void Freeze() {
  375. if (IsFrozen) {
  376. return;
  377. }
  378. _frozen = true;
  379. person_.Freeze();
  380. }
  381. public const int PersonFieldNumber = 1;
  382. private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person> _repeated_person_codec
  383. = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser);
  384. private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> person_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person>();
  385. public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> Person {
  386. get { return person_; }
  387. }
  388. public override bool Equals(object other) {
  389. return Equals(other as AddressBook);
  390. }
  391. public bool Equals(AddressBook other) {
  392. if (ReferenceEquals(other, null)) {
  393. return false;
  394. }
  395. if (ReferenceEquals(other, this)) {
  396. return true;
  397. }
  398. if(!person_.Equals(other.person_)) return false;
  399. return true;
  400. }
  401. public override int GetHashCode() {
  402. int hash = 1;
  403. hash ^= person_.GetHashCode();
  404. return hash;
  405. }
  406. public void WriteTo(pb::CodedOutputStream output) {
  407. person_.WriteTo(output, _repeated_person_codec);
  408. }
  409. public int CalculateSize() {
  410. int size = 0;
  411. size += person_.CalculateSize(_repeated_person_codec);
  412. return size;
  413. }
  414. public void MergeFrom(AddressBook other) {
  415. if (other == null) {
  416. return;
  417. }
  418. person_.Add(other.person_);
  419. }
  420. public void MergeFrom(pb::CodedInputStream input) {
  421. uint tag;
  422. while (input.ReadTag(out tag)) {
  423. switch(tag) {
  424. case 0:
  425. throw pb::InvalidProtocolBufferException.InvalidTag();
  426. default:
  427. if (pb::WireFormat.IsEndGroupTag(tag)) {
  428. return;
  429. }
  430. break;
  431. case 10: {
  432. person_.AddEntriesFrom(input, _repeated_person_codec);
  433. break;
  434. }
  435. }
  436. }
  437. }
  438. }
  439. #endregion
  440. }
  441. #endregion Designer generated code