示例#1
0
        public static int GetSizeOfFixedSizeProperty(PropertyTag.PropertyType propType)
        {
            PropertyTag.PropertyType propertyType = propType & ~PropertyTag.PropertyType.Multivalued;
            switch (propertyType)
            {
            case PropertyTag.PropertyType.Unspecified:
            case PropertyTag.PropertyType.Null:
                return(0);

            case PropertyTag.PropertyType.Int16:
            case PropertyTag.PropertyType.Boolean:
                return(2);

            case PropertyTag.PropertyType.Int32:
            case PropertyTag.PropertyType.Float:
            case PropertyTag.PropertyType.Error:
                return(4);

            case PropertyTag.PropertyType.Double:
            case PropertyTag.PropertyType.Currency:
            case PropertyTag.PropertyType.AppTime:
            case PropertyTag.PropertyType.Int64:
                break;

            case (PropertyTag.PropertyType) 8:
            case (PropertyTag.PropertyType) 9:
            case (PropertyTag.PropertyType) 12:
            case PropertyTag.PropertyType.Object:
            case (PropertyTag.PropertyType) 14:
            case (PropertyTag.PropertyType) 15:
            case (PropertyTag.PropertyType) 16:
            case (PropertyTag.PropertyType) 17:
            case (PropertyTag.PropertyType) 18:
            case (PropertyTag.PropertyType) 19:
                goto IL_7A;

            default:
                if (propertyType != PropertyTag.PropertyType.SysTime)
                {
                    if (propertyType != PropertyTag.PropertyType.ClassId)
                    {
                        goto IL_7A;
                    }
                    return(16);
                }
                break;
            }
            return(8);

IL_7A:
            throw new ArgumentOutOfRangeException(string.Format(CultureInfo.CurrentCulture, "Mapi property type '{0}' is not a supported fixed size property", new object[]
            {
                propType
            }), null);
        }
            protected static byte[] TrimStringEnd(PropertyTag.PropertyType propType, byte[] data)
            {
                int num = 0;

                switch (propType)
                {
                case PropertyTag.PropertyType.AnsiString:
                    goto IL_43;

                case PropertyTag.PropertyType.String:
                    break;

                default:
                    if (propType != PropertyTag.PropertyType.Unicode)
                    {
                        if (propType != PropertyTag.PropertyType.Ascii)
                        {
                            goto IL_54;
                        }
                        goto IL_43;
                    }
                    break;
                }
                if (data.Length >= 2 && data[data.Length - 1] == 0 && data[data.Length - 2] == 0)
                {
                    num = 2;
                    goto IL_54;
                }
                goto IL_54;
IL_43:
                if (data.Length >= 1 && data[data.Length - 1] == 0)
                {
                    num = 1;
                }
IL_54:
                if (num > 0)
                {
                    byte[] array = new byte[data.Length - num];
                    Array.Copy(data, array, array.Length);
                    data = array;
                }
                return(data);
            }