Exemplo n.º 1
0
        private Type CreateMetaInfoProperty(IEnumerable <ByNameGrouping> typesGroupesByName)
        {
            var typeBuilder = moduleBuilder.DefineType(MetaDataClassName, CodeGenerationUtils.PublicClass());

            var finalType = new NamespaceContextGenerator("MetaData", moduleBuilder, typeBuilder, typesGroupesByName,
                                                          CreateMetaDataGetter,
                                                          (t, d) => BuildMetaInfoType(moduleBuilder, d), true).BuildType();

            return(finalType.CreateType());
        }
Exemplo n.º 2
0
        internal static Type CreateContextType(ModuleBuilder builder,
                                               IEnumerable <KeyValuePair <ITypeDescription, Type> > types)
        {
            var typesGroupesByName = from t in types
                                     where t.Key.IsBusinessEntity
                                     group t by t.Key.Name
                                     into byName
                                     select new ByNameGrouping(byName.Key, byName);
            var typeBuilder = builder.DefineType(QueryContextClassName,
                                                 CodeGenerationUtils.PublicClass(), typeof(ContextRoot));

            return(new ContextTypeGenerator(builder, typeBuilder).Build(typesGroupesByName));
        }
Exemplo n.º 3
0
        private Tuple <TypeBuilder, ConstructorBuilder> BuildNSContextType(string forNamespace)
        {
            var currentType =
                moduleBuilder.DefineType(
                    CodeGenerator.NameSpace + "." + forNamespace + "." + nameSpaceClassesPrefix + "NameSpaceContext",
                    CodeGenerationUtils.PublicClass());
            var constructor = currentType.DefineConstructor(CodeGenerationUtils.PublicConstructurSignature(),
                                                            CallingConventions.Standard, new Type[0]);
            var ilGenerator = constructor.GetILGenerator();

            ilGenerator.Emit(OpCodes.Ldarg_0);
            ilGenerator.Emit(OpCodes.Call, typeof(object).GetConstructors().Single());
            ilGenerator.Emit(OpCodes.Ret);
            return(Tuple.Create(currentType, constructor));
        }
Exemplo n.º 4
0
        private static Type BuildMetaInfoType(ModuleBuilder moduleBuilder, ITypeDescription type)
        {
            var typeBuilder = moduleBuilder.DefineType(MetaDataNameSpace + "." + CodeGenerationUtils.ClassName(type.TypeName), CodeGenerationUtils.PublicClass());

            AddNameProperty(typeBuilder, type);
            return(typeBuilder.CreateType());
        }