Exemplo n.º 1
0
        internal PropTag[] GetPropertyTagsToDelete()
        {
            if (!(this.ObjectSchema is MapiObjectSchema))
            {
                throw new MapiInvalidOperationException(Strings.ExceptionSchemaInvalidCast(this.ObjectSchema.GetType().ToString()));
            }
            List <PropTag> list = new List <PropTag>(this.ObjectSchema.AllProperties.Count);

            foreach (PropertyDefinition propertyDefinition in this.ObjectSchema.AllProperties)
            {
                MapiPropertyDefinition mapiPropertyDefinition = (MapiPropertyDefinition)propertyDefinition;
                if (mapiPropertyDefinition.PropertyTag != PropTag.Null && !mapiPropertyDefinition.IsCalculated && !mapiPropertyDefinition.IsFilterOnly && !mapiPropertyDefinition.IsReadOnly)
                {
                    bool flag = false;
                    if (this.propertyBag.IsChanged(mapiPropertyDefinition))
                    {
                        object obj = null;
                        if (this.propertyBag.TryGetField(mapiPropertyDefinition, ref obj) && !mapiPropertyDefinition.PersistDefaultValue && mapiPropertyDefinition.DefaultValue == obj)
                        {
                            list.Add(mapiPropertyDefinition.PropertyTag);
                            flag = true;
                        }
                    }
                    if (mapiPropertyDefinition.IsMandatory && flag)
                    {
                        throw new DataValidationException(new PropertyValidationError(Strings.ErrorMandatoryPropertyMissing(mapiPropertyDefinition.Name), mapiPropertyDefinition, null));
                    }
                }
            }
            this.AdjustPropertyTagsToDelete(list);
            return(list.ToArray());
        }
Exemplo n.º 2
0
 public static PropValue PackNullableEnhancedTimeSpanIntoDays(object value, MapiPropertyDefinition propertyDefinition)
 {
     if (value == null || typeof(EnhancedTimeSpan) == value.GetType())
     {
         PropType type   = propertyDefinition.PropertyTag.ValueType();
         object   value2 = null;
         if (MapiPropValueConvertor.TryCastValueToPack((value == null) ? 0.0 : ((EnhancedTimeSpan)value).TotalDays, type, out value2))
         {
             return(new PropValue(propertyDefinition.PropertyTag, value2));
         }
     }
     throw MapiPropValueConvertor.ConstructPackingException(value, propertyDefinition, Strings.ConstantNa);
 }
Exemplo n.º 3
0
 public static PropValue PackNullableValueToBool(object value, MapiPropertyDefinition propertyDefinition)
 {
     if (value == null || typeof(bool) == value.GetType())
     {
         PropType type   = propertyDefinition.PropertyTag.ValueType();
         object   value2 = null;
         if (MapiPropValueConvertor.TryCastValueToPack((value == null) ? false : value, type, out value2))
         {
             return(new PropValue(propertyDefinition.PropertyTag, value2));
         }
     }
     throw MapiPropValueConvertor.ConstructPackingException(value, propertyDefinition, Strings.ConstantNa);
 }
        public static PropValue Pack(object value, MapiPropertyDefinition propertyDefinition)
        {
            PropTag  propertyTag = propertyDefinition.PropertyTag;
            PropType propType    = propertyTag.ValueType();
            Type     type        = MapiPropValueConvertor.TypeFromPropType(propType, false);

            if (value != null)
            {
                if (typeof(byte[]) == type)
                {
                    if (typeof(Guid) == value.GetType())
                    {
                        return(new PropValue(propertyTag, ((Guid)value).ToByteArray()));
                    }
                    if (typeof(Schedule) == value.GetType())
                    {
                        return(new PropValue(propertyTag, ((Schedule)value).ToByteArray()));
                    }
                }
                if (typeof(DateTime) == type && typeof(DateTime) == value.GetType())
                {
                    return(new PropValue(propertyTag, ((DateTime)value).ToUniversalTime()));
                }
                if (typeof(DateTime[]) == type)
                {
                    Type type2 = value.GetType();
                    if (typeof(MultiValuedProperty <DateTime>) == type2 || typeof(DateTime[]) == type2)
                    {
                        List <DateTime> list = new List <DateTime>(((ICollection)value).Count);
                        foreach (object obj in ((ICollection)value))
                        {
                            list.Add(((DateTime)obj).ToUniversalTime());
                        }
                        return(new PropValue(propertyTag, list.ToArray()));
                    }
                }
                if (type.IsAssignableFrom(value.GetType()))
                {
                    return(new PropValue(propertyTag, value));
                }
            }
            object value2 = null;

            if (MapiPropValueConvertor.TryCastValueToPack(value, propType, out value2))
            {
                return(new PropValue(propertyTag, value2));
            }
            throw MapiPropValueConvertor.ConstructPackingException(value, propertyDefinition, Strings.ConstantNa);
        }
