コード例 #1
0
        /// <summary>
        /// Creates a Custom Model assembly with given name and extended type definitions and saves it to assemblyName.dll
        /// </summary>
        /// <param name="assemblyName">The name of the assembly (will be saved as assemblyName.dll)</param>
        /// <param name="extendedTables">The enumeration of extended tables to be implemented</param>
        public static void CreateCustomModelAssembly(string assemblyName, IEnumerable<ExtendedTable> extendedTables)
        {
            string assemblyFileName = assemblyName + ".dll";
            var assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(assemblyName), AssemblyBuilderAccess.RunAndSave);
            var moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyFileName, assemblyFileName);

            var derivedTypes = new List<Type>();

            var tableMappings = new TableMappings();
            foreach (var extendedTable in extendedTables)
            {
                var tableMapping = new TableMapping(extendedTable.TableName);
                foreach (var extendedType in extendedTable.Types)
                {
                    var derivedType = CreateDerivedType(moduleBuilder, extendedTable, extendedType);

                    derivedTypes.Add(derivedType);

                    tableMapping.Add(new TypeMapping(extendedType.BaseType, derivedType));
                }
                tableMappings.Add(tableMapping);
            }
            SerializeMappings(assemblyName, tableMappings);
            assemblyBuilder.Save(assemblyFileName);
        }
コード例 #2
0
 public void Add(TableMapping mapping)
 {
     Mappings.Add(mapping);
 }
コード例 #3
0
 public void Add(TableMapping mapping)
 {
     Mappings.Add(mapping);
 }