Addressbook.cs 17.8 KB
Newer Older
1 2 3 4 5
// Generated by the protocol buffer compiler.  DO NOT EDIT!
// source: addressbook.proto
#pragma warning disable 1591, 0612, 3021
#region Designer generated code

6 7
using pb = global::Google.Protobuf;
using pbc = global::Google.Protobuf.Collections;
8
using pbr = global::Google.Protobuf.Reflection;
9
using scg = global::System.Collections.Generic;
10
namespace Google.Protobuf.Examples.AddressBook {
11

12
  /// <summary>Holder for reflection information generated from addressbook.proto</summary>
13
  public static partial class AddressbookReflection {
14 15

    #region Descriptor
16
    /// <summary>File descriptor for addressbook.proto</summary>
17
    public static pbr::FileDescriptor Descriptor {
18 19
      get { return descriptor; }
    }
20
    private static pbr::FileDescriptor descriptor;
21

22
    static AddressbookReflection() {
23 24
      byte[] descriptorData = global::System.Convert.FromBase64String(
          string.Concat(
25 26 27 28 29 30 31 32
            "ChFhZGRyZXNzYm9vay5wcm90bxIIdHV0b3JpYWwi1QEKBlBlcnNvbhIMCgRu",
            "YW1lGAEgASgJEgoKAmlkGAIgASgFEg0KBWVtYWlsGAMgASgJEiwKBnBob25l",
            "cxgEIAMoCzIcLnR1dG9yaWFsLlBlcnNvbi5QaG9uZU51bWJlchpHCgtQaG9u",
            "ZU51bWJlchIOCgZudW1iZXIYASABKAkSKAoEdHlwZRgCIAEoDjIaLnR1dG9y",
            "aWFsLlBlcnNvbi5QaG9uZVR5cGUiKwoJUGhvbmVUeXBlEgoKBk1PQklMRRAA",
            "EggKBEhPTUUQARIICgRXT1JLEAIiLwoLQWRkcmVzc0Jvb2sSIAoGcGVvcGxl",
            "GAEgAygLMhAudHV0b3JpYWwuUGVyc29uQlAKFGNvbS5leGFtcGxlLnR1dG9y",
            "aWFsQhFBZGRyZXNzQm9va1Byb3Rvc6oCJEdvb2dsZS5Qcm90b2J1Zi5FeGFt",
33
            "cGxlcy5BZGRyZXNzQm9va2IGcHJvdG8z"));
34
      descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
35
          new pbr::FileDescriptor[] { },
36 37 38
          new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {
            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)}),
            new pbr::GeneratedClrTypeInfo(typeof(global::Google.Protobuf.Examples.AddressBook.AddressBook), global::Google.Protobuf.Examples.AddressBook.AddressBook.Parser, new[]{ "People" }, null, null, null)
39
          }));
40 41 42 43 44
    }
    #endregion

  }
  #region Messages
45
  /// <summary>
46
  /// [START messages]
47
  /// </summary>
48
  public sealed partial class Person : pb::IMessage<Person> {
49
    private static readonly pb::MessageParser<Person> _parser = new pb::MessageParser<Person>(() => new Person());
50
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
51
    public static pb::MessageParser<Person> Parser { get { return _parser; } }
52

53
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
54
    public static pbr::MessageDescriptor Descriptor {
55
      get { return global::Google.Protobuf.Examples.AddressBook.AddressbookReflection.Descriptor.MessageTypes[0]; }
56 57
    }

58
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
59 60
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
61 62
    }

63
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
64 65 66 67 68
    public Person() {
      OnConstruction();
    }

    partial void OnConstruction();
Jon Skeet's avatar
Jon Skeet committed
69

70
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
71
    public Person(Person other) : this() {
Jon Skeet's avatar
Jon Skeet committed
72 73 74
      name_ = other.name_;
      id_ = other.id_;
      email_ = other.email_;
75
      phones_ = other.phones_.Clone();
Jon Skeet's avatar
Jon Skeet committed
76 77
    }

78
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
Jon Skeet's avatar
Jon Skeet committed
79 80
    public Person Clone() {
      return new Person(this);
81
    }
Jon Skeet's avatar
Jon Skeet committed
82

83
    /// <summary>Field number for the "name" field.</summary>
84 85
    public const int NameFieldNumber = 1;
    private string name_ = "";
86
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
87 88
    public string Name {
      get { return name_; }
89
      set {
90
        name_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
91
      }
92 93
    }

