private static MservRecord GetRecord(IPropertyBag propertyBag, MservValueFormat format, out bool isPrimary) { MServPropertyDefinition mservPropertyDefinition; MservRecord record = MServRecipientSchema.GetRecord(propertyBag, format, false, out mservPropertyDefinition); isPrimary = (mservPropertyDefinition == MServRecipientSchema.MservPrimaryRecord); return(record); }
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); }