當前位置: 首頁>>代碼示例>>C#>>正文


C# AssemblyDefinition.GetJavaCodeAttributes方法代碼示例

本文整理匯總了C#中Mono.Cecil.AssemblyDefinition.GetJavaCodeAttributes方法的典型用法代碼示例。如果您正苦於以下問題:C# AssemblyDefinition.GetJavaCodeAttributes方法的具體用法?C# AssemblyDefinition.GetJavaCodeAttributes怎麽用?C# AssemblyDefinition.GetJavaCodeAttributes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mono.Cecil.AssemblyDefinition的用法示例。


在下文中一共展示了AssemblyDefinition.GetJavaCodeAttributes方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: AssemblyClasses

            /// <summary>
            /// Default ctor
            /// </summary>
            internal AssemblyClasses(AssemblyDefinition assembly, Action<ClassSource> jarLoaded=null)
            {
                this.assembly = assembly;
                foreach (var attr in assembly.GetJavaCodeAttributes())
                {
                    var resourceName = (string)attr.ConstructorArguments[0].Value;
                    var fileName = attr.ConstructorArguments.Count > 1 ? (string)attr.ConstructorArguments[1].Value : null;

                    JavaCode javaCode;
                    if (!javaCodes.TryGetValue(resourceName, out javaCode))
                    {
                        var resource = assembly.MainModule.Resources.FirstOrDefault(x => x.Name == resourceName) as EmbeddedResource;
                        if (resource == null)
                            throw new LoaderException("Cannot find resource " + resourceName);
                        javaCode = new JavaCode(resource, fileName);
                        javaCodes[resourceName] = javaCode;

                        if (jarLoaded != null)
                            jarLoaded(javaCode.ClassSource);

                        foreach (var classFileName in javaCode.Resolve(null).ClassFileNames)
                        {
                            var className = classFileName;
                            if (className.EndsWith(".class", StringComparison.OrdinalIgnoreCase))
                            {
                                className = className.Substring(0, className.Length - ".class".Length);
                            }
                            var jClass = new JavaClass(className, javaCode);
                            javaClasses[className] = jClass;
                        }
                    }
                }
                var scope = AssemblyResolver.IsFrameworkAssembly(assembly) ? AttributeConstants.Dot42Scope : assembly.FullName;
                var ignoreFromJavaTypes = new List<TypeDefinition>();
                foreach (var type in assembly.MainModule.Types)
                {
                    CollectDexImportClasses(type, className2DexImportMap, type2DexImportMap, null, scope, ignoreFromJavaTypes);
                }
                foreach (var type in ignoreFromJavaTypes)
                {
                    var attr = type.GetDexOrJavaImportAttribute();
                    var className = (string)attr.ConstructorArguments[0].Value;
                    DexImport dexImport;
                    if (className2DexImportMap.TryGetValue(className, out dexImport))
                    {
                        dexImport.AddType(type);
                        type2DexImportMap[type] = dexImport;
                    }
                }
            }
開發者ID:Xtremrules,項目名稱:dot42,代碼行數:53,代碼來源:AssemblyClassLoader.AssemblyClasses.cs


注:本文中的Mono.Cecil.AssemblyDefinition.GetJavaCodeAttributes方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。