Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Referring to enums
Message
De
28/01/2011 09:06:46
 
 
À
28/01/2011 09:04:50
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Divers
Thread ID:
01497627
Message ID:
01497635
Vues:
34
Thanks again Tim.

>Hi Frank,
>
>I often just create a utiltity class or a family of utility classes in my business object library to put these in. I personally think it is an OK principal to put several utility methods in a class especially if they are all related. So if you have a bunch of formatting type utiltity methods you could create a FormatUtitlity class and group them all in there. I typically make most of these methods static so you don't have to instantiate the class to use the method.
>
>I also think the business object library is a good choice for lots of this as it is typically available to your other projects. There are times when that isn't the case, such as MVVM and they are better in a sperate project. I do have a BTS.Common project that contains many utitilities I have over time that I use from seveal different application projects. Those are typically more generic so not specific to a given application. Having a seperate project for these means I can share them with other applications but also can create a reference in any of my application projects without exposing a project I wouldn't want to.
>
>I hope that all makes sense.
>Tim
>
>>Thanks Tim.
>>
>>I've made it public and now I can refer to it as Policy.StatusCode.< enum >.
>>
>>On another similar vein, if I have sort of utility functions that may be accessed by various parts of my system, how do I handle those? For example, I want to format names as "Firstname Surname" so I might have a FormatNameFirstLast function and sometimes I might need them formatted as Surname, Firstname so I'll have one called FormatNameLastFirst. Should I have these in a utility.cs with their own namespace and just ensure the namespace is "declared" where I need to use them? Or should each be in their own .cs file?
>>
>>>Hi Frank,
>>>
>>>Is this in its own code file. try:
>>>public enum StatusCode
>>>Tim
>>>
>>>>Hi,
>>>>
>>>>I have an enum defined in a partial class of a Business Object (all my BOs are in one project) like this:
>>>>
>>>>
        enum StatusCode
>>>>        {
>>>>            Pending = 1,
>>>>            InForce = 2,
>>>>            Withdrawn = 3,
>>>>            Postponed = 4,
>>>>            Deferred = 5,
>>>>            Cancelled = 6,
>>>>            Claimed = 7,
>>>>            Matured = 8,
>>>>            Lapsed = 9,
>>>>            Surrendered = 10,
>>>>            DeathNotice = 11
>>>>        }
>>>>
>>>>This lets me refer to the enum in code in the partial class no problem, like this:
>>>>
>>>>
this.Entity.Status = StatusCode.Pending;
>>>>
>>>>However, if I want to use this enum in the interface project (separate to the BO project, but part of the overall solution) I can't as the compiler does not recognise it. Is there some way to make this enum available outside of the BO? Or is this bad design?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform