internal static PropertyValue ConvertFromMapiPropValue(PropValue mapiPropValue, int codePage) { PropertyValue result; try { PropertyTag propertyTag = new PropertyTag((uint)mapiPropValue.PropTag); object obj = null; PropertyType propertyType = propertyTag.PropertyType; if (propertyType <= PropertyType.Guid) { if (propertyType <= PropertyType.Object) { switch (propertyType) { case PropertyType.Null: goto IL_2E7; case PropertyType.Int16: obj = mapiPropValue.GetShort(); goto IL_2E7; case PropertyType.Int32: obj = mapiPropValue.GetInt(); goto IL_2E7; default: switch (propertyType) { case PropertyType.Error: obj = (ErrorCode)mapiPropValue.GetErrorValue(); goto IL_2E7; case PropertyType.Bool: obj = mapiPropValue.GetBoolean(); goto IL_2E7; case PropertyType.Object: goto IL_2E7; } break; } } else { switch (propertyType) { case PropertyType.String8: obj = ConvertHelper.ConvertMapiPtString8ToString8(mapiPropValue.Value, codePage); goto IL_2E7; case PropertyType.Unicode: obj = mapiPropValue.GetString(); goto IL_2E7; default: if (propertyType == PropertyType.SysTime) { DateTime dateTime = mapiPropValue.GetDateTime(); obj = (ExDateTime)dateTime; goto IL_2E7; } if (propertyType == PropertyType.Guid) { obj = mapiPropValue.GetGuid(); goto IL_2E7; } break; } } } else if (propertyType <= PropertyType.MultiValueUnicode) { if (propertyType == PropertyType.Binary) { obj = mapiPropValue.GetBytes(); goto IL_2E7; } switch (propertyType) { case PropertyType.MultiValueInt16: obj = mapiPropValue.GetShortArray(); goto IL_2E7; case PropertyType.MultiValueInt32: obj = mapiPropValue.GetIntArray(); goto IL_2E7; default: switch (propertyType) { case PropertyType.MultiValueString8: if (mapiPropValue.Value is string[]) { string[] array = (string[])mapiPropValue.Value; String8[] array2 = new String8[array.Length]; for (int i = 0; i < array.Length; i++) { array2[i] = ConvertHelper.ConvertMapiPtString8ToString8(array[i], codePage); } obj = array2; goto IL_2E7; } if (mapiPropValue.Value is byte[][]) { byte[][] array3 = (byte[][])mapiPropValue.Value; String8[] array4 = new String8[array3.Length]; for (int j = 0; j < array3.Length; j++) { array4[j] = ConvertHelper.ConvertMapiPtString8ToString8(array3[j], codePage); } obj = array4; goto IL_2E7; } goto IL_2E7; case PropertyType.MultiValueUnicode: obj = mapiPropValue.GetStringArray(); goto IL_2E7; } break; } } else if (propertyType != PropertyType.MultiValueSysTime) { if (propertyType == PropertyType.MultiValueGuid) { obj = mapiPropValue.GetGuidArray(); goto IL_2E7; } if (propertyType == PropertyType.MultiValueBinary) { obj = mapiPropValue.GetBytesArray(); goto IL_2E7; } } else { DateTime[] dateTimeArray = mapiPropValue.GetDateTimeArray(); if (dateTimeArray != null) { ExDateTime[] array5 = new ExDateTime[dateTimeArray.Length]; for (int k = 0; k < dateTimeArray.Length; k++) { array5[k] = (ExDateTime)dateTimeArray[k]; } obj = array5; goto IL_2E7; } goto IL_2E7; } throw new NspiException(NspiStatus.InvalidParameter, string.Format("Unable to convert unsupported property type {0} on property {1}.", propertyTag.PropertyType, propertyTag)); IL_2E7: if (obj == null) { result = PropertyValue.NullValue(propertyTag); } else { result = new PropertyValue(propertyTag, obj); } } catch (InvalidPropertyValueTypeException inner) { throw new NspiException(NspiStatus.InvalidParameter, string.Format("Unable to convert invalid PropValue on property {0}.", mapiPropValue), inner); } catch (NotSupportedException inner2) { throw new NspiException(NspiStatus.InvalidParameter, string.Format("Unable to convert invalid PropValue as it contains unsupported PropType on property {0}.", mapiPropValue), inner2); } return(result); }