예제 #1
0
        public static Dictionary <Type, Type> EmitTypes(BaseClassEmitter emitterToUse, params Type[] typesToMake)
        {
            var modelBuilder = GetModelBuilder();

            if (typesToMake.Any(x => !x.IsInterface))
            {
                throw new ArgumentException($"Parameter must be type of an interface", nameof(typesToMake));
            }
            if (typesToMake.Any(x => x.GetMethods().Any(m => !m.IsHideBySig)))
            {
                throw new ArgumentException("Parameter must be of an interface type that does contain methods.",
                                            nameof(typesToMake));
            }

            return(EmitTypes(emitterToUse, modelBuilder, typesToMake).ToDictionary(x => x.Item1, x => x.Item2));
        }
예제 #2
0
        public static Type EmitType(Type typeToMake, BaseClassEmitter emitterToUse, string nameForClass = null)
        {
            var modelBuilder = GetModelBuilder();

            if (!typeToMake.IsInterface)
            {
                throw new ArgumentException($"Parameter must be type of an interface", nameof(typeToMake));
            }
            if (typeToMake.GetMethods().Any(m => !m.IsHideBySig))
            {
                throw new ArgumentException("Parameter must be of an interface type that does contain methods.",
                                            nameof(typeToMake));
            }

            return(emitterToUse.EmitType(modelBuilder, typeToMake, nameForClass));
        }
예제 #3
0
 private static IEnumerable <Tuple <Type, Type> > EmitTypes(BaseClassEmitter emitterToUse, ModuleBuilder modelBuilder, Type[] typesToMake)
 => typesToMake.Select(x => new Tuple <Type, Type>(x, emitterToUse.EmitType(modelBuilder, x)));