本文整理汇总了C#中System.Function.IsUnsafeMethod方法的典型用法代码示例。如果您正苦于以下问题:C# Function.IsUnsafeMethod方法的具体用法?C# Function.IsUnsafeMethod怎么用?C# Function.IsUnsafeMethod使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Function
的用法示例。
在下文中一共展示了Function.IsUnsafeMethod方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateOpenGLFunction
public CodeWriter GenerateOpenGLFunction( Function function, IList<TypeMap> typeMapList, IList<CSTypeMap> csTypeMapList, IList<EnumData> enumDatas )
{
var writer = new CodeWriter();
writer.Indent = 0;
writer.Append( "[DllImport( \"opengl32.dll\", EntryPoint=\"gl" );
writer.AppendText( function.Name );
writer.Indent = 0;
writer.AppendLine( "\" )]" );
writer.Append( "public static extern " );
if (function.IsUnsafeMethod(typeMapList, csTypeMapList)){
writer.Indent = 0;
writer.Append( "unsafe " );
}
writer.AppendText( function.Return.GetCSName( typeMapList, csTypeMapList, enumDatas ) );
writer.Indent = 0;
writer.Append( " " );
writer.AppendText( function.Name );
writer.Indent = 0;
writer.Append( "( " );
{
var list = new List<CodeWriter>();
CodeWriter temp;
foreach (var item in function.ParamList)
{
temp = this.Invoke( "GenerateParam", item, typeMapList, csTypeMapList, enumDatas );
list.Add( temp );
}
writer.AppendType = AppendType.EmptyLastLine;
for (var listI = 0; listI < list.Count; listI++)
{
var codeWriter = list[listI];
writer.Append( codeWriter );
if (listI < list.Count - 1)
writer.AppendText( ", " );
}
writer.AppendType = AppendType.EmptyLastLine;
}
writer.Indent = 0;
writer.Append( " ); // " );
if (function.Contains( "extension" )){
writer.Indent = 0;
writer.Append( " extension method" );
}
writer.Indent = 0;
writer.AppendLine();
writer.Indent = 1;
return writer;
}
示例2: GenerateDelegateFunction
public CodeWriter GenerateDelegateFunction( Function function, IList<TypeMap> typeMapList, IList<CSTypeMap> csTypeMapList, IList<EnumData> enumDatas )
{
var writer = new CodeWriter();
writer.Indent = 0;
writer.Append( "public " );
if (function.IsUnsafeMethod(typeMapList, csTypeMapList)){
writer.Indent = 0;
writer.Append( "unsafe " );
}
writer.Indent = 0;
writer.Append( "delegate " );
writer.AppendText( function.Return.GetCSName( typeMapList, csTypeMapList, enumDatas ) );
writer.Indent = 0;
writer.Append( " " );
writer.AppendText( function.Name );
writer.Indent = 0;
writer.Append( "Delegate( " );
{
var list = new List<CodeWriter>();
CodeWriter temp;
foreach (var item in function.ParamList)
{
temp = this.Invoke( "GenerateParam", item, typeMapList, csTypeMapList, enumDatas );
list.Add( temp );
}
writer.AppendType = AppendType.EmptyLastLine;
for (var listI = 0; listI < list.Count; listI++)
{
var codeWriter = list[listI];
writer.Append( codeWriter );
if (listI < list.Count - 1)
writer.AppendText( ", " );
}
writer.AppendType = AppendType.EmptyLastLine;
}
writer.Indent = 0;
writer.Append( " ); // " );
if (function.Contains( "extension" )){
writer.Indent = 0;
writer.Append( " extension method" );
}
writer.Indent = 0;
writer.AppendLine();
writer.AppendLine();
writer.Append( "private static " );
writer.AppendText( function.Name );
writer.Indent = 0;
writer.Append( "Delegate _" );
writer.AppendText( function.Name );
writer.Indent = 0;
writer.AppendLine( ";" );
writer.AppendLine();
writer.Append( "public static " );
if (function.IsUnsafeMethod(typeMapList, csTypeMapList)){
writer.Indent = 0;
writer.Append( "unsafe " );
}
writer.Indent = 0;
writer.Append( " " );
writer.AppendText( function.Return.GetCSName( typeMapList, csTypeMapList, enumDatas ) );
writer.Indent = 0;
writer.Append( " " );
writer.AppendText( function.Name );
writer.Indent = 0;
writer.Append( "( " );
{
var list = new List<CodeWriter>();
CodeWriter temp;
foreach (var item in function.ParamList)
{
temp = this.Invoke( "GenerateParam", item, typeMapList, csTypeMapList, enumDatas );
list.Add( temp );
}
writer.AppendType = AppendType.EmptyLastLine;
for (var listI = 0; listI < list.Count; listI++)
{
var codeWriter = list[listI];
writer.Append( codeWriter );
if (listI < list.Count - 1)
writer.AppendText( ", " );
}
writer.AppendType = AppendType.EmptyLastLine;
}
writer.Indent = 0;
writer.AppendLine( " )" );
writer.AppendLine( "{" );
writer.Indent = 1;
writer.Append( "if (_" );
writer.AppendText( function.Name );
writer.Indent = 0;
writer.Append( " == null) throw new Exception( \"Extension method " );
writer.AppendText( function.Name );
writer.Indent = 0;
writer.AppendLine( " not found\" );" );
writer.Indent = 1;
//.........这里部分代码省略.........