本文整理汇总了C#中System.UIntPtr.ToUInt64方法的典型用法代码示例。如果您正苦于以下问题:C# UIntPtr.ToUInt64方法的具体用法?C# UIntPtr.ToUInt64怎么用?C# UIntPtr.ToUInt64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UIntPtr
的用法示例。
在下文中一共展示了UIntPtr.ToUInt64方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDateTime
public void SetDateTime (OciHandle handle, OciErrorHandle errorHandle,
short year, byte month, byte day,
byte hour, byte min, byte sec, uint fsec, string timezone)
{
// Get size of buffer
ulong rsize = 0;
UIntPtr rsizep = new UIntPtr (rsize);
int status = OciCalls.OCIUnicodeToCharSet (handle, null, timezone, ref rsizep);
// Fill buffer
rsize = rsizep.ToUInt64 ();
byte[] bytes = new byte[rsize];
if (status == 0 && rsize > 0)
OciCalls.OCIUnicodeToCharSet (handle, bytes, timezone, ref rsizep);
if (fsec > 0)
fsec = fsec * 1000000;
uint timezoneSize = (uint) bytes.Length;
OciCalls.OCIDateTimeConstruct (handle,
errorHandle, this.Handle,
year, month, day,
hour, min, sec, fsec,
bytes, timezoneSize);
//uint valid = 0;
//int result = OciCalls.OCIDateTimeCheck (handle,
// errorHandle, this.Handle, out valid);
}
示例2: GetElement
private NativeScoreEntry GetElement(UIntPtr index)
{
if (index.ToUInt64() >= Length().ToUInt64())
{
throw new ArgumentOutOfRangeException();
}
return new NativeScoreEntry(
ScorePage.ScorePage_Entries_GetElement(SelfPtr(), index));
}
示例3: InternalOnDataReceived
internal static void InternalOnDataReceived(
IntPtr room, IntPtr participant, IntPtr data, UIntPtr dataLength, bool isReliable,
IntPtr userData)
{
GooglePlayGames.OurUtils.Logger.d("Entering InternalOnDataReceived: " + userData.ToInt64());
var callback = Callbacks.IntPtrToPermanentCallback
<Action<NativeRealTimeRoom, MultiplayerParticipant, byte[], bool>>(userData);
using (var nativeRoom = NativeRealTimeRoom.FromPointer(room))
{
using (var nativeParticipant = MultiplayerParticipant.FromPointer(participant))
{
if (callback == null)
{
return;
}
byte[] convertedData = null;
if (dataLength.ToUInt64() != 0)
{
convertedData = new byte[dataLength.ToUInt32()];
Marshal.Copy(data, convertedData, 0, (int)dataLength.ToUInt32());
}
try
{
callback(nativeRoom, nativeParticipant, convertedData, isReliable);
}
catch (Exception e)
{
GooglePlayGames.OurUtils.Logger.e("Error encountered executing InternalOnDataReceived. " +
"Smothering to avoid passing exception into Native: " + e);
}
}
}
}
示例4: Create
public IDebuggerValue Create(UIntPtr value) {
return debugger.Dispatcher.UI(() => {
var res = CreateNoConstructorUI(appDomain.UIntPtr).CorValue;
Keep(res);
Debug.Assert(res.DereferencedValue != null && res.DereferencedValue.BoxedValue != null);
res = res.DereferencedValue.BoxedValue;
if (value != UIntPtr.Zero) {
var bytes = UIntPtr.Size == 4 ?
BitConverter.GetBytes(value.ToUInt32()) :
BitConverter.GetBytes(value.ToUInt64());
res.WriteGenericValue(bytes);
}
return new DebuggerValue(debugger, res);
});
}
示例5: Write
private static unsafe int Write(
ref GitOid oid,
IntPtr backend,
IntPtr data,
UIntPtr len,
Core.GitObjectType type)
{
OdbBackend odbBackend = GCHandle.FromIntPtr(Marshal.ReadIntPtr(backend, GitOdbBackend.GCHandleOffset)).Target as OdbBackend;
ObjectType objectType = type.ToObjectType();
if (odbBackend != null &&
len.ToUInt64() < long.MaxValue)
{
try
{
using (UnmanagedMemoryStream stream = new UnmanagedMemoryStream((byte*)data, (long)len.ToUInt64()))
{
byte[] finalOid;
int toReturn = odbBackend.Write(oid.Id, stream, (long)len.ToUInt64(), objectType, out finalOid);
if (0 == toReturn)
{
oid.Id = finalOid;
}
return toReturn;
}
}
catch (Exception ex)
{
Proxy.giterr_set_str(GitErrorCategory.Odb, ex);
}
}
return (int)GitErrorCode.Error;
}
示例6: Read
private unsafe static int Read(
IntPtr stream,
IntPtr buffer,
UIntPtr buf_size,
out UIntPtr bytes_read)
{
bytes_read = UIntPtr.Zero;
SmartSubtransportStream transportStream = GCHandle.FromIntPtr(Marshal.ReadIntPtr(stream, GitSmartSubtransportStream.GCHandleOffset)).Target as SmartSubtransportStream;
if (transportStream != null &&
buf_size.ToUInt64() < (ulong)long.MaxValue)
{
using (UnmanagedMemoryStream memoryStream = new UnmanagedMemoryStream((byte*)buffer, 0, (long)buf_size.ToUInt64(), FileAccess.ReadWrite))
{
try
{
long longBytesRead;
int toReturn = transportStream.Read(memoryStream, (long)buf_size.ToUInt64(), out longBytesRead);
bytes_read = new UIntPtr((ulong)Math.Max(0, longBytesRead));
return toReturn;
}
catch (Exception ex)
{
Proxy.giterr_set_str(GitErrorCategory.Net, ex);
}
}
}
return (int)GitErrorCode.Error;
}
示例7: GetOracleVersion
internal string GetOracleVersion ()
{
byte[] buffer = new Byte[256];
uint bufflen = (uint) buffer.Length;
IntPtr sh = oci.ServiceContext;
IntPtr eh = oci.ErrorHandle;
OciCalls.OCIServerVersion (sh, eh, ref buffer, bufflen, OciHandleType.Service);
// Get length of returned string
ulong rsize = 0;
UIntPtr rsizep = new UIntPtr (rsize);
IntPtr env = oci.Environment;
OciCalls.OCICharSetToUnicode (env, null, buffer, ref rsizep);
// Get string
rsize = rsizep.ToUInt64 ();
StringBuilder ret = new StringBuilder((int)rsize);
OciCalls.OCICharSetToUnicode (env, ret, buffer, ref rsizep);
return ret.ToString ();
}
示例8: OnAiFileSeekProc
private ReturnCode OnAiFileSeekProc(IntPtr file, UIntPtr offset, Origin seekOrigin)
{
if(m_filePtr != file)
return ReturnCode.Failure;
ReturnCode code = ReturnCode.Failure;
try
{
code = Seek((long) offset.ToUInt64(), seekOrigin);
}
catch(Exception) { /*Assimp will report an IO error*/ }
return code;
}
示例9: ParseScriptText
public override void ParseScriptText(string code, string itemName, object context, string delimiter, UIntPtr sourceContext, uint startingLineNumber, ScriptTextFlags flags, IntPtr pVarResult, out EXCEPINFO excepInfo)
{
activeScriptParse.ParseScriptText(code, itemName, context, delimiter, sourceContext.ToUInt64(), startingLineNumber, flags, pVarResult, out excepInfo);
}
示例10: HandleError
public static OciErrorInfo HandleError (OciHandle hwnd, int status)
{
OciErrorInfo info;
info.ErrorCode = status;
info.ErrorMessage = OciGlue.ReturnCodeToString (status);
if (status == OciGlue.OCI_ERROR || status == OciGlue.OCI_SUCCESS_WITH_INFO) {
OciHandle h = hwnd;
if (h == null)
throw new Exception ("Internal driver error: handle is null.");
ulong errbufSize = 4096;
UIntPtr errbufSizep = new UIntPtr (errbufSize);
IntPtr errbuf = OciCalls.AllocateClear ((int)errbufSize);
OciCalls.OCIErrorGet (hwnd,
1,
IntPtr.Zero,
out info.ErrorCode,
errbuf,
(uint) errbufSize,
OciHandleType.Error);
byte[] bytea = new byte[errbufSize];
Marshal.Copy (errbuf, bytea, 0, (int)errbufSize);
errbufSize = 0;
// first call to OCICharSetToUnicode gets the size
OciCalls.OCICharSetToUnicode (h, null, bytea, ref errbufSizep);
errbufSize = errbufSizep.ToUInt64 ();
StringBuilder str = new StringBuilder ((int)errbufSize);
// second call to OCICharSetToUnicode gets the string
OciCalls.OCICharSetToUnicode (h, str, bytea, ref errbufSizep);
string errmsg = String.Empty;
if (errbufSize > 0) {
errmsg = str.ToString ();
info.ErrorMessage = String.Copy (errmsg);
}
Marshal.FreeHGlobal (errbuf);
}
return info;
}
示例11: GetOutValue
private void GetOutValue (OracleCommand cmd)
{
// used to update the parameter value
// for Output, the output of InputOutput, and Return parameters
value = DBNull.Value;
if (indicator == -1)
return;
ulong rsize = 0;
UIntPtr rsizep = new UIntPtr (rsize);
IntPtr env = IntPtr.Zero;
StringBuilder ret = null;
// FIXME: redo all types - see how Char, Number, and Date are done
// here and in Bind()
switch (ociType) {
case OciDataType.VarChar2:
case OciDataType.String:
case OciDataType.VarChar:
case OciDataType.Char:
case OciDataType.CharZ:
case OciDataType.OciString:
case OciDataType.RowIdDescriptor:
// Get length of returned string
rsize = 0;
env = cmd.Connection.Environment;
OciCalls.OCICharSetToUnicode (env, null, bytes, ref rsizep);
// Get string
rsize = rsizep.ToUInt64 ();
ret = new StringBuilder((int)rsize);
OciCalls.OCICharSetToUnicode (env, ret, bytes, ref rsizep);
value = ret.ToString ();
break;
case OciDataType.Long:
case OciDataType.LongVarChar:
int longSize = 0;
if (BitConverter.IsLittleEndian)
longSize = BitConverter.ToInt32 (new byte [] {bytes [0], bytes [1], bytes [2], bytes [3]}, 0);
else
longSize = BitConverter.ToInt32 (new byte [] {bytes [3], bytes [2], bytes [1], bytes [0]}, 0);
ASCIIEncoding encoding = new ASCIIEncoding ();
value = encoding.GetString (bytes, 4, longSize);
encoding = null;
break;
case OciDataType.LongRaw:
case OciDataType.LongVarRaw:
int longrawSize = 0;
if (BitConverter.IsLittleEndian)
longrawSize = BitConverter.ToInt32 (new byte [] {bytes [0], bytes [1], bytes [2], bytes [3]}, 0);
else
longrawSize = BitConverter.ToInt32 (new byte [] {bytes [3], bytes [2], bytes [1], bytes [0]}, 0);
byte[] longraw_buffer = new byte [longrawSize];
Array.ConstrainedCopy (bytes, 4, longraw_buffer, 0, longrawSize);
value = longraw_buffer;
break;
case OciDataType.Raw:
case OciDataType.VarRaw:
int rawSize = 0;
if (BitConverter.IsLittleEndian)
rawSize = (int) BitConverter.ToInt16 (new byte [] {bytes [0], bytes [1]}, 0);
else
rawSize = (int) BitConverter.ToInt16 (new byte [] {bytes [1], bytes [0]}, 0);
byte[] raw_buffer = new byte [rawSize];
Array.ConstrainedCopy (bytes, 2, raw_buffer, 0, rawSize);
value = raw_buffer;
break;
case OciDataType.Integer:
case OciDataType.Number:
case OciDataType.Float:
rsize = 0;
env = cmd.Connection.Environment;
OciCalls.OCICharSetToUnicode (env, null, bytes, ref rsizep);
// Get string
rsize = rsizep.ToUInt64 ();
ret = new StringBuilder((int)rsize);
OciCalls.OCICharSetToUnicode (env, ret, bytes, ref rsizep);
// if not empty, parse string as a decimal using session format
if (ret.Length > 0) {
switch (dbType) {
case DbType.UInt16:
value = UInt16.Parse (ret.ToString (), cmd.Connection.SessionFormatProvider);
break;
case DbType.UInt32:
value = UInt32.Parse (ret.ToString (), cmd.Connection.SessionFormatProvider);
break;
case DbType.Int16:
value = Int16.Parse (ret.ToString (), cmd.Connection.SessionFormatProvider);
break;
case DbType.Int32:
value = Int32.Parse (ret.ToString (), cmd.Connection.SessionFormatProvider);
break;
default:
//.........这里部分代码省略.........
示例12: VerifyPointer
private static void VerifyPointer(UIntPtr ptr, ulong expected)
{
Assert.Equal(expected, ptr.ToUInt64());
uint expected32 = (uint)expected;
if (expected32 != expected)
{
Assert.Throws<OverflowException>(() => ptr.ToUInt32());
return;
}
Assert.Equal(expected32, ptr.ToUInt32());
Assert.Equal(expected.ToString(), ptr.ToString());
Assert.Equal(ptr, new UIntPtr(expected));
Assert.True(ptr == new UIntPtr(expected));
Assert.False(ptr != new UIntPtr(expected));
Assert.NotEqual(ptr, new UIntPtr(expected + 1));
Assert.False(ptr == new UIntPtr(expected + 1));
Assert.True(ptr != new UIntPtr(expected + 1));
}
示例13: GetBooleanArrayFromPtr
private static bool[] GetBooleanArrayFromPtr(IntPtr ptr, UIntPtr size)
{
int iSize = (int)size.ToUInt64();
bool[] bArr = new bool[iSize];
for (int i = 0; i < iSize; i++)
{
IntPtr data = new IntPtr(ptr.ToInt64() + sizeof(int) * i);
bArr[i] = (int)Marshal.PtrToStructure(data, typeof(int)) != 0;
}
return bArr;
}
示例14: ReadUTF8StringToByteArray
//Must be null terminated
internal static byte[] ReadUTF8StringToByteArray(IntPtr str, UIntPtr size)
{
int iSize = (int)size.ToUInt64();
byte[] data = new byte[iSize];
Marshal.Copy(str, data, 0, iSize);
return data;
}
示例15: GetGpuMemInfo
/// <summary>
/// Get the free and total amount of GPU memory on the current devide
/// </summary>
/// <param name="free">The free amount of GPU memory</param>
/// <param name="total">The total amount of GPU memory</param>
public static void GetGpuMemInfo(out ulong free, out ulong total)
{
UIntPtr f = new UIntPtr(), t = new UIntPtr();
getGpuMemInfo(ref f, ref t);
free = f.ToUInt64();
total = t.ToUInt64();
}