Esempio n. 1
0
 internal object GetUdtValue(object value, SqlMetaDataPriv metaData, bool returnDBNull)
 {
     if (returnDBNull && ADP.IsNull(value))
     {
         return DBNull.Value;
     }
     if (ADP.IsNull(value))
     {
         return metaData.udtType.InvokeMember("Null", BindingFlags.GetProperty | BindingFlags.Public | BindingFlags.Static, null, null, new object[0], CultureInfo.InvariantCulture);
     }
     MemoryStream s = new MemoryStream((byte[]) value);
     return SerializationHelperSql9.Deserialize(s, metaData.udtType);
 }
Esempio n. 2
0
 internal byte[] GetBytes(object o, out Format format, out int maxSize)
 {
     SqlUdtInfo infoFromType = AssemblyCache.GetInfoFromType(o.GetType());
     maxSize = infoFromType.MaxByteSize;
     format = infoFromType.SerializationFormat;
     if ((maxSize < -1) || (maxSize >= 0xffff))
     {
         throw new InvalidOperationException(o.GetType() + ": invalid Size");
     }
     using (MemoryStream stream = new MemoryStream((maxSize < 0) ? 0 : maxSize))
     {
         SerializationHelperSql9.Serialize(stream, o);
         return stream.ToArray();
     }
 }
Esempio n. 3
0
 internal static int GetLength(Object inst)
 {
     //caller should have allocated enough, based on MaxByteSize
     return(SerializationHelperSql9.SizeInBytes(inst));
 }
 internal static int GetLength(object inst)
 {
     return(SerializationHelperSql9.SizeInBytes(inst));
 }