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


C# MethodDefinition.GetDexOrJavaImportAttribute方法代码示例

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


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

示例1: GetFinalImplementationName

 private static string GetFinalImplementationName(MethodDefinition impl)
 {
     string finalName;
     var importAttr = impl.GetDexOrJavaImportAttribute();
     if (importAttr != null)
     {
         string descriptor, className;
         importAttr.GetDexOrJavaImportNames(impl, out finalName, out descriptor, out className);
     }
     else
     {
         var dexNameAttr = impl.GetDexNameAttribute();
         finalName = dexNameAttr.ConstructorArguments[0].Value.ToString();
     }
     return finalName;
 }
开发者ID:Xtremrules,项目名称:dot42,代码行数:16,代码来源:MethodInterfaceImportedlmpementationsConverter.cs

示例2: ConvertInterfaceMethod

            /// <summary>
            /// Convert the given interface method if it has explicit implementations.
            /// </summary>
            private void ConvertInterfaceMethod(TypeDefinition iType, MethodDefinition iMethod, Dictionary<TypeDefinition, List<TypeDefinition>> interfaceToImplementingTypes)
            {
                var implementations = GetImplementations(iMethod, interfaceToImplementingTypes);
                var iMethodIsJavaWithGenericParams = iMethod.IsJavaMethodWithGenericParams();
                var iMethodContainsGenericParams = iMethod.ContainsGenericParameter;
                if (!iMethodIsJavaWithGenericParams && !iMethodContainsGenericParams && (!implementations.Any(x => x.Item2.IsExplicitImplementation())))
                {
                    // There are no explicit implementation.
                    // No need to convert
                    return;
                }

                // Rename method
                string newName;
                bool createExplicitStubs = true;
                var oldName = iMethod.Name;
                var attr = iMethod.GetDexOrJavaImportAttribute();
                if (attr != null)
                {
                    string className;
                    string memberName;
                    string descriptor;
                    attr.GetDexOrJavaImportNames(iMethod, out memberName, out descriptor, out className);
                    newName = memberName;
                }
                else if ((attr = iMethod.GetDexNameAttribute()) != null)
                {
                    newName = (string) (attr.ConstructorArguments[0].Value);
                    createExplicitStubs = false;
                }
                else
                {
                    var module = reachableContext.Compiler.Module;
                    var xiType = XBuilder.AsTypeReference(module, iType);
                    newName = methodNames.GetUniqueName(NameConverter.GetConvertedName(xiType) + "_" + iMethod.Name);
                    oldName = newName;
                }

                Rename(iMethod, newName);
              
                // Update implementations
                foreach (var typeAndImpl in implementations)
                {
                    var type = typeAndImpl.Item1;
                    var impl = typeAndImpl.Item2;

                    if (impl.IsExplicitImplementation())
                    {
                        // Convert to implicit
                        impl.IsPublic = true;

                        // Rename
                        Rename(impl, newName);
                        // Update names of overrides
                        foreach (var @override in impl.Overrides)
                        {
                            @override.Name = newName;
                        }
                    }
                    else if (!(impl.HasDexImportAttribute() || impl.HasJavaImportAttribute()))
                    {
                        // Add stub redirecting explicit implementation to implicit implementation
                        if (createExplicitStubs/* && !type.IsInterface TODO: check what to do with interfaces*/)
                        {
                            CreateExplicitStub(type, impl, newName, oldName, iMethod, iMethodIsJavaWithGenericParams /*|| iMethodContainsGenericParams*/);
                        }
                    }
                }
            }
开发者ID:Xtremrules,项目名称:dot42,代码行数:72,代码来源:MethodExplicitInterfaceConverter.cs


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