internal static object GetDefaultValue(ref PARAMDESC paramdesc) { if ((paramdesc.wParamFlags & PARAMFLAG.PARAMFLAG_FHASDEFAULT) == 0) { return(DBNull.Value); } PARAMDESCEX varValue = (PARAMDESCEX)Marshal.PtrToStructure(paramdesc.lpVarValue, typeof(PARAMDESCEX)); if (varValue._cByte != (ulong)(Marshal.SizeOf((typeof(PARAMDESCEX))))) { throw Error.DefaultValueCannotBeRead(); } return(varValue._varDefaultValue.ToObject()); }
internal static object GetDefaultValue(ref PARAMDESC paramdesc) { if ((paramdesc.wParamFlags & PARAMFLAG.PARAMFLAG_FHASDEFAULT) == 0) { return DBNull.Value; } PARAMDESCEX varValue = (PARAMDESCEX)Marshal.PtrToStructure(paramdesc.lpVarValue, typeof(PARAMDESCEX)); if (varValue._cByte != (ulong)(Marshal.SizeOf((typeof(PARAMDESCEX))))) { return DBNull.Value; } try { // this may fail for various reasons such as no managed representation for native type return varValue._varDefaultValue.ToObject(); } catch (Exception) { return DBNull.Value; } }
internal static object GetDefaultValue(ref PARAMDESC paramdesc) { if ((paramdesc.wParamFlags & PARAMFLAG.PARAMFLAG_FHASDEFAULT) == 0) { return DBNull.Value; } PARAMDESCEX varValue = (PARAMDESCEX)Marshal.PtrToStructure(paramdesc.lpVarValue, typeof(PARAMDESCEX)); if (varValue._cByte != (ulong)(Marshal.SizeOf((typeof(PARAMDESCEX))))) { throw Error.DefaultValueCannotBeRead(); } return varValue._varDefaultValue.ToObject(); }