本文整理匯總了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;
}
}
}