94
    /// <summary>Field number for the "id" field.</summary>
95 96
    public const int IdFieldNumber = 2;
    private int id_;
97
    /// <summary>
98
    /// Unique ID number for this person.
99
    /// </summary>
100
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
101 102
    public int Id {
      get { return id_; }
103 104 105
      set {
        id_ = value;
      }
106 107
    }

108
    /// <summary>Field number for the "email" field.</summary>
109 110
    public const int EmailFieldNumber = 3;
    private string email_ = "";
111
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
112 113
    public string Email {
      get { return email_; }
114
      set {
115
        email_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
116
      }
117 118
    }

119
    /// <summary>Field number for the "phones" field.</summary>
120 121
    public const int PhonesFieldNumber = 4;
    private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> _repeated_phones_codec
122
        = pb::FieldCodec.ForMessage(34, global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber.Parser);
123
    private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> phones_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber>();
124
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
125 126
    public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneNumber> Phones {
      get { return phones_; }
127
    }
128

129
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
130 131
    public override bool Equals(object other) {
      return Equals(other as Person);
132 133
    }

134
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
135 136 137 138 139
    public bool Equals(Person other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
140 141
        return true;
      }
142 143 144
      if (Name != other.Name) return false;
      if (Id != other.Id) return false;
      if (Email != other.Email) return false;
145
      if(!phones_.Equals(other.phones_)) return false;
146
      return true;
147 148
    }

149
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
150
    public override int GetHashCode() {
151
      int hash = 1;
Jon Skeet's avatar
Jon Skeet committed
152
      if (Name.Length != 0) hash ^= Name.GetHashCode();
153
      if (Id != 0) hash ^= Id.GetHashCode();
Jon Skeet's avatar
Jon Skeet committed
154
      if (Email.Length != 0) hash ^= Email.GetHashCode();
155
      hash ^= phones_.GetHashCode();
156
      return hash;
157 158
    }

159
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
160
    public override string ToString() {
161
      return pb::JsonFormatter.ToDiagnosticString(this);
162 163
    }

164
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
165
    public void WriteTo(pb::CodedOutputStream output) {
Jon Skeet's avatar
Jon Skeet committed
166
      if (Name.Length != 0) {
167 168
        output.WriteRawTag(10);
        output.WriteString(Name);
169 170
      }
      if (Id != 0) {
171 172
        output.WriteRawTag(16);
        output.WriteInt32(Id);
173
      }
Jon Skeet's avatar
Jon Skeet committed
174
      if (Email.Length != 0) {
175 176
        output.WriteRawTag(26);
        output.WriteString(Email);
177
      }
178
      phones_.WriteTo(output, _repeated_phones_codec);
179 180
    }

181
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
182 183
    public int CalculateSize() {
      int size = 0;
Jon Skeet's avatar
Jon Skeet committed
184
      if (Name.Length != 0) {
185
        size += 1 + pb::CodedOutputStream.ComputeStringSize(Name);
186
      }
187
      if (Id != 0) {
188
        size += 1 + pb::CodedOutputStream.ComputeInt32Size(Id);
189
      }
Jon Skeet's avatar
Jon Skeet committed
190
      if (Email.Length != 0) {
191
        size += 1 + pb::CodedOutputStream.ComputeStringSize(Email);
192
      }
193
      size += phones_.CalculateSize(_repeated_phones_codec);
194 195
      return size;
    }
196

197
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
198 199 200 201
    public void MergeFrom(Person other) {
      if (other == null) {
        return;
      }
Jon Skeet's avatar
Jon Skeet committed
202
      if (other.Name.Length != 0) {
203 204 205 206 207
        Name = other.Name;
      }
      if (other.Id != 0) {
        Id = other.Id;
      }
Jon Skeet's avatar
Jon Skeet committed
208
      if (other.Email.Length != 0) {
209 210
        Email = other.Email;
      }
211
      phones_.Add(other.phones_);
212 213
    }

214
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
215 216
    public void MergeFrom(pb::CodedInputStream input) {
      uint tag;
217
      while ((tag = input.ReadTag()) != 0) {
218 219
        switch(tag) {
          default:
220
            input.SkipLastField();
221 222
            break;
          case 10: {
Jon Skeet's avatar
Jon Skeet committed
223
            Name = input.ReadString();
224 225 226
            break;
          }
          case 16: {
Jon Skeet's avatar
Jon Skeet committed
227
            Id = input.ReadInt32();
228 229 230
            break;
          }
          case 26: {
Jon Skeet's avatar
Jon Skeet committed
231
            Email = input.ReadString();
232 233 234
            break;
          }
          case 34: {
235
            phones_.AddEntriesFrom(input, _repeated_phones_codec);
236 237 238 239
            break;
          }
        }
      }
240 241
    }

