// Not static. Relies on associated Manager private Person _CreatePerson(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.PersonCollection + PropertyNames.PersonArrayNode, StringComparison.Ordinal)); string name = contact.GetStringProperty(arrayNode + PropertyNames.FormattedName); string id = contact.GetStringProperty(arrayNode + PropertyNames.PersonId); return new Person(name, id, _manager); }
private static Position _CreatePosition(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.PositionCollection + PropertyNames.PositionArrayNode, StringComparison.Ordinal)); string company = contact.GetStringProperty(arrayNode + PropertyNames.Company); string department = contact.GetStringProperty(arrayNode + PropertyNames.Department); string jobTitle = contact.GetStringProperty(arrayNode + PropertyNames.JobTitle); string office = contact.GetStringProperty(arrayNode + PropertyNames.Office); string organization = contact.GetStringProperty(arrayNode + PropertyNames.Organization); string profession = contact.GetStringProperty(arrayNode + PropertyNames.Profession); string role = contact.GetStringProperty(arrayNode + PropertyNames.Role); return new Position(organization, role, company, department, office, jobTitle, profession); }
// This is stricter than the contract provided by the COM Contact APIs. // It requires that the string in the contact is really a valid URI. If it's not then // this will return a dummy http: string. private static Uri _CreateUrl(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.UrlCollection + PropertyNames.UrlArrayNode, StringComparison.Ordinal)); string value = contact.GetStringProperty(arrayNode + PropertyNames.Value); if (string.IsNullOrEmpty(value)) { return null; } Uri url; if (Uri.TryCreate(value, UriKind.RelativeOrAbsolute, out url)) { return url; } return new Uri(_stockInvalidUrl); }
private static PhoneNumber _CreateNumber(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.PhoneNumberCollection + PropertyNames.PhoneNumberArrayNode, StringComparison.Ordinal)); string number = contact.GetStringProperty(arrayNode + PropertyNames.Number); string alternate = contact.GetStringProperty(arrayNode + PropertyNames.Alternate); return new PhoneNumber(number, alternate); }
private static Photo _CreatePhoto(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.PhotoCollection + PropertyNames.PhotoArrayNode, StringComparison.Ordinal)); Uri url = null; string urlString = contact.GetStringProperty(arrayNode + PropertyNames.Url); if (!string.IsNullOrEmpty(urlString)) { if (!Uri.TryCreate(urlString, UriKind.RelativeOrAbsolute, out url)) { url = new Uri(_stockInvalidUrl); } } var photoType = new StringBuilder(); Stream photoStream = contact.GetBinaryProperty(arrayNode + PropertyNames.Value, photoType); return new Photo(photoStream, null == photoStream ? null : photoType.ToString(), url); }
private static Name _CreateName(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.NameCollection + PropertyNames.NameArrayNode, StringComparison.Ordinal)); string familyName = contact.GetStringProperty(arrayNode + PropertyNames.FamilyName); string formattedName = contact.GetStringProperty(arrayNode + PropertyNames.FormattedName); string generation = contact.GetStringProperty(arrayNode + PropertyNames.Generation); string givenName = contact.GetStringProperty(arrayNode + PropertyNames.GivenName); string middleName = contact.GetStringProperty(arrayNode + PropertyNames.MiddleName); string nickName = contact.GetStringProperty(arrayNode + PropertyNames.Nickname); string title = contact.GetStringProperty(arrayNode + PropertyNames.Title); string phonetic = contact.GetStringProperty(arrayNode + PropertyNames.Phonetic); string prefix = contact.GetStringProperty(arrayNode + PropertyNames.Prefix); string suffix = contact.GetStringProperty(arrayNode + PropertyNames.Suffix); return new Name(formattedName, phonetic, prefix, title, givenName, middleName, familyName, generation, suffix, nickName); }
private static IMAddress _CreateIM(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.IMAddressCollection + PropertyNames.IMAddressArrayNode, StringComparison.Ordinal)); string handle = contact.GetStringProperty(arrayNode + PropertyNames.Value); string protocol = contact.GetStringProperty(arrayNode + PropertyNames.Protocol); return new IMAddress(handle, protocol); }
private static EmailAddress _CreateEmail(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.EmailAddressCollection + PropertyNames.EmailAddressArrayNode, StringComparison.Ordinal)); string address = contact.GetStringProperty(arrayNode + PropertyNames.Address); string type = contact.GetStringProperty(arrayNode + PropertyNames.AddressType); return new EmailAddress(address, type); }
private static Guid? _CreateContactId(Contact contact, string arrayNode) { Guid? id = null; Assert.IsTrue(arrayNode.StartsWith(PropertyNames.ContactIdCollection + PropertyNames.ContactIdArrayNode, StringComparison.Ordinal)); string value = contact.GetStringProperty(arrayNode + PropertyNames.Value); if (!string.IsNullOrEmpty(value)) { id = new Guid(value); } return id; }
private static PhysicalAddress _CreateAddress(Contact contact, string arrayNode) { Assert.IsTrue(arrayNode.StartsWith(PropertyNames.PhysicalAddressCollection + PropertyNames.PhysicalAddressArrayNode, StringComparison.Ordinal)); string label = contact.GetStringProperty(arrayNode + PropertyNames.AddressLabel); string city = contact.GetStringProperty(arrayNode + PropertyNames.Locality); string country = contact.GetStringProperty(arrayNode + PropertyNames.Country); string extended = contact.GetStringProperty(arrayNode + PropertyNames.ExtendedAddress); string pobox = contact.GetStringProperty(arrayNode + PropertyNames.POBox); string state = contact.GetStringProperty(arrayNode + PropertyNames.Region); string street = contact.GetStringProperty(arrayNode + PropertyNames.Street); string zip = contact.GetStringProperty(arrayNode + PropertyNames.PostalCode); return new PhysicalAddress(pobox, street, city, state, zip, country, extended, label); }