private void CompileMissingTypes(IList <GeneratedTypesInfo> typesInfo)
        {
            // Compiling missing classes
            if (typesInfo.Any(s => s.CompilationNeeded))
            {
                var codeGenerationBuilder = new CodeGenerationBuilder(_dataProviderContext.ProviderName + ":DataId and helper classes");
                var codeBuilder           = new XmlDataProviderCodeBuilder(_dataProviderContext.ProviderName, codeGenerationBuilder);

                foreach (var storeToLoad in typesInfo.Where(s => s.CompilationNeeded))
                {
                    codeBuilder.AddDataType(storeToLoad.DataTypeDescriptor);

                    // Compiling some other classes for optimization
                    DataWrapperCodeGenerator.AddDataWrapperClassCode(codeGenerationBuilder, storeToLoad.DataTypeDescriptor);
                    EmptyDataClassCodeGenerator.AddEmptyDataClassTypeCode(codeGenerationBuilder, storeToLoad.DataTypeDescriptor);
                }

                var types = CodeGenerationManager.CompileRuntimeTempTypes(codeGenerationBuilder, false).ToDictionary(type => type.FullName);

                foreach (var storeToLoad in typesInfo.Where(s => s.CompilationNeeded))
                {
                    storeToLoad.DataIdClass             = types[storeToLoad.DataIdClassName];
                    storeToLoad.DataProviderHelperClass = types[storeToLoad.DataProviderHelperClassName];
                }
            }
        }
Example #2
0
        internal static Type CreateEmptyDataClassType(DataTypeDescriptor dataTypeDescriptor, Type baseClassType = null, CodeAttributeDeclaration codeAttributeDeclaration = null)
        {
            CodeGenerationBuilder codeGenerationBuilder = new CodeGenerationBuilder("EmptyDataClass: " + dataTypeDescriptor.Name);

            EmptyDataClassCodeGenerator.AddAssemblyReferences(codeGenerationBuilder, dataTypeDescriptor);
            EmptyDataClassCodeGenerator.AddEmptyDataClassTypeCode(codeGenerationBuilder, dataTypeDescriptor, baseClassType, codeAttributeDeclaration);

            IEnumerable <Type> types = CodeGenerationManager.CompileRuntimeTempTypes(codeGenerationBuilder);

            return(types.Single());
        }