Ejemplo n.º 1
0
        void AddInstrumentations(XElement manifest, IList <TypeDefinition> subclasses, int targetSdkVersion)
        {
            var assemblyAttrs =
                Assemblies.SelectMany(path => InstrumentationAttribute.FromCustomAttributeProvider(Resolver.GetAssembly(path)));

            // Add instrumentation to the manifest
            foreach (var ia in assemblyAttrs)
            {
                if (ia.TargetPackage == null)
                {
                    ia.SetTargetPackage(PackageName);
                }
                if (!manifest.Descendants("instrumentation").Any(x => (string)x.Attribute(attName) == ia.Name))
                {
                    manifest.Add(ia.ToElement(PackageName));
                }
            }

            foreach (var type in subclasses)
            {
                if (type.IsSubclassOf("Android.App.Instrumentation"))
                {
                    var xe = InstrumentationFromTypeDefinition(type, JavaNativeTypeManager.ToJniName(type).Replace('/', '.'), targetSdkVersion);
                    if (xe != null)
                    {
                        manifest.Add(xe);
                    }
                }
            }
        }
Ejemplo n.º 2
0
 XElement InstrumentationFromTypeDefinition(TypeDefinition type, string name, int targetSdkVersion)
 {
     return(ToElement(type, name,
                      t => InstrumentationAttribute.FromCustomAttributeProvider(t).FirstOrDefault(),
                      ia => {
         if (ia.TargetPackage == null)
         {
             ia.SetTargetPackage(PackageName);
         }
         return ia.ToElement(PackageName);
     }));
 }