本文整理汇总了C#中CharSet类的典型用法代码示例。如果您正苦于以下问题:C# CharSet类的具体用法?C# CharSet怎么用?C# CharSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CharSet类属于命名空间,在下文中一共展示了CharSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: StructLayoutAttribute
internal StructLayoutAttribute(LayoutKind layoutKind, int pack, int size, CharSet charSet)
{
this._val = layoutKind;
this.Pack = pack;
this.Size = size;
this.CharSet = charSet;
}
示例2: CharClass
/// <summary>
/// 初始化 <see cref="Cyjb.Compilers.Lexers.CharClass"/> 类的新实例。
/// </summary>
public CharClass()
{
CharSet defaultSet = new CharSet();
for (int i = 0; i <= char.MaxValue; i++)
{
defaultSet.Add((char)i);
}
charClassList = new List<CharSet>();
charClassList.Add(defaultSet);
}
示例3: IsSuperSetOf
public bool IsSuperSetOf(CharSet rhs)
{
Contract.Requires(rhs != null);
foreach (char ch in rhs.m_chars)
{
if (m_chars.IndexOf(ch) < 0)
return false;
}
return true;
}
示例4: AutoTile
public static char[,] AutoTile(char[,] data, CharSet charSet)
{
var width = data.GetLength(0);
var height = data.GetLength(1);
var tiles = new char[width, height];
for(var x = 0; x < width; ++x) {
for(var y = 0; y < height; ++y) {
tiles[x, y] = GetTile(data, charSet, x, y);
}
}
return tiles;
}
示例5: GetText
public static unsafe string GetText(IntPtr ptr, CharSet charSet)
{
switch (charSet)
{
case CharSet.None:
case CharSet.Ansi:
return Marshal.PtrToStringAnsi(((void*) ptr).pszText);
case CharSet.Unicode:
return Marshal.PtrToStringUni(((void*) ptr).pszText);
}
return Marshal.PtrToStringAuto(((void*) ptr).pszText);
}
示例6: DynamicDllFunctionInvoke
public static object DynamicDllFunctionInvoke(
string dllPath,
string entryPoint,
MethodAttributes methodAttr,
CallingConvention nativeCallConv,
CharSet nativeCharSet,
Type returnType,
Type[] parameterTypes,
object[] parameterValues
)
{
string dllName = Path.GetFileNameWithoutExtension(dllPath);
// ����һ����̬����(assembly)��ģ��(module)
AssemblyName assemblyName = new AssemblyName();
assemblyName.Name = string.Format("A{0}{1}",
dllName,
Guid.NewGuid().ToString( "N" )
);
AssemblyBuilder dynamicAssembly =
AppDomain.CurrentDomain.DefineDynamicAssembly(
assemblyName, AssemblyBuilderAccess.Run);
ModuleBuilder dynamicModule =
dynamicAssembly.DefineDynamicModule(
string.Format("M{0}{1}",
dllName,
Guid.NewGuid().ToString("N"))
);
// ʹ��ָ������Ϣ����ƽ̨����ǩ��
MethodBuilder dynamicMethod =
dynamicModule.DefinePInvokeMethod(
entryPoint,
dllPath,
methodAttr,
CallingConventions.Standard,
returnType,
parameterTypes,
nativeCallConv,
nativeCharSet
);
// ��������
dynamicModule.CreateGlobalFunctions();
// ���ƽ̨���õķ���
MethodInfo methodInfo =
dynamicModule.GetMethod(entryPoint, parameterTypes);
// ���÷��йܺ�������÷��صĽ��
object result = methodInfo.Invoke(null, parameterValues);
return result;
}
示例7: GetText
public static string GetText(IntPtr ptr, CharSet charSet)
{
IntPtr ptr2 = Marshal.ReadIntPtr(ptr, Marshal.SizeOf(typeof(NMHDR)));
if (ptr2 == IntPtr.Zero)
{
NMTTDISPINFO nmttdispinfo = (NMTTDISPINFO) Marshal.PtrToStructure(ptr, typeof(NMTTDISPINFO));
return nmttdispinfo.szText;
}
switch (charSet)
{
case CharSet.None:
case CharSet.Ansi:
return Marshal.PtrToStringAnsi(ptr2);
case CharSet.Unicode:
return Marshal.PtrToStringUni(ptr2);
}
return Marshal.PtrToStringAuto(ptr2);
}
示例8: GetTile
public static char GetTile(char[,] data, CharSet charSet, int x, int y)
{
if(data[x, y] == '-') {
return charSet.HorizontalLine;
} else if(data[x, y] == '|') {
return charSet.VerticalLine;
} else if(data[x, y] == ' ') {
return charSet.Empty;
} else {
var top = GetCharAt(data, x, y - 1) != ' ';
var bottom = GetCharAt(data, x, y + 1) != ' ';
var left = GetCharAt(data, x - 1, y) != ' ';
var right = GetCharAt(data, x + 1, y) != ' ';
if(top && bottom && left && right) {
return charSet.Cross;
} else if(!top && bottom && left && right) {
return charSet.STee;
} else if(top && !bottom && left && right) {
return charSet.NTee;
} else if(top && bottom && !left && right) {
return charSet.ETee;
} else if(top && bottom && left && !right) {
return charSet.WTee;
} else if(!top && !bottom && left && right) {
return charSet.HorizontalLine;
} else if(top && bottom && !left && !right) {
return charSet.VerticalLine;
} else if(!top && bottom && !left && right) {
return charSet.NWCorner;
} else if(!top && bottom && left && !right) {
return charSet.NECorner;
} else if(top && !bottom && !left && right) {
return charSet.SWCorner;
} else if(top && !bottom && left && !right) {
return charSet.SECorner;
}
return charSet.Pillar;
}
}
示例9: DefinePInvokeMethod
[System.Security.SecurityCritical] // auto-generated
#endif
public MethodBuilder DefinePInvokeMethod(String name, String dllName, String entryName, MethodAttributes attributes,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes, CallingConvention nativeCallConv,
CharSet nativeCharSet)
{
Contract.Ensures(Contract.Result<MethodBuilder>() != null);
lock(SyncRoot)
{
return DefinePInvokeMethodNoLock(name, dllName, entryName, attributes, callingConvention,
returnType, parameterTypes, nativeCallConv, nativeCharSet);
}
}
示例10: DefaultCharSetAttribute
// Constructors
public DefaultCharSetAttribute(CharSet charSet) {}
示例11: DefinePInvokeMethodHelper
[System.Security.SecurityCritical] // auto-generated
private MethodBuilder DefinePInvokeMethodHelper(
String name, String dllName, String importName, MethodAttributes attributes, CallingConventions callingConvention,
Type returnType, Type[] returnTypeRequiredCustomModifiers, Type[] returnTypeOptionalCustomModifiers,
Type[] parameterTypes, Type[][] parameterTypeRequiredCustomModifiers, Type[][] parameterTypeOptionalCustomModifiers,
CallingConvention nativeCallConv, CharSet nativeCharSet)
{
CheckContext(returnType);
CheckContext(returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers, parameterTypes);
CheckContext(parameterTypeRequiredCustomModifiers);
CheckContext(parameterTypeOptionalCustomModifiers);
AppDomain.CheckDefinePInvokeSupported();
lock (SyncRoot)
{
return DefinePInvokeMethodHelperNoLock(name, dllName, importName, attributes, callingConvention,
returnType, returnTypeRequiredCustomModifiers, returnTypeOptionalCustomModifiers,
parameterTypes, parameterTypeRequiredCustomModifiers, parameterTypeOptionalCustomModifiers,
nativeCallConv, nativeCharSet);
}
}
示例12: DefinePInvokeMethod
public MethodBuilder DefinePInvokeMethod(String name, String dllName, MethodAttributes attributes,
CallingConventions callingConvention, Type returnType, Type[] parameterTypes,
CallingConvention nativeCallConv, CharSet nativeCharSet)
{
MethodBuilder method = DefinePInvokeMethodHelper(
name, dllName, name, attributes, callingConvention, returnType, null, null,
parameterTypes, null, null, nativeCallConv, nativeCharSet);
return method;
}
示例13: MakeDllImport
private string MakeDllImport(
CallingConvention? cc = null,
CharSet? charSet = null,
bool? exactSpelling = null,
bool? preserveSig = null,
bool? setLastError = null,
bool? bestFitMapping = null,
bool? throwOnUnmappableChar = null)
{
StringBuilder sb = new StringBuilder("[DllImport(\"bar\"");
if (cc != null)
{
sb.Append(", CallingConvention = CallingConvention.");
sb.Append(cc.Value);
}
if (charSet != null)
{
sb.Append(", CharSet = CharSet.");
sb.Append(charSet.Value);
}
if (exactSpelling != null)
{
sb.Append(", ExactSpelling = ");
sb.Append(exactSpelling.Value ? "true" : "false");
}
if (preserveSig != null)
{
sb.Append(", PreserveSig = ");
sb.Append(preserveSig.Value ? "true" : "false");
}
if (setLastError != null)
{
sb.Append(", SetLastError = ");
sb.Append(setLastError.Value ? "true" : "false");
}
if (bestFitMapping != null)
{
sb.Append(", BestFitMapping = ");
sb.Append(bestFitMapping.Value ? "true" : "false");
}
if (throwOnUnmappableChar != null)
{
sb.Append(", ThrowOnUnmappableChar = ");
sb.Append(throwOnUnmappableChar.Value ? "true" : "false");
}
sb.Append(")]");
return sb.ToString();
}
示例14: ResolveGlobalAttributes
/// <summary>
/// It is called very early therefore can resolve only predefined attributes
/// </summary>
void ResolveGlobalAttributes ()
{
if (OptAttributes == null)
return;
if (!OptAttributes.CheckTargets ())
return;
// FIXME: Define is wrong as the type may not exist yet
var DefaultCharSet_attr = new PredefinedAttribute (this, "System.Runtime.InteropServices", "DefaultCharSetAttribute");
DefaultCharSet_attr.Define ();
Attribute a = ResolveModuleAttribute (DefaultCharSet_attr);
if (a != null) {
has_default_charset = true;
DefaultCharSet = a.GetCharSetValue ();
switch (DefaultCharSet) {
case CharSet.Ansi:
case CharSet.None:
break;
case CharSet.Auto:
DefaultCharSetType = TypeAttributes.AutoClass;
break;
case CharSet.Unicode:
DefaultCharSetType = TypeAttributes.UnicodeClass;
break;
default:
Report.Error (1724, a.Location, "Value specified for the argument to `{0}' is not valid",
DefaultCharSet_attr.GetSignatureForError ());
break;
}
}
}
示例15: SetCustomAttribute
public void SetCustomAttribute (CustomAttributeBuilder customBuilder)
{
if (customBuilder == null)
throw new ArgumentNullException ("customBuilder");
switch (customBuilder.Ctor.ReflectedType.FullName) {
case "System.Runtime.CompilerServices.MethodImplAttribute":
byte[] data = customBuilder.Data;
int impla; // the (stupid) ctor takes a short or an int ...
impla = (int)data [2];
impla |= ((int)data [3]) << 8;
iattrs |= (MethodImplAttributes)impla;
return;
case "System.Runtime.InteropServices.DllImportAttribute":
CustomAttributeBuilder.CustomAttributeInfo attr = CustomAttributeBuilder.decode_cattr (customBuilder);
bool preserveSig = true;
/*
* It would be easier to construct a DllImportAttribute from
* the custom attribute builder, but the DllImportAttribute
* does not contain all the information required here, ie.
* - some parameters, like BestFitMapping has three values
* ("on", "off", "missing"), but DllImportAttribute only
* contains two (on/off).
* - PreserveSig is true by default, while it is false by
* default in DllImportAttribute.
*/
pi_dll = (string)attr.ctorArgs[0];
if (pi_dll == null || pi_dll.Length == 0)
throw new ArgumentException ("DllName cannot be empty");
native_cc = System.Runtime.InteropServices.CallingConvention.Winapi;
for (int i = 0; i < attr.namedParamNames.Length; ++i) {
string name = attr.namedParamNames [i];
object value = attr.namedParamValues [i];
if (name == "CallingConvention")
native_cc = (CallingConvention)value;
else if (name == "CharSet")
charset = (CharSet)value;
else if (name == "EntryPoint")
pi_entry = (string)value;
else if (name == "ExactSpelling")
ExactSpelling = (bool)value;
else if (name == "SetLastError")
SetLastError = (bool)value;
else if (name == "PreserveSig")
preserveSig = (bool)value;
else if (name == "BestFitMapping")
BestFitMapping = (bool)value;
else if (name == "ThrowOnUnmappableChar")
ThrowOnUnmappableChar = (bool)value;
}
attrs |= MethodAttributes.PinvokeImpl;
if (preserveSig)
iattrs |= MethodImplAttributes.PreserveSig;
return;
case "System.Runtime.InteropServices.PreserveSigAttribute":
iattrs |= MethodImplAttributes.PreserveSig;
return;
case "System.Runtime.CompilerServices.SpecialNameAttribute":
attrs |= MethodAttributes.SpecialName;
return;
case "System.Security.SuppressUnmanagedCodeSecurityAttribute":
attrs |= MethodAttributes.HasSecurity;
break;
}
if (cattrs != null) {
CustomAttributeBuilder[] new_array = new CustomAttributeBuilder [cattrs.Length + 1];
cattrs.CopyTo (new_array, 0);
new_array [cattrs.Length] = customBuilder;
cattrs = new_array;
} else {
cattrs = new CustomAttributeBuilder [1];
cattrs [0] = customBuilder;
}
}