Exemplo n.º 5
0
 public static object ExtractIpV4StringFromIpV6Bytes(PropValue value, MapiPropertyDefinition propertyDefinition)
 {
     if (!(typeof(string) == propertyDefinition.Type))
     {
         throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
     }
     byte[] bytes = value.GetBytes();
     if (16 == bytes.Length)
     {
         return(string.Format("{0}.{1}.{2}.{3}", new object[]
         {
             bytes[4],
             bytes[5],
             bytes[6],
             bytes[7]
         }));
     }
     throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ErrorByteArrayLength(16.ToString(), bytes.Length.ToString()));
 }
Exemplo n.º 6
0
 public static PropValue PackMultiAnsiStringsIntoBytes(object value, MapiPropertyDefinition propertyDefinition)
 {
     if (typeof(MultiValuedProperty <string>) == value.GetType())
     {
         MultiValuedProperty <string> multiValuedProperty = (MultiValuedProperty <string>)value;
         List <byte> list = new List <byte>();
         foreach (string s in multiValuedProperty)
         {
             byte[] bytes = Encoding.ASCII.GetBytes(s);
             list.AddRange(bytes);
             if (bytes[bytes.Length - 1] != 0)
             {
                 list.Add(0);
             }
         }
         return(new PropValue(propertyDefinition.PropertyTag, list.ToArray()));
     }
     throw MapiPropValueConvertor.ConstructPackingException(value, propertyDefinition, Strings.ConstantNa);
 }
Exemplo n.º 7
0
        internal PropTag[] GetPropertyTagsToRead()
        {
            if (!(this.ObjectSchema is MapiObjectSchema))
            {
                throw new MapiInvalidOperationException(Strings.ExceptionSchemaInvalidCast(this.ObjectSchema.GetType().ToString()));
            }
            List <PropTag> list = new List <PropTag>(this.ObjectSchema.AllProperties.Count);

            foreach (PropertyDefinition propertyDefinition in this.ObjectSchema.AllProperties)
            {
                MapiPropertyDefinition mapiPropertyDefinition = (MapiPropertyDefinition)propertyDefinition;
                if (mapiPropertyDefinition.PropertyTag != PropTag.Null && !mapiPropertyDefinition.IsCalculated)
                {
                    list.Add(mapiPropertyDefinition.PropertyTag);
                }
            }
            this.AdjustPropertyTagsToRead(list);
            return(list.ToArray());
        }
Exemplo n.º 8
0
 public static object ExtractMacAddressStringFromBytes(PropValue value, MapiPropertyDefinition propertyDefinition)
 {
     if (!(typeof(string) == propertyDefinition.Type))
     {
         throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
     }
     byte[] bytes = value.GetBytes();
     if (6 == bytes.Length)
     {
         return(string.Format("{0:X2}-{1:X2}-{2:X2}-{3:X2}-{4:X2}-{5:X2}", new object[]
         {
             bytes[0],
             bytes[1],
             bytes[2],
             bytes[3],
             bytes[4],
             bytes[5]
         }));
     }
     throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ErrorByteArrayLength(6.ToString(), bytes.Length.ToString()));
 }
