コード例 #1
0
        private static IAuxiliaryDatabaseObject CreateSimpleObject(HbmDatabaseObject databaseObjectSchema)
        {
            string createText = databaseObjectSchema.FindCreateText();
            string dropText   = databaseObjectSchema.FindDropText();

            IAuxiliaryDatabaseObject simpleObject = new SimpleAuxiliaryDatabaseObject(createText, dropText);

            foreach (string dialectName in databaseObjectSchema.FindDialectScopeNames())
            {
                simpleObject.AddDialectScope(dialectName);
            }

            return(simpleObject);
        }
コード例 #2
0
        private static IAuxiliaryDatabaseObject CreateCustomObject(Mappings mappings, HbmDatabaseObject databaseObjectSchema)
        {
            HbmDefinition definitionSchema = databaseObjectSchema.FindDefinition();
            string        customTypeName   = definitionSchema.@class;

            try
            {
                string className =
                    TypeNameParser.Parse(customTypeName, mappings.DefaultNamespace, mappings.DefaultAssembly).ToString();
                System.Type customType = ReflectHelper.ClassForName(className);

                IAuxiliaryDatabaseObject customObject =
                    (IAuxiliaryDatabaseObject)Environment.BytecodeProvider.ObjectsFactory.CreateInstance(customType);

                foreach (string dialectName in databaseObjectSchema.FindDialectScopeNames())
                {
                    customObject.AddDialectScope(dialectName);
                }

                customObject.SetParameterValues(definitionSchema.FindParameterValues());

                return(customObject);
            }
            catch (TypeLoadException exception)
            {
                throw new MappingException(string.Format("Could not locate custom database object class [{0}].", customTypeName),
                                           exception);
            }
            catch (Exception exception)
            {
                throw new MappingException(
                          string.Format("Could not instantiate custom database object class [{0}].", customTypeName), exception);
            }
        }
コード例 #3
0
 public static IAuxiliaryDatabaseObject Create(Mappings mappings, HbmDatabaseObject databaseObjectSchema)
 {
     return(databaseObjectSchema.HasDefinition()
                                                 ? CreateCustomObject(mappings, databaseObjectSchema)
                                                 : CreateSimpleObject(databaseObjectSchema));
 }