当前位置: 首页>>代码示例>>C#>>正文


C# Function.IsUnsafeMethod方法代码示例

本文整理汇总了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;
        }
开发者ID:werwolfby,项目名称:Managed-OpenGL,代码行数:52,代码来源:FunctionGenerator.cs

示例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;
//.........这里部分代码省略.........
开发者ID:werwolfby,项目名称:Managed-OpenGL,代码行数:101,代码来源:FunctionGenerator.cs


注:本文中的System.Function.IsUnsafeMethod方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。