internal static PropValue ConvertToMapiPropValue(PropertyValue propertyValue) { PropValue result; try { PropertyTag propertyTag = propertyValue.PropertyTag; object value = null; if (!propertyValue.IsNullValue) { PropertyType propertyType = propertyTag.PropertyType; if (propertyType <= PropertyType.Guid) { if (propertyType <= PropertyType.Object) { switch (propertyType) { case PropertyType.Null: goto IL_244; case PropertyType.Int16: value = propertyValue.GetValue <short>(); goto IL_244; case PropertyType.Int32: value = propertyValue.GetValue <int>(); goto IL_244; default: switch (propertyType) { case PropertyType.Error: value = (uint)propertyValue.Value; goto IL_244; case PropertyType.Bool: value = propertyValue.GetValue <bool>(); goto IL_244; case PropertyType.Object: goto IL_244; } break; } } else { switch (propertyType) { case PropertyType.String8: value = MarshalHelper.GetString8PropertyValue(propertyValue); goto IL_244; case PropertyType.Unicode: value = propertyValue.GetValue <string>(); goto IL_244; default: if (propertyType == PropertyType.SysTime) { value = (DateTime)propertyValue.GetValue <ExDateTime>(); goto IL_244; } if (propertyType == PropertyType.Guid) { value = propertyValue.GetValue <Guid>(); goto IL_244; } break; } } } else if (propertyType <= PropertyType.MultiValueUnicode) { if (propertyType == PropertyType.Binary) { value = propertyValue.GetValue <byte[]>(); goto IL_244; } switch (propertyType) { case PropertyType.MultiValueInt16: value = propertyValue.GetValue <short[]>(); goto IL_244; case PropertyType.MultiValueInt32: value = propertyValue.GetValue <int[]>(); goto IL_244; default: switch (propertyType) { case PropertyType.MultiValueString8: value = MarshalHelper.GetMultiValuedString8PropertyValue(propertyValue); goto IL_244; case PropertyType.MultiValueUnicode: value = propertyValue.GetValue <string[]>(); goto IL_244; } break; } } else { if (propertyType == PropertyType.MultiValueSysTime) { ExDateTime[] value2 = propertyValue.GetValue <ExDateTime[]>(); DateTime[] array = null; if (value2 != null) { array = new DateTime[value2.Length]; for (int i = 0; i < value2.Length; i++) { array[i] = (DateTime)value2[i]; } } value = array; goto IL_244; } if (propertyType == PropertyType.MultiValueGuid) { value = propertyValue.GetValue <Guid[]>(); goto IL_244; } if (propertyType == PropertyType.MultiValueBinary) { value = propertyValue.GetValue <byte[][]>(); goto IL_244; } } throw new NspiException(NspiStatus.InvalidParameter, string.Format("Unable to convert unsupported property type {0} on property {1}.", propertyTag.PropertyType, propertyTag)); } IL_244: result = new PropValue(ConvertHelper.ConvertToMapiPropTag(propertyTag), value); } catch (UnexpectedPropertyTypeException inner) { throw new NspiException(NspiStatus.InvalidParameter, string.Format("Unable to convert invalid PropValue as it contains unsupported PropType on property {0}.", propertyValue), inner); } return(result); }