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


C# Method.ToSignatureString方法代码示例

本文整理汇总了C#中Method.ToSignatureString方法的典型用法代码示例。如果您正苦于以下问题:C# Method.ToSignatureString方法的具体用法?C# Method.ToSignatureString怎么用?C# Method.ToSignatureString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Method的用法示例。


在下文中一共展示了Method.ToSignatureString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: EmitMethod

        protected override void EmitMethod (Method method)
        {
            if (method.IsSynthetic)
                return;
            
            if (method.IsOverride && !method.IsConstructor && !method.Abstract && !method.Static)
            {
                Type parent = method.Type.ParentType;
                string sig = method.ToSignatureString();
                while (parent != null)
                {
                    if (myJniTypes.ContainsKey(parent.Name) && parent.Methods.Dictionary.ContainsKey(sig))
                    {
                        var jniType = myJniTypes[parent.Name];
                        
                        // see if the method exists to override
                        try
                        {
                            if (jniType.GetMethod(method.Name) == null)
                                return;
                        }
                        catch (AmbiguousMatchException)
                        {
                        }
                    }
                    parent = parent.ParentType;
                }
            }
            
            //if (method.PropertyType != null && method.Name.StartsWith("set"))
            //    return;
            
            string methodId = null;
            if (!method.Type.IsInterface)
            {
                string signature = GetMethodSignature(method);
                if (method.Name.LastIndexOf('.') == -1)
                    methodId = method.Name;
                else
                    methodId = method.Name.Substring(method.Name.LastIndexOf('.') + 1);
                string methodIdLookup = methodId;
                methodId = string.Format("_{0}{1}", methodId.Replace("@",""), myMemberCounter++);
                string initJni = string.Format("global::{0}.{1} = @__env.Get{4}MethodIDNoThrow(global::{0}.staticClass, \"{2}\", \"{3}\");", method.Type.Name, methodId, method.IsConstructor ? "<init>" : methodIdLookup, signature, method.Static ? "Static" : string.Empty);
                myInitJni.Add(initJni);
                WriteLine("internal static global::MonoJavaBridge.MethodId {0};", methodId);
                
                //WriteLine("[global::System.Runtime.CompilerServices.MethodImpl(global::System.Runtime.CompilerServices.MethodImplOptions.InternalCall)]");
                Write(method.Scope);
                if (method.Abstract)
                    Write("abstract");
                else
                {
                    if (method.Static)
                    {
                        Write("static");
                    }
                    else if (!method.IsConstructor)
                    {
                        if (method.IsOverride)
                        {
                            if (method.IsSealed)
                                Write("sealed");
                            Write("override");
                        }
                        else if (!method.Type.IsSealed && method.Scope != string.Empty)
                            Write("virtual");
                    }
                    //Write("extern");
                }
            }
            // TODO: Reflect on the jni4net type, and see if the method exists or not.
            // This is a hack to prevent some compiler warnings.
            if (method.IsNew && (method.Name != "clone" || !myJniTypes.ContainsKey(method.Type.Parent)))
                Write("new");
            if (method.Return != null)
                Write("{0}{1}", ObjectModel.IsSystemType(method.Return) ? string.Empty : "global::", method.Return);
            Write(method.Name, false);
            Write("(", false);
            //WriteDelimited(method.Parameters, (v, i) => string.Format("{0} arg{1}", v == "java.lang.CharSequence" && !method.Name.Contains('.') ? "string" : v, i), ",");
            WriteDelimited(method.Parameters, (v, i) => string.Format("{0} arg{1}", v, i), ",");
            if (method.Type.IsInterface || method.Abstract || method.Scope == "internal")
            {
                WriteLine(");");
            }
            else
            {
                Write(")");
                if (method.IsConstructor)
                    Write(" : base(global::MonoJavaBridge.JNIEnv.ThreadEnv)");
                WriteLine();
                WriteLine("{");
                myIndent++;
                // TODO: Remove this if statement when array returns are properly supported
                WriteLine("global::MonoJavaBridge.JNIEnv @__env = global::MonoJavaBridge.JNIEnv.ThreadEnv;");
                var statement = GetMethodStatement(method);
                StringBuilder parBuilder = new StringBuilder();
                if (method.Static || method.IsConstructor)
                    parBuilder.AppendFormat("{0}.staticClass, ", method.Type.Name);
                else
                    parBuilder.Append("this.JvmHandle, ");
//.........这里部分代码省略.........
开发者ID:nagyist,项目名称:androidmono,代码行数:101,代码来源:NetProxyGenerator.cs


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