public static AddressBook Map(M.AddressBook source)
        {
            var result = new AddressBook();

            foreach (var sourcePerson in source.People)
            {
                var person = new Person()
                {
                    Email = sourcePerson.Email,
                    Id    = sourcePerson.ID,
                    Name  = sourcePerson.Name
                };

                if (sourcePerson.Phones != null)
                {
                    foreach (var sourcePhone in sourcePerson.Phones)
                    {
                        person.Phones.Add(new Person.Types.PhoneNumber()
                        {
                            Number = sourcePhone.Number,
                            Type   = (Person.Types.PhoneType)sourcePhone.Type
                        });
                    }
                }

                result.People.Add(person);
            }

            return(result);
        }
Example #2
0
        public void LoadData()
        {
            var assembly = typeof(WriteTests).GetTypeInfo().Assembly;

            var serializedData = TestsHelpers.LoadAddressBookData();

            _data       = ProtobufNet.AddressBookSerializer.Deserialize(serializedData);
            _googleData = GoogleProtobuf.AddressBookExtensions.Map(_data);
        }