242
    #region Nested types
243
    /// <summary>Container for nested types declared in the Person message type.</summary>
244
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
245 246
    public static partial class Types {
      public enum PhoneType {
247 248 249
        [pbr::OriginalName("MOBILE")] Mobile = 0,
        [pbr::OriginalName("HOME")] Home = 1,
        [pbr::OriginalName("WORK")] Work = 2,
250 251
      }

252
      public sealed partial class PhoneNumber : pb::IMessage<PhoneNumber> {
253
        private static readonly pb::MessageParser<PhoneNumber> _parser = new pb::MessageParser<PhoneNumber>(() => new PhoneNumber());
254
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
255
        public static pb::MessageParser<PhoneNumber> Parser { get { return _parser; } }
256

257
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
258
        public static pbr::MessageDescriptor Descriptor {
259
          get { return global::Google.Protobuf.Examples.AddressBook.Person.Descriptor.NestedTypes[0]; }
260 261
        }

262
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
263 264
        pbr::MessageDescriptor pb::IMessage.Descriptor {
          get { return Descriptor; }
265
        }
266

267
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
268 269 270 271 272
        public PhoneNumber() {
          OnConstruction();
        }

        partial void OnConstruction();
Jon Skeet's avatar
Jon Skeet committed
273

274
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
275
        public PhoneNumber(PhoneNumber other) : this() {
Jon Skeet's avatar
Jon Skeet committed
276 277 278 279
          number_ = other.number_;
          type_ = other.type_;
        }

280
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
Jon Skeet's avatar
Jon Skeet committed
281 282
        public PhoneNumber Clone() {
          return new PhoneNumber(this);
283
        }
Jon Skeet's avatar
Jon Skeet committed
284

285
        /// <summary>Field number for the "number" field.</summary>
286 287
        public const int NumberFieldNumber = 1;
        private string number_ = "";
288
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
289 290
        public string Number {
          get { return number_; }
291
          set {
292
            number_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
293
          }
294
        }
295

296
        /// <summary>Field number for the "type" field.</summary>
297
        public const int TypeFieldNumber = 2;
298
        private global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType type_ = 0;
299
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
300
        public global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType Type {
301
          get { return type_; }
302 303 304
          set {
            type_ = value;
          }
305 306
        }

307
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
308 309
        public override bool Equals(object other) {
          return Equals(other as PhoneNumber);
310 311
        }

312
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
313 314 315 316 317 318 319 320 321 322
        public bool Equals(PhoneNumber other) {
          if (ReferenceEquals(other, null)) {
            return false;
          }
          if (ReferenceEquals(other, this)) {
            return true;
          }
          if (Number != other.Number) return false;
          if (Type != other.Type) return false;
          return true;
323 324
        }

325
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
326
        public override int GetHashCode() {
327
          int hash = 1;
Jon Skeet's avatar
Jon Skeet committed
328
          if (Number.Length != 0) hash ^= Number.GetHashCode();
329
          if (Type != 0) hash ^= Type.GetHashCode();
330
          return hash;
331
        }
332

333
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
334
        public override string ToString() {
335
          return pb::JsonFormatter.ToDiagnosticString(this);
336 337
        }

338
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
339
        public void WriteTo(pb::CodedOutputStream output) {
Jon Skeet's avatar
Jon Skeet committed
340
          if (Number.Length != 0) {
341 342
            output.WriteRawTag(10);
            output.WriteString(Number);
343
          }
344
          if (Type != 0) {
345 346
            output.WriteRawTag(16);
            output.WriteEnum((int) Type);
347
          }
348
        }
349

350
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
351 352
        public int CalculateSize() {
          int size = 0;
Jon Skeet's avatar
Jon Skeet committed
353
          if (Number.Length != 0) {
354
            size += 1 + pb::CodedOutputStream.ComputeStringSize(Number);
355
          }
356
          if (Type != 0) {
357
            size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) Type);
358 359
          }
          return size;
360
        }
361

362
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
363 364 365 366
        public void MergeFrom(PhoneNumber other) {
          if (other == null) {
            return;
          }
Jon Skeet's avatar
Jon Skeet committed
367
          if (other.Number.Length != 0) {
368 369
            Number = other.Number;
          }
370
          if (other.Type != 0) {
371 372
            Type = other.Type;
          }
373 374
        }

