Addressbook.cs 16 KB

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