How to use the Enum feature of 3.5

Posts   
 
    
gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 31-Jul-2012 16:38:55   

Hi,

I wanted to start using the native enum support, but I found the documentation a bit thin (or it's too obvious and I missed it) also I could only find 4 threads that didn't answer my questions.

There are 2 questions I have on this:

  1. What I assumed is that I would link to a certain .dll file containing all my enums and they would be available. But the structure of the .typeimports file does me give the impression I have to define each enum I want to use by hand, is that correct?
<typeImports>
    <typeImport typeName="MME.Objects.CurrentRight.Access"  assemblyFile="C:\Users\bin\Debug\MME.Objects.dll"/> 
</typeImports>

  1. In what part of the project file can I add the <typeImports> section, what should be it's containing element/section? Reason is that we have project-specific-enums.

Hope you can help, thanks a lot.

Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 31-Jul-2012 18:37:21   

TypeImport files, with the extension .typeimports are small XML files which are stored in TypeConverter folders (either the default type converter folder of the designer or the additional type converter folder specified in the Project Settings.

And for every type, you will need define where it can be found, the typeimports file, as shown in the doc example.

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 01-Aug-2012 10:18:32   

Thanks,

I did the following, but seems to missing something still.

I have an enum:


namespace Obymobi.Logic.Routing
{
    public enum RoutestephandlerStatus : int
    {
        WaitingForPreviousStep = 0,
        WaitingToBeHandled = 10,
        BeingHandled = 20,
        Completed = 30,
        Failed = 9999
    }
}

Created a file called 'Obymobi.typeimports' in 'D:\Development\dotnet\Obymobi\Obymobi.Files\Database\TypeImports.3.5'

Content:


<typeImports>
    <typeImport typeName="Obymobi.Logic.Routing.RoutestephandlerStatus" assemblyFile="D:\Development\dotnet\Obymobi\Obymobi.Logic\bin\Debug\Obymobi.Logic.dll"/> 
</typeImports>

Configured the project setting General > Designer Behavior > Additional Type converter folder to point to 'D:\Development\dotnet\Obymobi\Obymobi.Files\Database\TypeImports.3.5'

Restarted LLBLGen Pro 3.5 (May 31st 2012)

Opened an Entity, went to Entity fields, clicked the dropdown in the column 'Type', but only Kind; DotNet with it's types appeared, not my type.

Then I looked at Field mappings, in the column TypeConvert to use I only see 'None', so that was also not working.

What am I missing?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 01-Aug-2012 10:46:39   

What's the applicationoutput window telling you? It should enlist the error if it encountered an error while loading external types. e.g. if you compiled the enum dll with .net 4 and you're running the designer on .net 3.5 (the default)

Frans Bouma | Lead developer LLBLGen Pro
gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 01-Aug-2012 11:30:47   

It doesn't seem to be loading our convertor, the full Application Output:


DatabaseDriverStore::Successfully loaded driver 'MS Access 2000/XP/2003/2007/2010 Driver (OleDb)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\Access\SD.LLBLGen.Pro.DBDrivers.AccessDBDriver.dll'
DatabaseDriverStore::Successfully loaded driver 'IBM DB2 UDB 7.x/8.x/9x Driver (IBM DB2 .NET)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\DB2\SD.LLBLGen.Pro.DBDrivers.DB2DBDriver.dll'
DatabaseDriverStore::Successfully loaded driver 'Firebird 1.5/2.x Driver (Firebird.NET)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\Firebird\SD.LLBLGen.Pro.DBDrivers.FirebirdDBDriver.dll'
DatabaseDriverStore::Successfully loaded driver 'MySql 4.x/5.x Driver (MySQLDirect)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\MySql\SD.LLBLGen.Pro.DBDrivers.MySqlDBDriver.dll'
DatabaseDriverStore::Successfully loaded driver 'Oracle 9i/10g/11g Driver (MS Oracle)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\OracleMSOracle\SD.LLBLGen.Pro.DBDrivers.OracleDBDriver_MSOracle.dll'
DatabaseDriverStore::Successfully loaded driver 'Oracle 9i/10g/11g Driver (ODP.NET)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\OracleODPNET\SD.LLBLGen.Pro.DBDrivers.OracleDBDriver_ODPNET.dll'
DatabaseDriverStore::Successfully loaded driver 'PostgreSql 7.4+ Driver (Npgsql)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\PostgreSql\SD.LLBLGen.Pro.DBDrivers.PostgreSqlDBDriver.dll'
DatabaseDriverStore::Successfully loaded driver 'SQL Server 2000/2005/2008/2008R2/2012/Express Driver (SqlClient)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\SqlServer\SD.LLBLGen.Pro.DBDrivers.SqlServerDBDriver.dll'
DatabaseDriverStore::Successfully loaded driver 'Sybase ASA iAnywhere Driver (ASA iAnywhere Client)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\SybaseAsa\SD.LLBLGen.Pro.DBDrivers.SybaseAsaDBDriver.dll'
DatabaseDriverStore::Successfully loaded driver 'Sybase ASE Driver (ASE Client)' from 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Drivers\SybaseAse\SD.LLBLGen.Pro.DBDrivers.SybaseAseDBDriver.dll'
PluginStore::Successfully loaded plug-in 'Add Custom Properties Plug-in' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Plugins\SD.LLBLGen.Pro.Plugins.dll'.
PluginStore::Successfully loaded plug-in 'Plural to Singular converter plug-in' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Plugins\SD.LLBLGen.Pro.Plugins.dll'.
PluginStore::Successfully loaded plug-in 'Singular to Plural converter plug-in' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Plugins\SD.LLBLGen.Pro.Plugins.dll'.
PluginStore::Successfully loaded plug-in 'Project Inspector Plug-in' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Plugins\SD.LLBLGen.Pro.Plugins.dll'.
ImporterStore::Successfully loaded importer plug-in 'LLBLGen Pro v3 project importer' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\Plugins\SD.LLBLGen.Pro.Importers.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.BooleanNumericConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.BooleanCharYNConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.ByteDecimalConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.DateTimeDateTimeUTCConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.GuidByteArrayConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.GuidStringConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.DoubleDecimalConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.SingleDecimalConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.Int64DecimalConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.Int32DecimalConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
TypeConverterLoader::Successfully instantiated type converter 'SD.LLBLGen.Pro.TypeConverters.Int16DecimalConverter' from assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\SD.LLBLGen.Pro.TypeConverters.dll'.
Project File I/O::Project 'Obymobi.Data' loaded successfully
System::Initialization done. Ready.

Also verified it's in the .llblgenproj file:


    <Property Name="AdditionalTypeConverterFolder" Value="D:\Development\dotnet\Obymobi\Obymobi.Files\Database\TypeImports.3.5" />
Walaa avatar
Walaa
Support Team
Posts: 14950
Joined: 21-Aug-2005
# Posted on: 01-Aug-2012 21:18:09   

Jut for testing, what if you placed the dll in the default TypeConverter folder?

gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 02-Aug-2012 11:32:25   

Hi,

This is what I've tried based on your request:

Placed the 'Obymobi.typeimports' in "C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters"

No effect.

Placed our dll, Obymobi.Logic.dll in "C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters"

Found it and got an error:

TypeConverterStore::Error loading potential type converter assembly file 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\Obymobi.Logic.dll': One or more dependencies couldn't be resolved. Type converters in this assembly will be unavailable.

Then, just for testing, copied everything from the bin folder of that project in "C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters" (probably of no use)

Got:

TypeConverterLoader::Calling CreateInstance(null, null) on an instance of type converter type 'Dionysos.Web.UI.AnthemControls.ControlIDConverter' from assembly 'C:\Program Files (x86)\Solutions Design\LLBLGen Pro v3.5\TypeConverters\Dionysos.Web.dll' returned null: the core type of this type converted couldn't be determined because of this. The type converter will be unavailable.

Just let me know what to do next.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 02-Aug-2012 12:17:08   

The path to the assembly the enum type can be found in, has to be specified in the typeimports file. The enum probe code will then load the assembly and obtain the .net type as specified in the typeimports file from the assembly loaded. If the assembly is a .net 4 assembly it won't load it if you run the designer normally (on .net 3.5). Every error it can run into should be reported in the application output folder, including different .net versions.

Enums don't use type converters. You don't need a type converter for the enums. You can see which enums are loaded in the type shortcuts in project settings. Apparently you have a type converter class somewhere as it picks that one up.

The enum assembly itself, did you compile that against .net 4? If so, run the designer with the .net 4 runner. Although if this was the error, it should have been reported as such...

Also, please try the following: - create a new assembly with just the enum type - compile it - create a typeimports file and place it in a reachable typeconverter folder. Add the correct path to the assembly with the enum - load your project, add the typeconverter folder which contains the typeimports file and save the project - reload the project. This should load the type.

If this doesn't work, please attach the enum assembly and typeimports file to this thread so we can try to reproduce it with a project.

I suspect it's something with the XML file: it either isn't found or the xpath queries we use to find the elements don't result in any values in which case it's skipped.

Frans Bouma | Lead developer LLBLGen Pro
gabrielk avatar
gabrielk
User
Posts: 231
Joined: 01-Feb-2005
# Posted on: 02-Aug-2012 12:22:28   

I will perform your tests later, thanks for that.

Just to be 100% sure I don't misunderstand this 'feature', because I'm getting a bit scared that I might be wrong when I read the following which I didn't 100% follow.

Enums don't use type converters. You don't need a type converter for the enums. You can see which enums are loaded in the type shortcuts in project settings. Apparently you have a type converter class somewhere as it picks that one up.

What I want to achieve is that a field I have on an Entity that is now a int field, to be generated as Enum property on that entity.

For example, Order.Status would no longer be:

public int Status {get;set;}

but

public OrderStatus Status {get; set;}

Is that correct?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39614
Joined: 17-Aug-2003
# Posted on: 02-Aug-2012 12:32:50   

yep. simple_smile The conversion to/from a numeric value in the DB is done by the framework.

Frans Bouma | Lead developer LLBLGen Pro