private static HashSet <T> GetPropertyAsHashSet <T>(PropertyBagAdaptor propertyBag, StorePropertyDefinition property, HashSet <T> defaultValue) { T[] valueOrDefault = propertyBag.GetValueOrDefault <T[]>(property, null); if (valueOrDefault == null || valueOrDefault.Length == 0) { return(defaultValue); } return(new HashSet <T>(valueOrDefault)); }
protected ContactInfoForLinking(PropertyBagAdaptor propertyBag) : this(propertyBag.GetValueOrDefault <bool>(ContactSchema.Linked, false), propertyBag.GetValueOrDefault <PersonId>(ContactSchema.PersonId, null), ContactInfoForLinking.GetPropertyAsHashSet <PersonId>(propertyBag, ContactSchema.LinkRejectHistory, new HashSet <PersonId>()), propertyBag.GetValueOrDefault <Guid?>(ContactSchema.GALLinkID, null), propertyBag.GetValueOrDefault <byte[]>(ContactSchema.AddressBookEntryId, null), propertyBag.GetValueOrDefault <GALLinkState>(ContactSchema.GALLinkState, GALLinkState.NotLinked), propertyBag.GetValueOrDefault <string[]>(ContactSchema.SmtpAddressCache, Array <string> .Empty), propertyBag.GetValueOrDefault <bool>(ContactSchema.UserApprovedLink, false)) { this.ItemId = propertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null); this.EmailAddresses = ContactInfoForLinking.GetEmailAddresses(propertyBag); this.GivenName = propertyBag.GetValueOrDefault <string>(ContactSchema.GivenName, string.Empty); this.Surname = propertyBag.GetValueOrDefault <string>(ContactSchema.Surname, string.Empty); this.DisplayName = propertyBag.GetValueOrDefault <string>(StoreObjectSchema.DisplayName, string.Empty); this.PartnerNetworkId = propertyBag.GetValueOrDefault <string>(ContactSchema.PartnerNetworkId, string.Empty); this.PartnerNetworkUserId = propertyBag.GetValueOrDefault <string>(ContactSchema.PartnerNetworkUserId, string.Empty); this.IMAddress = ContactInfoForLinking.CanonicalizeEmailAddress(propertyBag.GetValueOrDefault <string>(ContactSchema.IMAddress, string.Empty)); this.IsDL = ObjectClass.IsOfClass(propertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty), "IPM.DistList"); }
private static HashSet <string> GetEmailAddresses(PropertyBagAdaptor propertyBag) { HashSet <string> hashSet = new HashSet <string>(); foreach (StorePropertyDefinition propertyDefinition in ContactSchema.EmailAddressProperties) { string text = ContactInfoForLinking.CanonicalizeEmailAddress(propertyBag.GetValueOrDefault <string>(propertyDefinition, string.Empty)); if (!string.IsNullOrEmpty(text)) { hashSet.Add(text); } } return(hashSet); }