375
        [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
376 377
        public void MergeFrom(pb::CodedInputStream input) {
          uint tag;
378
          while ((tag = input.ReadTag()) != 0) {
379 380
            switch(tag) {
              default:
381
                input.SkipLastField();
382 383
                break;
              case 10: {
Jon Skeet's avatar
Jon Skeet committed
384
                Number = input.ReadString();
385
                break;
386
              }
387
              case 16: {
388
                type_ = (global::Google.Protobuf.Examples.AddressBook.Person.Types.PhoneType) input.ReadEnum();
389
                break;
390 391 392 393 394 395 396 397
              }
            }
          }
        }

      }

    }
398 399
    #endregion

400 401
  }

402
  /// <summary>
403
  /// Our address book file is just one of these.
404
  /// </summary>
405
  public sealed partial class AddressBook : pb::IMessage<AddressBook> {
406
    private static readonly pb::MessageParser<AddressBook> _parser = new pb::MessageParser<AddressBook>(() => new AddressBook());
407
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
408
    public static pb::MessageParser<AddressBook> Parser { get { return _parser; } }
409

410
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
411
    public static pbr::MessageDescriptor Descriptor {
412
      get { return global::Google.Protobuf.Examples.AddressBook.AddressbookReflection.Descriptor.MessageTypes[1]; }
413 414
    }

415
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
416 417
    pbr::MessageDescriptor pb::IMessage.Descriptor {
      get { return Descriptor; }
418 419
    }

420
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
421 422 423 424 425
    public AddressBook() {
      OnConstruction();
    }

    partial void OnConstruction();
Jon Skeet's avatar
Jon Skeet committed
426

427
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
428
    public AddressBook(AddressBook other) : this() {
429
      people_ = other.people_.Clone();
430
    }
Jon Skeet's avatar
Jon Skeet committed
431

432
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
Jon Skeet's avatar
Jon Skeet committed
433 434 435 436
    public AddressBook Clone() {
      return new AddressBook(this);
    }

437
    /// <summary>Field number for the "people" field.</summary>
438 439
    public const int PeopleFieldNumber = 1;
    private static readonly pb::FieldCodec<global::Google.Protobuf.Examples.AddressBook.Person> _repeated_people_codec
440
        = pb::FieldCodec.ForMessage(10, global::Google.Protobuf.Examples.AddressBook.Person.Parser);
441
    private readonly pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> people_ = new pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person>();
442
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
443 444
    public pbc::RepeatedField<global::Google.Protobuf.Examples.AddressBook.Person> People {
      get { return people_; }
445
    }
446

447
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
448 449
    public override bool Equals(object other) {
      return Equals(other as AddressBook);
450 451
    }

452
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
453 454 455 456 457
    public bool Equals(AddressBook other) {
      if (ReferenceEquals(other, null)) {
        return false;
      }
      if (ReferenceEquals(other, this)) {
458 459
        return true;
      }
460
      if(!people_.Equals(other.people_)) return false;
461
      return true;
462 463
    }

464
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
465
    public override int GetHashCode() {
466
      int hash = 1;
467
      hash ^= people_.GetHashCode();
468
      return hash;
469 470
    }

471
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
472
    public override string ToString() {
473
      return pb::JsonFormatter.ToDiagnosticString(this);
474 475
    }

476
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
477
    public void WriteTo(pb::CodedOutputStream output) {
478
      people_.WriteTo(output, _repeated_people_codec);
479 480
    }

481
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
482 483
    public int CalculateSize() {
      int size = 0;
484
      size += people_.CalculateSize(_repeated_people_codec);
485 486
      return size;
    }
487

488
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
489 490 491
    public void MergeFrom(AddressBook other) {
      if (other == null) {
        return;
492
      }
493
      people_.Add(other.people_);
494
    }
495

496
    [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
497 498
    public void MergeFrom(pb::CodedInputStream input) {
      uint tag;
499
      while ((tag = input.ReadTag()) != 0) {
500 501
        switch(tag) {
          default:
502
            input.SkipLastField();
503 504
            break;
          case 10: {
505
            people_.AddEntriesFrom(input, _repeated_people_codec);
506
            break;
507 508 509 510
          }
        }
      }
    }
511

512 513 514 515 516 517 518
  }

  #endregion

}

#endregion Designer generated code