NormObject Refactor
* Updated NormObjectGetInfo to use byte array * Updated designpull/85/head
parent
022e1204ca
commit
32c3eb5239
|
|
@ -91,7 +91,7 @@ class NormApi <<static>> {
|
||||||
+ {static} <<extern>> NormObjectGetType(objectHandle:long) : NormObjectType
|
+ {static} <<extern>> NormObjectGetType(objectHandle:long) : NormObjectType
|
||||||
+ {static} <<extern>> NormObjectHasInfo(objectHandle:long) : bool
|
+ {static} <<extern>> NormObjectHasInfo(objectHandle:long) : bool
|
||||||
+ {static} <<extern>> NormObjectGetInfoLength(objectHandle:long) : int
|
+ {static} <<extern>> NormObjectGetInfoLength(objectHandle:long) : int
|
||||||
+ {static} <<extern>> NormObjectGetInfo(objectHandle:long, buffer:nint, bufferLen:int) : int
|
+ {static} <<extern>> NormObjectGetInfo(objectHandle:long, buffer:byte[], bufferLen:int) : int
|
||||||
+ {static} <<extern>> NormObjectGetSize(objectHandle:long) : int
|
+ {static} <<extern>> NormObjectGetSize(objectHandle:long) : int
|
||||||
+ {static} <<extern>> NormObjectGetBytesPending(objectHandle:long) : long
|
+ {static} <<extern>> NormObjectGetBytesPending(objectHandle:long) : long
|
||||||
+ {static} <<extern>> NormObjectCancel(objectHandle:long) : void
|
+ {static} <<extern>> NormObjectCancel(objectHandle:long) : void
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
class NormFile {
|
class NormFile {
|
||||||
+ <<const>> FILENAME_MAX : int = 260
|
+ <<const>> FILENAME_MAX : int = 260
|
||||||
<<internal>> NormFile(handle:long)
|
<<internal>> NormFile(handle:long)
|
||||||
+ Name : string <<get>>
|
+ <<unsafe>> Name : string <<get>>
|
||||||
+ Rename(filePath:string) : void
|
+ Rename(filePath:string) : void
|
||||||
}
|
}
|
||||||
NormObject <|-- NormFile
|
NormObject <|-- NormFile
|
||||||
|
|
|
||||||
|
|
@ -961,7 +961,7 @@ namespace Mil.Navy.Nrl.Norm
|
||||||
/// function can be used to determine the length of NORM_INFO content for the object even if a NULL buffer value and
|
/// function can be used to determine the length of NORM_INFO content for the object even if a NULL buffer value and
|
||||||
/// zero bufferLen is provided. A zero value is returned if NORM_INFO content has not yet been received (or is nonexistent) for the specified object.</returns>
|
/// zero bufferLen is provided. A zero value is returned if NORM_INFO content has not yet been received (or is nonexistent) for the specified object.</returns>
|
||||||
[DllImport(NORM_LIBRARY)]
|
[DllImport(NORM_LIBRARY)]
|
||||||
public static extern int NormObjectGetInfo(long objectHandle, nint buffer, int bufferLen);
|
public static extern int NormObjectGetInfo(long objectHandle, [Out] byte[] buffer, int bufferLen);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This function can be used to determine the size (in bytes) of the transport object specified by the objectHandle parameter.
|
/// This function can be used to determine the size (in bytes) of the transport object specified by the objectHandle parameter.
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
using System.Runtime.InteropServices;
|
namespace Mil.Navy.Nrl.Norm
|
||||||
|
|
||||||
namespace Mil.Navy.Nrl.Norm
|
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The base transport object.
|
/// The base transport object.
|
||||||
|
|
@ -44,17 +42,7 @@ namespace Mil.Navy.Nrl.Norm
|
||||||
|
|
||||||
var length = NormObjectGetInfoLength(_handle);
|
var length = NormObjectGetInfoLength(_handle);
|
||||||
var buffer = new byte[length];
|
var buffer = new byte[length];
|
||||||
var bufferHandle = GCHandle.Alloc(buffer, GCHandleType.Pinned);
|
NormObjectGetInfo(_handle, buffer, length);
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var bufferPtr = bufferHandle.AddrOfPinnedObject();
|
|
||||||
NormObjectGetInfo(_handle, bufferPtr, length);
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
bufferHandle.Free();
|
|
||||||
}
|
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue