本文整理汇总了C#中IAssemblyName.GetProperty方法的典型用法代码示例。如果您正苦于以下问题:C# IAssemblyName.GetProperty方法的具体用法?C# IAssemblyName.GetProperty怎么用?C# IAssemblyName.GetProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAssemblyName
的用法示例。
在下文中一共展示了IAssemblyName.GetProperty方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetStringProperty
internal string GetStringProperty(IAssemblyName name, ASM_NAME propertyName)
{
uint bufferSize = BufferLength;
IntPtr buffer = Marshal.AllocHGlobal((int)bufferSize);
name.GetProperty(propertyName, buffer, ref bufferSize);
var stringVaule = Marshal.PtrToStringUni(buffer, (int)bufferSize);
Marshal.FreeHGlobal(buffer);
return stringVaule;
}
示例2: GetDwordProperty
internal UInt32 GetDwordProperty(IAssemblyName name, ASM_NAME propertyName)
{
uint bufferSize = 512;
IntPtr buffer = Marshal.AllocHGlobal((int)bufferSize);
name.GetProperty(propertyName, buffer, ref bufferSize);
byte a = Marshal.ReadByte(buffer);
byte b = Marshal.ReadByte(buffer, 1);
byte c = Marshal.ReadByte(buffer);
byte d = Marshal.ReadByte(buffer, 1);
Marshal.FreeHGlobal(buffer);
return (UInt32)(a + (b << 8) + (c << 16) + (d << 24));
}
示例3: GetShortProperty
internal UInt16 GetShortProperty(IAssemblyName name, ASM_NAME propertyName)
{
uint bufferSize = 512;
IntPtr buffer = Marshal.AllocHGlobal((int)bufferSize);
name.GetProperty(propertyName, buffer, ref bufferSize);
byte low = Marshal.ReadByte(buffer);
byte high = Marshal.ReadByte(buffer, 1);
Marshal.FreeHGlobal(buffer);
return (UInt16)(low + (high << 8));
}
示例4: GetCulture
/// <summary>
/// Gets the culture.
/// </summary>
/// <param name="name">The name.</param>
/// <returns></returns>
public static CultureInfo GetCulture(IAssemblyName name)
{
uint bufferSize = 255;
IntPtr buffer = Marshal.AllocHGlobal((int) bufferSize);
name.GetProperty(ASM_NAME.ASM_NAME_CULTURE, buffer, ref bufferSize);
string result = Marshal.PtrToStringAuto(buffer);
Marshal.FreeHGlobal(buffer);
if (result != null)
{
return new CultureInfo(result);
}
return null;
}
示例5: GetByteArrayProperty
internal byte[] GetByteArrayProperty(IAssemblyName name, ASM_NAME propertyName)
{
uint bufferSize = 512;
IntPtr buffer = Marshal.AllocHGlobal((int)bufferSize);
name.GetProperty(propertyName, buffer, ref bufferSize);
byte[] result = new byte[bufferSize];
for (int i = 0; i < bufferSize; i++)
result[i] = Marshal.ReadByte(buffer, i);
Marshal.FreeHGlobal(buffer);
return result;
}
示例6: GetPublicKey
/// <summary>
/// Gets the public key.
/// </summary>
/// <param name="name">The name.</param>
/// <returns></returns>
public static byte[] GetPublicKey(IAssemblyName name)
{
uint bufferSize = 512;
IntPtr buffer = Marshal.AllocHGlobal((int) bufferSize);
name.GetProperty(ASM_NAME.ASM_NAME_PUBLIC_KEY, buffer, ref bufferSize);
var result = new byte[bufferSize];
for (int i = 0; i < bufferSize; i++)
result[i] = Marshal.ReadByte(buffer, i);
Marshal.FreeHGlobal(buffer);
return result;
}
示例7: GetPublicKeyToken
/// <summary>
/// Gets the public key token.
/// </summary>
/// <param name="name">The name.</param>
/// <returns></returns>
public static byte[] GetPublicKeyToken(IAssemblyName name)
{
var result = new byte[8];
uint bufferSize = 8;
IntPtr buffer = Marshal.AllocHGlobal((int) bufferSize);
name.GetProperty(ASM_NAME.ASM_NAME_PUBLIC_KEY_TOKEN, buffer, ref bufferSize);
for (int i = 0; i < 8; i++)
result[i] = Marshal.ReadByte(buffer, i);
Marshal.FreeHGlobal(buffer);
return result;
}
示例8: GetPropertyWord
internal static unsafe uint? GetPropertyWord(IAssemblyName nameObject, PropertyId propertyId)
{
uint result;
uint size = sizeof(uint);
int hr = nameObject.GetProperty(propertyId, &result, ref size);
if (hr != 0)
{
throw Marshal.GetExceptionForHR(hr);
}
if (size == 0)
{
return null;
}
return result;
}
示例9: IsKeyOrTokenEmpty
internal static unsafe bool IsKeyOrTokenEmpty(IAssemblyName nameObject, PropertyId propertyId)
{
Debug.Assert(propertyId == PropertyId.NULL_PUBLIC_KEY_TOKEN || propertyId == PropertyId.NULL_PUBLIC_KEY);
uint size = 0;
int hr = nameObject.GetProperty(propertyId, null, ref size);
return hr == 0;
}
示例10: GetPropertyBytes
internal static unsafe byte[] GetPropertyBytes(IAssemblyName nameObject, PropertyId propertyId)
{
int hr;
uint size = 0;
hr = nameObject.GetProperty(propertyId, null, ref size);
if (hr == 0)
{
return null;
}
if (hr != ERROR_INSUFFICIENT_BUFFER)
{
throw Marshal.GetExceptionForHR(hr);
}
byte[] data = new byte[(int)size];
fixed (byte* p = data)
{
hr = nameObject.GetProperty(propertyId, p, ref size);
if (hr != 0)
{
throw Marshal.GetExceptionForHR(hr);
}
}
return data;
}