Example #1
0
        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);
            }
        }
Example #2
0
        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);
        }
Example #3
0
 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);
 }
Example #4
0
 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;
             });
         }
     }
 }
Example #5
0
 internal void SetReferenceParameter <TIdentityParameter>(ADPropertyDefinition propertyBagKey, TIdentityParameter parameter, ConfigurableObject dataObject, GetRecipientDelegate <TIdentityParameter> getRecipient) where TIdentityParameter : IIdentityParameter
 {
     this.SetReferenceParameter <TIdentityParameter>(propertyBagKey, propertyBagKey, parameter, propertyBagKey.Name, dataObject, getRecipient, null);
 }
Example #6
0
		private void GetRecipientDelegates(IProxy mailItem, string uroAddressType, out GetRecipientDelegate getRecipientDelegate, out SetRecipientDelegate setRecipientDelegate)
		{
			if ((null == mailItem) || (string.IsNullOrEmpty(uroAddressType)))
			{
				getRecipientDelegate = null;
				setRecipientDelegate = null;
				return;
			}

			switch (uroAddressType)
			{
			case AddressType.CC:
			case AddressType.BCC:
			case AddressType.To:
			default:
				{
					getRecipientDelegate = mailItem.GetResolvedRecipientsTypeToken;
					setRecipientDelegate = mailItem.SetResolvedRecipientsTypeToken;
				}
				break;
			}
		}
Example #7
0
        internal static void ResolveModifiedMultiReferenceParameter <TIdentityParameter>(string parameterName, object propertyBagKey, IEnumerable <TIdentityParameter> parameters, GetRecipientDelegate <TIdentityParameter> getRecipient, IReferenceErrorReporter referenceErrorReporter, Dictionary <object, MultiValuedProperty <ADObjectId> > recipientIdsDictionary, Dictionary <object, MultiValuedProperty <ADRecipient> > recipientsDictionary, Dictionary <ADRecipient, IIdentityParameter> parameterDictionary) where TIdentityParameter : IIdentityParameter
        {
            MultiValuedProperty <ADRecipient> recipients   = null;
            MultiValuedProperty <ADObjectId>  recipientIds = null;

            if (parameters != null)
            {
                recipients   = new MultiValuedProperty <ADRecipient>();
                recipientIds = new MultiValuedProperty <ADObjectId>();
                using (IEnumerator <TIdentityParameter> enumerator = parameters.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        TIdentityParameter parameter      = enumerator.Current;
                        string             parameterName2 = parameterName;
                        TIdentityParameter parameter2     = parameter;
                        referenceErrorReporter.ValidateReference(parameterName2, parameter2.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);
                            }
                            recipientIds.Add(adrecipient.Identity);
                            recipients.Add(adrecipient);
                            parameterDictionary.Add(adrecipient, parameter);
                        });
                    }
                }
            }
            recipientsDictionary[propertyBagKey]   = recipients;
            recipientIdsDictionary[propertyBagKey] = recipientIds;
        }