Enum generator task performer released

Posts   
 
    
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 14-Jul-2004 13:41:31   

Enum generation from DB Tables

Courtesy of: Circulation Data Author: Wayne Barker Database Support: SQL Server Language: C#

Included in this archive: The Source: Source folder. Taskperformer DLL: Gen_Enums.dll Taskperformer Config: Gen_Enums.config

Description: This Taskperformer allows the user to generate a enum code file that is based on the contents of lookup tables in the database. The Taskperformer has been tested with the 28th June release of LLBLGen. - Source Code included.

DISCLAIMER: This taskperformer is supplied as is, without any warranty or support. Use it at your own risk. It is always wise to first check the sourcecode, and before using it, make a backup copy of your project.

Read the enclosed readme for details about how to setup the taskperformer for your project.

The task performer is available in the 3rd party section on the website in the customer area. Thanks Wayne!! simple_smile

Frans Bouma | Lead developer LLBLGen Pro
alexdresko
User
Posts: 336
Joined: 08-Jun-2004
# Posted on: 15-Jul-2004 01:51:28   

Didn't know what that would be used for until I found this post: http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=1114

wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 29-Sep-2004 10:34:56   

Hi All

I found that a problem with enums. After running the enum taks performer. I had an enum like this:

    public enum PaymentType : int
    {
        Takeon__unknown = -1,
        Cash_Received = 1,
        Cheque = 2,
        Postal_Order = 3,
        Credit_Card = 4,
        Debit_Cheque_Account = 7,
        Debit_Credit_Card = 8,
        Bill_Me_Later = 9,
        Voucher_Copies = 10,
        Complimentary = 13,
        Journal = 14,
        Direct_Deposit_ABSA = 16,
        Split_Deposit_Nedbank = 17,
        Direct_Deposit_NedBank = 18,
        Direct_Deposit_FTFW = 19,
        Auto_Renewal = 20,
        Ican_Online_Payment = 21
    } 

But yet C# allows me to do the following - without raising an exception

PaymentType PType;
PType = (PaymentType)100;

...Strongly typed language? Notice that 100 is not in the enum. If there is some way to stop this from happening - please let me know. Some type of compiler directive that will raise an exception?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39615
Joined: 17-Aug-2003
# Posted on: 29-Sep-2004 11:11:08   

That's a C# quirk simple_smile

You could test though: System.Enum.IsValue(typeof(yourEnum), value)

or System.Enum.Parse simple_smile

Frans Bouma | Lead developer LLBLGen Pro
wayne avatar
wayne
User
Posts: 611
Joined: 07-Apr-2004
# Posted on: 29-Sep-2004 12:27:04   

Otis wrote:

That's a C# quirk simple_smile

You could test though: System.Enum.IsValue(typeof(yourEnum), value) or System.Enum.Parse simple_smile

Thanks.

So everywhere a value gets passed to an enum i have to do that check. - Got it. simple_smile

I accidently found that bug when a old entry in our database had a Int value that was no longer present (used) in the enum.

Quite a BIG quirk if you ask me. frowning

Kinda reminds me of VB with _option strict off. _