protected List <PropValue> GetPropValuesFromValues(ExTimeZone exTimeZone, IList <PropertyDefinition> propertyDefinitions, IList <object> propertyValues) { ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.Session.Mailbox.MapiStore, this.Session, false, propertyDefinitions); List <PropValue> list = new List <PropValue>(propertyDefinitions.Count); int num = 0; foreach (PropTag propTag in collection) { InternalSchema.CheckPropertyValueType(propertyDefinitions[num], propertyValues[num]); list.Add(MapiPropertyBag.GetPropValueFromValue(this.Session, exTimeZone, propTag, propertyValues[num])); num++; } return(list); }
private PropertyError[] InternalSetProperties(PropertyDefinition[] propertyDefinitions, object[] propertyValues, MapiPropertyBag.MapiSetProps mapiSetProps) { this.CheckDisposed("SetProperties"); if (propertyDefinitions == null) { throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyDefinitions", 1)); } if (propertyValues == null) { throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyValues", 2)); } if (propertyDefinitions.Length == 0) { return(MapiPropertyBag.EmptyPropertyErrorArray); } ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiProp, this.storeSession, (this.saveFlags & PropertyBagSaveFlags.IgnoreUnresolvedHeaders) == PropertyBagSaveFlags.IgnoreUnresolvedHeaders, true, (this.saveFlags & PropertyBagSaveFlags.DisableNewXHeaderMapping) != PropertyBagSaveFlags.DisableNewXHeaderMapping, propertyDefinitions); List <PropValue> list = new List <PropValue>(propertyDefinitions.Length); int num = 0; foreach (PropTag propTag in collection) { if (propTag != PropTag.Unresolved) { InternalSchema.CheckPropertyValueType(propertyDefinitions[num], propertyValues[num]); list.Add(MapiPropertyBag.GetPropValueFromValue(this.storeSession, this.ExTimeZone, propTag, propertyValues[num])); } num++; } PropProblem[] array = null; StoreSession storeSession = this.StoreSession; bool flag = false; try { if (storeSession != null) { storeSession.BeginMapiCall(); storeSession.BeginServerHealthCall(); flag = true; } if (StorageGlobals.MapiTestHookBeforeCall != null) { StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod()); } try { array = mapiSetProps(list.ToArray()); } catch (MapiExceptionNotEnoughMemory mapiExceptionNotEnoughMemory) { ExTraceGlobals.StorageTracer.TraceError <MapiExceptionNotEnoughMemory>((long)this.GetHashCode(), "MapiPropertyBag::InternalSetProperties. Failed to SetProps due to MapiException {0}.", mapiExceptionNotEnoughMemory); string errorDescription = mapiExceptionNotEnoughMemory.ToString(); List <PropertyError> list2 = new List <PropertyError>(); foreach (PropertyDefinition propertyDefinition in propertyDefinitions) { list2.Add(new PropertyError(propertyDefinition, PropertyErrorCode.NotEnoughMemory, errorDescription)); } throw PropertyError.ToException(list2.ToArray()); } } catch (MapiPermanentException ex) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetProps, ex, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiPropertyBag::InternalSetProperties.", new object[0]), ex }); } catch (MapiRetryableException ex2) { throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetProps, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[] { string.Format("MapiPropertyBag::InternalSetProperties.", new object[0]), ex2 }); } finally { try { if (storeSession != null) { storeSession.EndMapiCall(); if (flag) { storeSession.EndServerHealthCall(); } } } finally { if (StorageGlobals.MapiTestHookAfterCall != null) { StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod()); } } } PropertyError[] array2 = MapiPropertyBag.EmptyPropertyErrorArray; if (array != null) { array2 = new PropertyError[array.Length]; for (int j = 0; j < array.Length; j++) { int scode = array[j].Scode; PropertyDefinition propertyDefinition2 = null; int num2 = 0; foreach (PropTag propTag2 in collection) { if (array[j].PropTag == propTag2) { propertyDefinition2 = propertyDefinitions[num2]; break; } num2++; } string errorDescription2; PropertyErrorCode error = MapiPropertyHelper.MapiErrorToXsoError(scode, out errorDescription2); array2[j] = new PropertyError(propertyDefinition2, error, errorDescription2); ExTraceGlobals.StorageTracer.TraceError <string, MapiProp, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::InternalSetProperties. Failed. PropDef display name= {0}, MapiProp = {1}, Error = {2}.", propertyDefinition2.Name, this.MapiProp, array2[j]); } } return(array2); }