Example #1
0
 /// <summary>
 /// Create a type builder for the given type.
 /// </summary>
 internal static IClassBuilder[] Create(ReachableContext context, AssemblyCompiler compiler, TypeDefinition typeDef)
 {
     if (typeDef.FullName == "<Module>")
         return new IClassBuilder[] { new SkipClassBuilder() };
     if (typeDef.IsDelegate())
         return new IClassBuilder[] {new DelegateClassBuilder(context, compiler, typeDef) };
     if (typeDef.IsAttribute()) 
         return new IClassBuilder[]  {new AttributeClassBuilder(context, compiler, typeDef) };
     if (typeDef.IsAnnotation())
         return new IClassBuilder[] {new AnnotationClassBuilder(context, compiler, typeDef) };
     if (typeDef.HasDexImportAttribute())
         return new IClassBuilder[] {new DexImportClassBuilder(context, compiler, typeDef) };
     if (typeDef.HasJavaImportAttribute())
         return new IClassBuilder[] {CreateJavaImportBuilder(context, compiler, typeDef)};
     if (typeDef.IsEnum)
     {
         if (typeDef.UsedInNullableT)
         {
             var nullableBaseClassBuilder = new NullableEnumBaseClassBuilder(context, compiler, typeDef);
             IClassBuilder builder = new EnumClassBuilder(context, compiler, typeDef, nullableBaseClassBuilder);
             return new[] { builder, nullableBaseClassBuilder };
         }
         return new IClassBuilder[] { new EnumClassBuilder(context, compiler, typeDef, null) };
     }
     else
     {
         IClassBuilder builder = new StandardClassBuilder(context, compiler, typeDef);
         if (typeDef.UsedInNullableT)
             return new[] { builder, new NullableBaseClassBuilder(context, compiler, typeDef) };
         return new[] { builder };
     }
 }
Example #2
0
 /// <summary>
 /// Create a type builder for the given type.
 /// </summary>
 internal static IClassBuilder[] Create(ReachableContext context, AssemblyCompiler compiler, TypeDefinition typeDef)
 {
     if (typeDef.FullName == "<Module>")
     {
         return new IClassBuilder[] { new SkipClassBuilder() }
     }
     ;
     if (typeDef.IsDelegate())
     {
         return new IClassBuilder[] { new DelegateClassBuilder(context, compiler, typeDef) }
     }
     ;
     if (typeDef.IsAttribute())
     {
         return new IClassBuilder[]  { new AttributeClassBuilder(context, compiler, typeDef) }
     }
     ;
     if (typeDef.IsAnnotation())
     {
         return new IClassBuilder[] { new AnnotationClassBuilder(context, compiler, typeDef) }
     }
     ;
     if (typeDef.HasDexImportAttribute())
     {
         return new IClassBuilder[] { new DexImportClassBuilder(context, compiler, typeDef) }
     }
     ;
     if (typeDef.HasJavaImportAttribute())
     {
         return new IClassBuilder[] { CreateJavaImportBuilder(context, compiler, typeDef) }
     }
     ;
     if (typeDef.IsEnum)
     {
         if (typeDef.UsedInNullableT)
         {
             var           nullableBaseClassBuilder = new NullableEnumBaseClassBuilder(context, compiler, typeDef);
             IClassBuilder builder = new EnumClassBuilder(context, compiler, typeDef, nullableBaseClassBuilder);
             return(new[] { builder, nullableBaseClassBuilder });
         }
         return(new IClassBuilder[] { new EnumClassBuilder(context, compiler, typeDef, null) });
     }
     else
     {
         IClassBuilder builder = new StandardClassBuilder(context, compiler, typeDef);
         if (typeDef.UsedInNullableT)
         {
             return new[] { builder, new NullableBaseClassBuilder(context, compiler, typeDef) }
         }
         ;
         return(new[] { builder });
     }
 }