internal static int SizeOfValue(StreamPropertyType propType, object value) { int num = 0; if (propType <= (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List)) { switch (propType) { case StreamPropertyType.Null: return(num); case StreamPropertyType.Bool: case StreamPropertyType.Byte: case StreamPropertyType.SByte: return(num + 1); case StreamPropertyType.Int16: case StreamPropertyType.UInt16: return(num + 2); case StreamPropertyType.Int32: case StreamPropertyType.UInt32: case StreamPropertyType.Single: case StreamPropertyType.RecipientType: return(num + 4); case StreamPropertyType.Int64: case StreamPropertyType.UInt64: case StreamPropertyType.Double: case StreamPropertyType.DateTime: return(num + 8); case StreamPropertyType.Decimal: case StreamPropertyType.Guid: case StreamPropertyType.IPAddress: return(num + 16); case StreamPropertyType.Char: return(num + PropertyStreamWriter.SizeOfValue(StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array, new char[] { (char)value })); case StreamPropertyType.String: { num += 4; string text = (string)value; if (!string.IsNullOrEmpty(text)) { return(num + Encoding.UTF8.GetByteCount(text)); } return(num); } case StreamPropertyType.IPEndPoint: return(num + 18); case StreamPropertyType.RoutingAddress: case StreamPropertyType.ADObjectId: goto IL_48F; default: switch (propType) { case StreamPropertyType.Bool | StreamPropertyType.Array: case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array: case StreamPropertyType.SByte | StreamPropertyType.Array: return(num + (4 + ((Array)value).Length)); case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.Array: case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.Array: return(num + (4 + ((Array)value).Length * 2)); case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.Array: case StreamPropertyType.UInt32 | StreamPropertyType.Array: case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.Array: return(num + (4 + ((Array)value).Length * 4)); case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.Array: case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.Array: case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array: case StreamPropertyType.DateTime | StreamPropertyType.Array: return(num + (4 + ((Array)value).Length * 8)); case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array: case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.Array: case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.Array: return(num + (4 + ((Array)value).Length * 16)); case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array: num += 4; if (value != null) { return(num + Encoding.UTF8.GetByteCount((char[])value)); } return(num); case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.Array: { num += 4; string[] array = (string[])value; for (int i = 0; i < array.Length; i++) { num += PropertyStreamWriter.SizeOfValue(StreamPropertyType.String, array[i]); } return(num); } case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.Array: return(num + (4 + ((Array)value).Length * 18)); default: switch (propType) { case StreamPropertyType.Bool | StreamPropertyType.List: case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.List: case StreamPropertyType.SByte | StreamPropertyType.List: break; case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.List: case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.List: goto IL_308; case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.List: case StreamPropertyType.UInt32 | StreamPropertyType.List: case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.List: goto IL_31F; case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.List: case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.List: case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List: case StreamPropertyType.DateTime | StreamPropertyType.List: goto IL_336; case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List: case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.List: case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List: goto IL_34D; case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List: { List <char> list = (List <char>)value; char[] chars = list.ToArray(); num += 4; if (value != null) { return(num + Encoding.UTF8.GetByteCount(chars)); } return(num); } case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.List: goto IL_3DB; case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.List: goto IL_365; default: goto IL_48F; } break; } break; } } else { if (propType == (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array | StreamPropertyType.List)) { num += 4; List <byte[]> list2 = (List <byte[]>)value; for (int j = 0; j < list2.Count; j++) { num += PropertyStreamWriter.SizeOfValue(propType & ~StreamPropertyType.List, list2[j]); } return(num); } switch (propType) { case StreamPropertyType.Bool | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty: break; case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty: goto IL_308; case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty: goto IL_31F; case StreamPropertyType.Null | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.Bool | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty: goto IL_336; case StreamPropertyType.Null | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.Null | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty: case StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty: goto IL_34D; case StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty: { MultiValuedProperty <char> multiValuedProperty = (MultiValuedProperty <char>)value; char[] chars2 = multiValuedProperty.ToArray(); num += 4; if (value != null) { return(num + Encoding.UTF8.GetByteCount(chars2)); } return(num); } case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.SByte | StreamPropertyType.UInt32 | StreamPropertyType.MultiValuedProperty: goto IL_3DB; case StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.DateTime | StreamPropertyType.MultiValuedProperty: goto IL_365; default: { if (propType != (StreamPropertyType.Null | StreamPropertyType.Bool | StreamPropertyType.Array | StreamPropertyType.MultiValuedProperty)) { goto IL_48F; } num += 4; MultiValuedProperty <byte[]> multiValuedProperty2 = (MultiValuedProperty <byte[]>)value; for (int k = 0; k < multiValuedProperty2.Count; k++) { num += PropertyStreamWriter.SizeOfValue(propType & ~StreamPropertyType.MultiValuedProperty, multiValuedProperty2[k]); } return(num); } } } return(num + (4 + ((ICollection)value).Count)); IL_308: return(num + (4 + ((ICollection)value).Count * 2)); IL_31F: return(num + (4 + ((ICollection)value).Count * 4)); IL_336: return(num + (4 + ((ICollection)value).Count * 8)); IL_34D: return(num + (4 + ((ICollection)value).Count * 16)); IL_365: return(num + (4 + ((ICollection)value).Count * 18)); IL_3DB: num += 4; IList <string> list3 = (IList <string>)value; for (int l = 0; l < list3.Count; l++) { num += PropertyStreamWriter.SizeOfValue(StreamPropertyType.String, list3[l]); } return(num); IL_48F: throw new InvalidOperationException(string.Format("Data type {0} is unknown", propType)); }
public static int SizeOf(StreamPropertyType propType, object value) { return(2 + PropertyStreamWriter.SizeOfValue(propType, value)); }