Exemplo n.º 9
0
 public static object ExtractMultiAnsiStringsFromBytes(PropValue value, MapiPropertyDefinition propertyDefinition)
 {
     if (typeof(string) == propertyDefinition.Type && propertyDefinition.IsMultivalued)
     {
         byte[]        bytes = value.GetBytes();
         List <string> list  = new List <string>();
         int           num   = 0;
         int           num2  = 0;
         while (bytes.Length > num2)
         {
             if (bytes[num2] == 0)
             {
                 list.Add(Encoding.ASCII.GetString(bytes, num, num2 - num));
                 num = 1 + num2;
             }
             num2++;
         }
         return(new MultiValuedProperty <string>(propertyDefinition.IsReadOnly, propertyDefinition, list));
     }
     throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
 }
Exemplo n.º 10
0
        internal PropValue[] GetPropertyValuesToUpdate()
        {
            if (!(this.ObjectSchema is MapiObjectSchema))
            {
                throw new MapiInvalidOperationException(Strings.ExceptionSchemaInvalidCast(this.ObjectSchema.GetType().ToString()));
            }
            List <PropValue> list = new List <PropValue>(this.ObjectSchema.AllProperties.Count);

            foreach (PropertyDefinition propertyDefinition in this.ObjectSchema.AllProperties)
            {
                MapiPropertyDefinition mapiPropertyDefinition = (MapiPropertyDefinition)propertyDefinition;
                if (mapiPropertyDefinition.PropertyTag != PropTag.Null && !mapiPropertyDefinition.IsCalculated && !mapiPropertyDefinition.IsFilterOnly && !mapiPropertyDefinition.IsReadOnly)
                {
                    bool flag = false;
                    if (base.ObjectState == ObjectState.New && !this.propertyBag.IsChanged(mapiPropertyDefinition) && (mapiPropertyDefinition.DefaultValue != mapiPropertyDefinition.InitialValue || mapiPropertyDefinition.PersistDefaultValue))
                    {
                        this.propertyBag[mapiPropertyDefinition] = mapiPropertyDefinition.InitialValue;
                    }
                    if (((MapiPropertyBag)this.propertyBag).IsChangedOrInitialized(mapiPropertyDefinition))
                    {
                        object obj = null;
                        if (this.propertyBag.TryGetField(mapiPropertyDefinition, ref obj) && (mapiPropertyDefinition.DefaultValue != obj || mapiPropertyDefinition.PersistDefaultValue))
                        {
                            list.Add(mapiPropertyDefinition.Packer(obj, mapiPropertyDefinition));
                            flag = true;
                        }
                    }
                    if (mapiPropertyDefinition.IsMandatory && base.ObjectState == ObjectState.New && !flag)
                    {
                        throw new DataValidationException(new PropertyValidationError(Strings.ErrorMandatoryPropertyMissing(mapiPropertyDefinition.Name), mapiPropertyDefinition, null));
                    }
                }
            }
            this.AdjustPropertyValuesToUpdate(list);
            return(list.ToArray());
        }
        public static object Extract(PropValue value, MapiPropertyDefinition propertyDefinition)
        {
            bool isReadOnly     = propertyDefinition.IsReadOnly;
            Type type           = propertyDefinition.Type;
            Type underlyingType = Nullable.GetUnderlyingType(type);

            if (null != underlyingType)
            {
                type = underlyingType;
            }
            if (propertyDefinition.PropertyTag.Id() != value.PropTag.Id())
            {
                throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ExceptionUnmatchedPropTag(propertyDefinition.PropertyTag.ToString(), value.PropTag.ToString()));
            }
            if (PropType.Binary == value.PropType)
            {
                if (typeof(Guid) == type)
                {
                    return(new Guid(value.GetBytes()));
                }
                if (typeof(Schedule) == type)
                {
                    return(Schedule.FromByteArray(value.GetBytes()));
                }
                if (typeof(MapiEntryId) == type)
                {
                    return(new MapiEntryId(value.GetBytes()));
                }
            }
            if (typeof(short) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <short>(isReadOnly, propertyDefinition, value.GetShortArray()));
                }
                return(value.GetShort());
            }
            else if (typeof(int) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <int>(isReadOnly, propertyDefinition, value.GetIntArray()));
                }
                return(value.GetInt());
            }
            else if (typeof(long) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <long>(isReadOnly, propertyDefinition, value.GetLongArray()));
                }
                return(value.GetLong());
            }
            else if (typeof(float) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <float>(isReadOnly, propertyDefinition, value.GetFloatArray()));
                }
                return(value.GetFloat());
            }
            else if (typeof(double) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <double>(isReadOnly, propertyDefinition, value.GetDoubleArray()));
                }
                return(value.GetDouble());
            }
            else if (typeof(DateTime) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    DateTime[]      dateTimeArray = value.GetDateTimeArray();
                    List <DateTime> list          = new List <DateTime>(dateTimeArray.Length);
                    foreach (DateTime dateTime in dateTimeArray)
                    {
                        list.Add(dateTime.ToLocalTime());
                    }
                    return(new MultiValuedProperty <DateTime>(isReadOnly, propertyDefinition, list.ToArray()));
                }
                return(value.GetDateTime().ToLocalTime());
            }
            else if (typeof(bool) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <bool>(isReadOnly, propertyDefinition, value.GetBoolArray()));
                }
                return(value.GetBoolean());
            }
            else if (typeof(string) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <string>(isReadOnly, propertyDefinition, value.GetStringArray()));
                }
                return(value.GetString());
            }
            else if (typeof(Guid) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <Guid>(isReadOnly, propertyDefinition, value.GetGuidArray()));
                }
                return(value.GetGuid());
            }
            else if (typeof(byte[]) == type)
            {
                if (propertyDefinition.IsMultivalued)
                {
                    return(new MultiValuedProperty <byte[]>(isReadOnly, propertyDefinition, value.GetBytesArray()));
                }
                return(value.GetBytes());
            }
            else
            {
                if (typeof(short[]) == type)
                {
                    return(value.GetShortArray());
                }
                if (typeof(int[]) == type)
                {
                    return(value.GetIntArray());
                }
                if (typeof(long[]) == type)
                {
                    return(value.GetLongArray());
                }
                if (typeof(float[]) == type)
                {
                    return(value.GetFloatArray());
                }
                if (typeof(double[]) == type)
                {
                    return(value.GetDoubleArray());
                }
                if (typeof(DateTime[]) == type)
                {
                    DateTime[]      dateTimeArray2 = value.GetDateTimeArray();
                    List <DateTime> list2          = new List <DateTime>(dateTimeArray2.Length);
                    foreach (DateTime dateTime2 in dateTimeArray2)
                    {
                        list2.Add(dateTime2.ToLocalTime());
                    }
                    return(list2.ToArray());
                }
                if (typeof(bool[]) == type)
                {
                    return(value.GetBoolArray());
                }
                if (typeof(string[]) == type)
                {
                    return(value.GetStringArray());
                }
                if (typeof(Guid[]) == type)
                {
                    return(value.GetGuidArray());
                }
                if (typeof(byte[][]) == type)
                {
                    return(value.GetBytesArray());
                }
                if (type.IsAssignableFrom(MapiPropValueConvertor.TypeFromPropType(value.PropType, false)))
                {
                    return(value.RawValue);
                }
                object result = null;
                if (MapiPropValueConvertor.TryCastValueToExtract(value, type, out result))
                {
                    return(result);
                }
                throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
            }
        }
        public static MultiValuedPropertyBase MultiValuedPropertyFromCollection(ICollection values, MapiPropertyDefinition propertyDefinition, bool forceReadOnly)
        {
            if (!propertyDefinition.IsMultivalued)
            {
                throw new NotSupportedException(Strings.ExceptionNotMultiValuedPropertyDefinition(propertyDefinition.Name));
            }
            Type type     = propertyDefinition.Type;
            bool readOnly = propertyDefinition.IsReadOnly || forceReadOnly;
            bool flag     = propertyDefinition.IsReadOnly && 0 == values.Count;

            if (typeof(short) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <short>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <short> .Empty);
            }
            else if (typeof(int) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <int>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <int> .Empty);
            }
            else if (typeof(long) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <long>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <long> .Empty);
            }
            else if (typeof(float) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <float>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <float> .Empty);
            }
            else if (typeof(double) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <double>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <double> .Empty);
            }
            else if (typeof(DateTime) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <DateTime>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <DateTime> .Empty);
            }
            else if (typeof(bool) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <bool>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <bool> .Empty);
            }
            else if (typeof(string) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <string>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <string> .Empty);
            }
            else if (typeof(Guid) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <Guid>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <Guid> .Empty);
            }
            else if (typeof(byte[]) == type)
            {
                if (!flag)
                {
                    return(new MultiValuedProperty <byte[]>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <byte[]> .Empty);
            }
            else
            {
                if (!(typeof(ObjectId) == type))
                {
                    throw new NotSupportedException(Strings.ExceptionNoIdeaGenerateMultiValuedProperty(propertyDefinition.Type.ToString()));
                }
                if (!flag)
                {
                    return(new MultiValuedProperty <ObjectId>(readOnly, propertyDefinition, values));
                }
                return(MultiValuedProperty <ObjectId> .Empty);
            }
        }
