本文整理汇总了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;
}
}
}