Addressbook.cs 15 KB

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