Exemplo n.º 13
0
        internal void Instantiate(PropValue[] propertyValues)
        {
            if (propertyValues == null)
            {
                throw new ArgumentNullException("propertyValues");
            }
            if (propertyValues.Length == 0)
            {
                return;
            }
            if (!(this.ObjectSchema is MapiObjectSchema))
            {
                throw new MapiInvalidOperationException(Strings.ExceptionSchemaInvalidCast(this.ObjectSchema.GetType().ToString()));
            }
            base.InstantiationErrors.Clear();
            MapiStore mapiStore = null;
            MapiProp  mapiProp  = null;

            try
            {
                foreach (PropertyDefinition propertyDefinition in this.ObjectSchema.AllProperties)
                {
                    MapiPropertyDefinition mapiPropertyDefinition = (MapiPropertyDefinition)propertyDefinition;
                    if (!mapiPropertyDefinition.IsCalculated && mapiPropertyDefinition.PropertyTag != PropTag.Null)
                    {
                        bool      flag      = false;
                        PropValue propValue = new PropValue(PropTag.Null, null);
                        foreach (PropValue propValue in propertyValues)
                        {
                            if (propValue.PropTag.Id() == mapiPropertyDefinition.PropertyTag.Id())
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            if (mapiPropertyDefinition.IsMandatory)
                            {
                                base.InstantiationErrors.Add(new PropertyValidationError(Strings.ErrorMandatoryPropertyMissing(mapiPropertyDefinition.Name), mapiPropertyDefinition, null));
                            }
                        }
                        else
                        {
                            if (PropType.Error == propValue.PropType && propValue.GetErrorValue() == -2147024882)
                            {
                                if (mapiProp == null)
                                {
                                    mapiProp = this.GetRawMapiEntry(out mapiStore);
                                }
                                propValue = mapiProp.GetProp(mapiPropertyDefinition.PropertyTag);
                            }
                            if (PropType.Error == propValue.PropType)
                            {
                                ExTraceGlobals.MapiObjectTracer.TraceError <PropTag>((long)this.GetHashCode(), "Retrieving PropTag '{0}' failed.", mapiPropertyDefinition.PropertyTag);
                            }
                            else
                            {
                                try
                                {
                                    object value = mapiPropertyDefinition.Extractor(propValue, mapiPropertyDefinition);
                                    IList <ValidationError> list = mapiPropertyDefinition.ValidateProperty(value, this.propertyBag, false);
                                    if (list != null)
                                    {
                                        base.InstantiationErrors.AddRange(list);
                                    }
                                    this.propertyBag.SetField(mapiPropertyDefinition, value);
                                }
                                catch (MapiConvertingException ex)
                                {
                                    base.InstantiationErrors.Add(new PropertyConversionError(ex.LocalizedString, mapiPropertyDefinition, propValue, ex));
                                }
                            }
                        }
                    }
                }
            }
            finally
            {
                if (mapiProp != null)
                {
                    mapiProp.Dispose();
                    mapiProp = null;
                }
                if (mapiStore != null)
                {
                    mapiStore.Dispose();
                    mapiStore = null;
                }
            }
        }
