private List <ADRecipient> GetRecipients <TIdentityParameter>(IEnumerable <TIdentityParameter> parameters, string parameterName, GetRecipientDelegate <TIdentityParameter> getRecipient, ValidateRecipientDelegate validateRecipient) where TIdentityParameter : class, IIdentityParameter { List <ADRecipient> list = new List <ADRecipient>(); HashSet <ADObjectId> recipientIds = new HashSet <ADObjectId>(); using (IEnumerator <TIdentityParameter> enumerator = parameters.GetEnumerator()) { while (enumerator.MoveNext()) { TIdentityParameter parameter = enumerator.Current; IReferenceErrorReporter referenceErrorReporter = this.ReferenceErrorReporter; string parameterName2 = parameterName; TIdentityParameter parameter3 = parameter; referenceErrorReporter.ValidateReference(parameterName2, parameter3.RawIdentity, delegate(Task.ErrorLoggerDelegate writeError) { ADRecipient adrecipient = getRecipient(parameter, writeError); if (recipientIds.Contains((ADObjectId)adrecipient.Identity)) { writeError(new RecipientTaskException(Strings.ErrorRecipientIdParamElementsNotUnique(parameterName, adrecipient.Id.ToString())), ExchangeErrorCategory.Client, parameter); } if (validateRecipient != null) { ValidateRecipientDelegate validateRecipient2 = validateRecipient; ADRecipient recipient = adrecipient; TIdentityParameter parameter2 = parameter; validateRecipient2(recipient, parameter2.RawIdentity, writeError); } recipientIds.Add((ADObjectId)adrecipient.Identity); list.Add(adrecipient); this.parameterDictionary.Add(adrecipient, parameter); }); } } return(list); }
public static ValidateRecipientDelegate ValidateBypassADUser(ValidateRecipientDelegate validateRecipient) { return(delegate(ADRecipient recipient, string recipientId, Task.ErrorLoggerDelegate writeError) { if (recipient.RecipientType == RecipientType.User) { return; } validateRecipient(recipient, recipientId, writeError); }); }
internal void SetMultiReferenceParameter <TIdentityParameter>(object sourcePropertyBagKey, ADPropertyDefinition targetPropertyBagKey, MultiValuedProperty <TIdentityParameter> parameters, string parameterName, ConfigurableObject dataObject, GetRecipientDelegate <TIdentityParameter> getRecipient, ValidateRecipientDelegate validateRecipient) where TIdentityParameter : class, IIdentityParameter { Func <object, TIdentityParameter> func = null; Func <ADRecipient, ADObjectId> func2 = null; Func <object, TIdentityParameter> func3 = null; Func <ADRecipient, ADObjectId> func4 = null; Func <ADRecipient, ADObjectId> func5 = null; if (base.Fields.IsModified(sourcePropertyBagKey)) { if (parameters == null) { dataObject[targetPropertyBagKey] = null; return; } if (parameters.IsChangesOnlyCopy) { object[] added = parameters.Added; object[] removed = parameters.Removed; Hashtable hashtable = new Hashtable(); if (added.Length > 0) { IEnumerable <object> source = added; if (func == null) { func = ((object obj) => (TIdentityParameter)((object)obj)); } List <ADRecipient> recipients = this.GetRecipients <TIdentityParameter>(source.Select(func), parameterName, getRecipient, validateRecipient); Hashtable hashtable2 = hashtable; object key = "Add"; IEnumerable <ADRecipient> source2 = recipients; if (func2 == null) { func2 = ((ADRecipient recipient) => recipient.OriginalId); } hashtable2.Add(key, source2.Select(func2).ToArray <ADObjectId>()); this.recipientsDictionary[sourcePropertyBagKey] = new MultiValuedProperty <ADRecipient>(recipients); } if (removed.Length > 0) { IEnumerable <object> source3 = removed; if (func3 == null) { func3 = ((object obj) => (TIdentityParameter)((object)obj)); } List <ADRecipient> recipients2 = this.GetRecipients <TIdentityParameter>(source3.Select(func3), parameterName, getRecipient, null); Hashtable hashtable3 = hashtable; object key2 = "Remove"; IEnumerable <ADRecipient> source4 = recipients2; if (func4 == null) { func4 = ((ADRecipient recipient) => recipient.OriginalId); } hashtable3.Add(key2, source4.Select(func4).ToArray <ADObjectId>()); } dataObject[targetPropertyBagKey] = new MultiValuedProperty <ADObjectId>(hashtable); return; } List <ADRecipient> recipients3 = this.GetRecipients <TIdentityParameter>(parameters, parameterName, getRecipient, validateRecipient); IEnumerable <ADRecipient> source5 = recipients3; if (func5 == null) { func5 = ((ADRecipient recipient) => recipient.OriginalId); } dataObject[targetPropertyBagKey] = new MultiValuedProperty <ADObjectId>(source5.Select(func5).ToArray <ADObjectId>()); this.recipientsDictionary[sourcePropertyBagKey] = new MultiValuedProperty <ADRecipient>(recipients3); } }
internal void SetMultiReferenceParameter <TIdentityParameter>(ADPropertyDefinition propertyBagKey, MultiValuedProperty <TIdentityParameter> parameters, ConfigurableObject dataObject, GetRecipientDelegate <TIdentityParameter> getRecipient, ValidateRecipientDelegate validateRecipient) where TIdentityParameter : class, IIdentityParameter { this.SetMultiReferenceParameter <TIdentityParameter>(propertyBagKey, propertyBagKey, parameters, propertyBagKey.Name, dataObject, getRecipient, validateRecipient); }
internal void SetReferenceParameter <TIdentityParameter>(object sourcePropertyBagKey, ADPropertyDefinition targetPropertyBagKey, TIdentityParameter parameter, string parameterName, ConfigurableObject dataObject, GetRecipientDelegate <TIdentityParameter> getRecipient, ValidateRecipientDelegate validateRecipient) where TIdentityParameter : IIdentityParameter { if (base.Fields.IsModified(sourcePropertyBagKey)) { dataObject[targetPropertyBagKey] = null; if (parameter != null) { this.ReferenceErrorReporter.ValidateReference(parameterName, parameter.RawIdentity, delegate(Task.ErrorLoggerDelegate writeError) { ADRecipient adrecipient = getRecipient(parameter, writeError); if (validateRecipient != null) { validateRecipient(adrecipient, parameter.RawIdentity, writeError); } this.parameterDictionary[adrecipient] = parameter; this.recipientDictionary[sourcePropertyBagKey] = adrecipient; dataObject[targetPropertyBagKey] = adrecipient.Identity; }); } } }