private static bool PopulateConsumerMailboxProperties(ADRawEntry user, ulong puid, IEnumerable <ADPropertyDefinition> propertiesToSet, PropertyBag propertyValuesBag, bool setMbxPropertyDefinition = false) { bool result = false; if (!setMbxPropertyDefinition) { user.SetId(ConsumerIdentityHelper.GetADObjectIdFromPuid(puid)); } foreach (ADPropertyDefinition adpropertyDefinition in propertiesToSet) { if (propertyValuesBag.IsModified(adpropertyDefinition)) { if (adpropertyDefinition.IsMultivalued) { MultiValuedPropertyBase multiValuedPropertyBase = setMbxPropertyDefinition ? ((MultiValuedPropertyBase)user[adpropertyDefinition.MbxPropertyDefinition]) : ((MultiValuedPropertyBase)user[adpropertyDefinition]); MultiValuedPropertyBase multiValuedPropertyBase2 = (MultiValuedPropertyBase)propertyValuesBag[adpropertyDefinition]; foreach (object item in multiValuedPropertyBase2.Added) { multiValuedPropertyBase.Add(item); } foreach (object item2 in multiValuedPropertyBase2.Removed) { multiValuedPropertyBase.Remove(item2); } } else if (setMbxPropertyDefinition) { user[adpropertyDefinition.MbxPropertyDefinition] = propertyValuesBag[adpropertyDefinition]; } else { user[adpropertyDefinition] = propertyValuesBag[adpropertyDefinition]; } result = true; } } return(result); }
internal bool TryApplyChange(ProviderPropertyDefinition pdef, ConfigurableObject targetObject, PropertyUpdateOperation op) { object obj = null; if (this.TryGetValue(pdef, out obj)) { Exception ex = null; try { if (op == PropertyUpdateOperation.Replace) { object obj2 = targetObject[pdef]; if ((!object.Equals(obj, pdef.DefaultValue) || obj2 != null) && !object.Equals(obj2, obj)) { if (pdef == ADObjectSchema.ExchangeVersion) { targetObject.SetExchangeVersion((ExchangeObjectVersion)obj); } else { targetObject[pdef] = obj; } } } else { MultiValuedPropertyBase multiValuedPropertyBase = obj as MultiValuedPropertyBase; MultiValuedPropertyBase multiValuedPropertyBase2 = targetObject[pdef] as MultiValuedPropertyBase; if (multiValuedPropertyBase != null && multiValuedPropertyBase2 != null) { foreach (object item in ((IEnumerable)multiValuedPropertyBase)) { switch (op) { case PropertyUpdateOperation.AddValues: multiValuedPropertyBase2.Add(item); break; case PropertyUpdateOperation.RemoveValues: multiValuedPropertyBase2.Remove(item); break; } } } } return(true); } catch (DataValidationException ex2) { ex = ex2; } catch (ArgumentException ex3) { ex = ex3; } catch (FormatException ex4) { ex = ex4; } catch (LocalizedException ex5) { ex = ex5; } if (ex != null) { MrsTracer.Common.Warning("Property {0} could not be set to '{1}', error {2}", new object[] { pdef.Name, obj, CommonUtils.FullExceptionMessage(ex) }); return(false); } return(false); } return(false); }