AddContact() 공개 메소드

public AddContact ( Contact contact ) : void
contact Contact
리턴 void
예제 #1
0
        public void AddAndRemoveContacts()
        {
            var root = new AddressBookRoot();

            Assert.IsFalse(root.Contacts.Any());

            var contact1 = root.AddNewContact();
            Assert.IsTrue(root.Contacts.SequenceEqual(new[] { contact1 }));

            var contact2 = new Contact();
            root.AddContact(contact2);
            Assert.IsTrue(root.Contacts.SequenceEqual(new[] { contact1, contact2 }));

            root.RemoveContact(contact1);
            Assert.IsTrue(root.Contacts.SequenceEqual(new[] { contact2 }));
        }
예제 #2
0
        public void Initialize()
        {
            using (var stream = documentService.GetStream(documentPartPath, MediaTypeNames.Text.Xml, FileMode.Open))
            {
                if (stream.Length == 0)
                {
                    root = new AddressBookRoot();
                    foreach (var contact in SampleDataProvider.CreateContacts()) { root.AddContact(contact); }
                }
                else
                {
                    root = (AddressBookRoot)serializer.Value.ReadObject(stream);
                }
            }

            navigationService.AddNavigationNode("Contacts", ShowAddressBook, CloseAddressBook, 2, 1);
        }