private static MservRecord GetRecord(IPropertyBag propertyBag, MservValueFormat format, bool createIfMissing, out MServPropertyDefinition recordPropDef) { MservRecord mservRecord = (MservRecord)propertyBag[MServRecipientSchema.MservPrimaryRecord]; MservRecord mservRecord2 = (MservRecord)propertyBag[MServRecipientSchema.MservSecondaryRecord]; if (mservRecord != null && mservRecord.ValueFormat == format) { recordPropDef = MServRecipientSchema.MservPrimaryRecord; return(mservRecord); } if (mservRecord2 != null && mservRecord2.ValueFormat == format) { recordPropDef = MServRecipientSchema.MservSecondaryRecord; return(mservRecord2); } if (!createIfMissing) { recordPropDef = null; return(null); } bool flag = mservRecord == null; if (mservRecord != null && mservRecord2 != null) { throw new DataValidationException(new PropertyValidationError(DirectoryStrings.CrossRecordMismatch(mservRecord, mservRecord2), MServRecipientSchema.MservPrimaryRecord, mservRecord)); } string puidKey = MServRecipientSchema.GetPuidKey(propertyBag); byte resourceId = flag ? 0 : 7; recordPropDef = (flag ? MServRecipientSchema.MservPrimaryRecord : MServRecipientSchema.MservSecondaryRecord); byte flags = 0; if (!flag) { flags = mservRecord.Flags; } MservRecord mservRecord3 = new MservRecord(puidKey, resourceId, null, null, flags); propertyBag[recordPropDef] = mservRecord3; return(mservRecord3); }
internal static void EmailAddressesSetter(object value, IPropertyBag propertyBag) { ProxyAddressCollection proxyAddressCollection = (ProxyAddressCollection)value; if (proxyAddressCollection == null || proxyAddressCollection.WasCleared) { throw new MservOperationException(DirectoryStrings.NoResetOrAssignedMvp); } string puidKey = MServRecipientSchema.GetPuidKey(propertyBag); MultiValuedProperty <MservRecord> multiValuedProperty = (MultiValuedProperty <MservRecord>)propertyBag[MServRecipientSchema.MservEmailAddressesRecord]; foreach (ProxyAddress proxyAddress in proxyAddressCollection.Added) { bool flag = true; MservRecord mservRecord = new MservRecord(proxyAddress.AddressString, 0, null, puidKey, 0); foreach (MservRecord record in multiValuedProperty.Added) { if (mservRecord.SameRecord(record)) { flag = false; break; } } if (flag) { multiValuedProperty.Add(mservRecord); } } foreach (ProxyAddress proxyAddress2 in proxyAddressCollection.Removed) { foreach (MservRecord mservRecord2 in multiValuedProperty.ToArray()) { if (proxyAddress2.AddressString.Equals(mservRecord2.Key, StringComparison.OrdinalIgnoreCase)) { multiValuedProperty.Remove(mservRecord2); break; } } } }