本文整理汇总了C#中UnmanagedType类的典型用法代码示例。如果您正苦于以下问题:C# UnmanagedType类的具体用法?C# UnmanagedType怎么用?C# UnmanagedType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnmanagedType类属于命名空间,在下文中一共展示了UnmanagedType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UnmanagedMarshal
private UnmanagedMarshal(UnmanagedType unmanagedType, Guid guid, int numElem, UnmanagedType type)
{
this.m_unmanagedType = unmanagedType;
this.m_guid = guid;
this.m_numElem = numElem;
this.m_baseType = type;
}
示例2: DefineUnmanagedMarshal
public static UnmanagedMarshal DefineUnmanagedMarshal(UnmanagedType unmanagedType)
{
if (((unmanagedType == UnmanagedType.ByValTStr) || (unmanagedType == UnmanagedType.SafeArray)) || (((unmanagedType == UnmanagedType.CustomMarshaler) || (unmanagedType == UnmanagedType.ByValArray)) || (unmanagedType == UnmanagedType.LPArray)))
{
throw new ArgumentException(Environment.GetResourceString("Argument_NotASimpleNativeType"));
}
return new UnmanagedMarshal(unmanagedType, Guid.Empty, 0, (UnmanagedType) 0);
}
示例3: Main
public static int Main ()
{
UnmanagedType = (UnmanagedType) 0;
if (UnmanagedType != 0)
return 1;
return 0;
}
示例4: GetMarshalAsAttribute
private static CustomAttributeBuilder GetMarshalAsAttribute(UnmanagedType unmanagedType)
{
Type[] ctorParams = new Type[] { typeof(UnmanagedType) };
ConstructorInfo classCtorInfo = typeof(MarshalAsAttribute).GetConstructor(ctorParams);
CustomAttributeBuilder builder = new CustomAttributeBuilder(
classCtorInfo,
new object[] { unmanagedType });
return builder;
}
示例5: GetMarshalAs
internal static void GetMarshalAs(ConstArray nativeType, out UnmanagedType unmanagedType, out VarEnum safeArraySubType, out string safeArrayUserDefinedSubType, out UnmanagedType arraySubType, out int sizeParamIndex, out int sizeConst, out string marshalType, out string marshalCookie, out int iidParamIndex)
{
int num;
int num2;
int num3;
_GetMarshalAs(nativeType.Signature, nativeType.Length, out num, out num2, out safeArrayUserDefinedSubType, out num3, out sizeParamIndex, out sizeConst, out marshalType, out marshalCookie, out iidParamIndex);
unmanagedType = (UnmanagedType) num;
safeArraySubType = (VarEnum) num2;
arraySubType = (UnmanagedType) num3;
}
示例6: DefineUnmanagedMarshal
/******************************
[System.Runtime.InteropServices.ComVisible(true)]
* public static constructors. You can only construct
* UnmanagedMarshal using these static constructors.
******************************/
public static UnmanagedMarshal DefineUnmanagedMarshal(UnmanagedType unmanagedType)
{
if (unmanagedType == UnmanagedType.ByValTStr ||
#if FEATURE_COMINTEROP
unmanagedType == UnmanagedType.SafeArray ||
unmanagedType == UnmanagedType.CustomMarshaler ||
#endif //FEATURE_COMINTEROP
unmanagedType == UnmanagedType.ByValArray ||
unmanagedType == UnmanagedType.LPArray)
{
// not a simple native marshal
throw new ArgumentException(Environment.GetResourceString("Argument_NotASimpleNativeType"));
}
return new UnmanagedMarshal(unmanagedType, Guid.Empty, 0, (UnmanagedType) 0);
}
示例7: Verify
private int Verify(UnmanagedType umt, int expectedValue)
{
Console.WriteLine("Verify " + umt);
try
{
if (expectedValue == (int)umt)
return 0;
Console.WriteLine("Error! Actual: {0}, Expected: {1}", (int)umt, expectedValue);
}
catch (Exception e)
{
Console.WriteLine("UnexpectedEception: " + e);
}
return 1;
}
示例8: GetUnmanagedType
public static Type GetUnmanagedType(UnmanagedType type)
{
switch (type)
{
case UnmanagedType.I1: return typeof(bool);
case UnmanagedType.U1: return typeof(bool);
case UnmanagedType.I2: return typeof(short);
case UnmanagedType.I4: return typeof(int);
case UnmanagedType.I8: return typeof(long);
case UnmanagedType.R4: return typeof(float);
case UnmanagedType.R8: return typeof(double);
case UnmanagedType.Currency: return typeof(double);
case UnmanagedType.ByValTStr: return typeof(char);
default: throw new NotImplementedException();
}
}
示例9: DefineSafeArray
public static UnmanagedMarshal DefineSafeArray(UnmanagedType elemType)
{
return new UnmanagedMarshal(UnmanagedType.SafeArray, Guid.Empty, 0, elemType);
}
示例10: GetMarshalAs
[System.Security.SecurityCritical] // auto-generated
internal static void GetMarshalAs(ConstArray nativeType,
out UnmanagedType unmanagedType, out VarEnum safeArraySubType, out string safeArrayUserDefinedSubType,
out UnmanagedType arraySubType, out int sizeParamIndex, out int sizeConst, out string marshalType, out string marshalCookie,
out int iidParamIndex)
{
int _unmanagedType, _safeArraySubType, _arraySubType;
_GetMarshalAs(nativeType.Signature, (int)nativeType.Length,
out _unmanagedType, out _safeArraySubType, out safeArrayUserDefinedSubType,
out _arraySubType, out sizeParamIndex, out sizeConst, out marshalType, out marshalCookie,
out iidParamIndex);
unmanagedType = (UnmanagedType)_unmanagedType;
safeArraySubType = (VarEnum)_safeArraySubType;
arraySubType = (UnmanagedType)_arraySubType;
}
示例11: UnmanagedMarshal
// Define a simple unmanaged marshalling behaviour.
public static UnmanagedMarshal DefineUnmanagedMarshal
(UnmanagedType unmanagedType)
{
// Must be a simple unmanaged type.
if(unmanagedType == UnmanagedType.ByValArray ||
unmanagedType == UnmanagedType.ByValTStr ||
unmanagedType == UnmanagedType.LPArray ||
unmanagedType == UnmanagedType.SafeArray ||
unmanagedType == UnmanagedType.CustomMarshaler)
{
throw new ArgumentException
(_("Emit_NotSimpleUnmanagedType"));
}
return new UnmanagedMarshal(unmanagedType);
}
示例12: UnmanagedMarshal
#pragma warning restore 169, 414
private UnmanagedMarshal (UnmanagedType maint, int cnt) {
count = cnt;
t = maint;
tbase = maint;
}
示例13: DefineLPArray
public static UnmanagedMarshal DefineLPArray( UnmanagedType elemType) {
return new UnmanagedMarshal (UnmanagedType.LPArray, elemType);
}
示例14: GetTypeNameForUnmanagedType
public static TypeName GetTypeNameForUnmanagedType(UnmanagedType unmngType)
{
return primitiveUnmanagedToNameMap[(int)unmngType];
}
示例15: MarshalingToCharSet
private static CharSet? MarshalingToCharSet(UnmanagedType? type)
{
if (type == null)
{
return null;
}
switch (type)
{
case UnmanagedType.AnsiBStr:
case UnmanagedType.LPStr:
case UnmanagedType.VBByRefStr:
return CharSet.Ansi;
case UnmanagedType.BStr:
case UnmanagedType.LPWStr:
return CharSet.Unicode;
case UnmanagedType.ByValTStr:
case UnmanagedType.LPTStr:
case UnmanagedType.TBStr:
return CharSet.Auto;
default:
return CharSet.None;
}
}