Exemplo n.º 14
0
 public static PropValue PackNullableEnhancedTimeSpanIntoSeconds(object value, MapiPropertyDefinition propertyDefinition)
 {
     if (value != null && typeof(EnhancedTimeSpan) == value.GetType())
     {
         object value2 = null;
         if (MapiPropValueConvertor.TryCastValueToPack(((EnhancedTimeSpan)value).TotalSeconds, propertyDefinition.PropertyTag.ValueType(), out value2))
         {
             return(new PropValue(propertyDefinition.PropertyTag, value2));
         }
     }
     throw MapiPropValueConvertor.ConstructPackingException(value, propertyDefinition, Strings.ConstantNa);
 }
Exemplo n.º 15
0
 public static PropValue PackNullableUnlimitedByteQuantifiedSizeIntoKilobytes(object value, MapiPropertyDefinition propertyDefinition)
 {
     if (value == null || typeof(Unlimited <ByteQuantifiedSize>) == value.GetType())
     {
         long num = -1L;
         if (value != null)
         {
             Unlimited <ByteQuantifiedSize> unlimited = (Unlimited <ByteQuantifiedSize>)value;
             if (unlimited.IsUnlimited)
             {
                 num = -1L;
             }
             else
             {
                 num = checked ((long)unlimited.Value.ToKB());
             }
         }
         object value2 = null;
         if (MapiPropValueConvertor.TryCastValueToPack(num, propertyDefinition.PropertyTag.ValueType(), out value2))
         {
             return(new PropValue(propertyDefinition.PropertyTag, value2));
         }
     }
     throw MapiPropValueConvertor.ConstructPackingException(value, propertyDefinition, Strings.ConstantNa);
 }
        internal static MapiConvertingException ConstructPackingException(object value, MapiPropertyDefinition propertyDefinition, LocalizedString errorDetails)
        {
            if (errorDetails.IsEmpty)
            {
                errorDetails = Strings.ConstantNa;
            }
            MapiConvertingException ex = new MapiPackingException(propertyDefinition.Name, (value == null) ? Strings.ConstantNull : value.ToString(), (value == null) ? Strings.ConstantNull : value.GetType().Name, propertyDefinition.IsMultivalued.ToString(), propertyDefinition.PropertyTag.ToString(), propertyDefinition.PropertyTag.ValueType().ToString(), errorDetails);

            ExTraceGlobals.ConvertorTracer.TraceError((long)typeof(MapiPropValueConvertor).GetHashCode(), ex.Message);
            return(ex);
        }
Exemplo n.º 17
0
 public static object ExtractUnlimitedByteQuantifiedSizeFromPages(PropValue value, MapiPropertyDefinition propertyDefinition)
 {
     if (typeof(Unlimited <ByteQuantifiedSize>) == propertyDefinition.Type)
     {
         object obj = null;
         if (MapiPropValueConvertor.TryCastValueToExtract(value, typeof(int), out obj))
         {
             long num = (long)((int)obj);
             if (0L > num)
             {
                 return(Unlimited <ByteQuantifiedSize> .UnlimitedValue);
             }
             return(new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromBytes(checked ((ulong)num * 32UL * 1024UL))));
         }
     }
     throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
 }
Exemplo n.º 18
0
 public static object ExtractNullableEnhancedTimeSpanFromSeconds(PropValue value, MapiPropertyDefinition propertyDefinition)
 {
     if (typeof(EnhancedTimeSpan?) == propertyDefinition.Type)
     {
         object obj = null;
         if (MapiPropValueConvertor.TryCastValueToExtract(value, typeof(double), out obj))
         {
             return(new EnhancedTimeSpan?(EnhancedTimeSpan.FromSeconds((double)obj)));
         }
     }
     throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
 }
Exemplo n.º 19
0
 public static object ExtractNullableUnlimitedByteQuantifiedSizeFromKilobytes(PropValue value, MapiPropertyDefinition propertyDefinition)
 {
     if (typeof(Unlimited <ByteQuantifiedSize>?) == propertyDefinition.Type)
     {
         object obj = null;
         if (MapiPropValueConvertor.TryCastValueToExtract(value, typeof(long), out obj))
         {
             long num = (long)obj;
             if (0L > num)
             {
                 return(new Unlimited <ByteQuantifiedSize>?(Unlimited <ByteQuantifiedSize> .UnlimitedValue));
             }
             return(new Unlimited <ByteQuantifiedSize>?(new Unlimited <ByteQuantifiedSize>(ByteQuantifiedSize.FromKB(checked ((ulong)num)))));
         }
     }
     throw MapiPropValueConvertor.ConstructExtractingException(value, propertyDefinition, Strings.ConstantNa);
 }