Search Results

Search found 1234 results on 50 pages for 'enum'.

Page 8/50 | < Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >

  • Fluent NHibernate Map Enum as Lookup Table

    - by Jaimal Chohan
    I have the following (simplified) public enum Level { Bronze, Silver, Gold } public class Member { public virtual Level MembershipLevel { get; set; } } public class MemberMap : ClassMap<Member> { Map(x => x.MembershipLevel); } This creates a table with a column called MembershipLevel with the value as the Enum string value. What I want is for the entire Enum to be created as a lookup table, with the Membe table referencing this with the integer value as the FK. Also, I want to do this without bas***izing my model. Any ideas? [And I want time machine] [With 2 cup holders]

    Read the article

  • C# - Silverlight - CustomAttribute with Enum

    - by cmaduro
    I have the following class: [MetadataAttribute] [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public class ModuleActivationButtonAttribute : ExportAttribute { public Enum TargetRegion { get; set; } public ModuleActivationButtonAttribute(Enum targetRegion) : base(typeof(IModuleActivationButton)) { TargetRegion = targetRegion; } } The class compiles fine, but when I decorate my property with it: [ModuleActivationButton(Regions.Tabs)] public IModuleActivationButton ModuleActivationButton { get { return new ModuleActivationButton() as IModuleActivationButton; } set { ModuleActivationButton = value; } } public enum Regions { Content, Tabs } The compiler spits out: Error 1 An attribute argument must be a constant expression, typeof expression or array creation expression of an attribute parameter type C:\...\Manpower4U.Modules.Home\HomeModule.cs 28 33 Manpower4U.Modules.Home

    Read the article

  • How to define enum in as3?

    - by Nava Carmon
    Is there a way to define an enum in AS3 in a way we do it in other languages? I can define constants with defined values like that: private const CONST_1:int = 0; private const CONST_2:int = 1; private const CONST_3:int = 2; and so on. If I want to insert some other constant between 3 these I need to move all values like that: private const CONST_1:int = 0; private const CONST_2:int = 1; private const CONST_2A:int = 2; private const CONST_3:int = 3; while in other language I would end up with only adding a new member to enum closure like that: enum { CONST_1 = 0, CONST_2, CONST_2A, CONST_3 } MyConstEnum; Does AS3 has something similar? Thanks

    Read the article

  • Source Insight: Show me Enum Values

    - by JXG
    I'm programming in C and using Source Insight. I have an enum type with a lot of constants (like 100). I have debug prints that print out variable values, but they (of course) print out as integers. What I'd like to do is click on the name of an enum constant, and see its numeric value displayed somewhere. (I've seen this done in a Visual Studio plugin, so it must be possible.) That is, assume I have enum colors { ORANGE, PURPLE, PINK }; I want to click on (or select, or something) PURPLE and see the value 1 somewhere visible (ideally, the symbol window or context window, but I'm not particular). Is there an easy way to do this in Source Insight? Is there a difficult way, at least (such as writing a macro)?

    Read the article

  • MySQL SET and ENUM types in CakePHP framework

    - by Andrew Bashtannik
    Hi! I need to use SET and ENUM types in my CakePHP 1.3 project. I found some advices, but all them are too old (2004-2006) and full of crazy methods, like modifying cake's core files. Also, CakePHP developers said that SET and ENUM types are not supported. Example: I have SET('alpha','beta') field, and I need to use this data as checkboxes in add & edit actions. Is there any way to add normal support (Form helpers etc.) of SET and ENUM fields?

    Read the article

  • Constraining enum value in method parameter

    - by fearofawhackplanet
    enum Fruit { Banana, Orange, Strawberry ... ... // etc, very long enum } PeelFruit(Fruit.Orange); PeelFruit(Fruit.Banana); PeelFruit(Fruit.Strawberry); // huh? can't peel strawberries! Sorry for the lame example, but hopefully you get the idea. Is there a way to constrain the enum values that PeelFruit will accept? Obvisouly I could check them in the method with a switch or something, but it would be cool if there was a way to do it that is a) a bit more compact, and b) would cause a compile time error, not a run time error. [Fruit = Orange,Bannana] void PeelFruit(Fruit fruit) { ... }

    Read the article

  • How to check a radio button based upon the enum value

    - by user281180
    I have an enum. Based upon the value brought by model, I have to check radio button. How can I do that? <%=Html.RadioButton("Role", Role.Viewer)%><%= .Role.Viewer%> <%=Html.RadioButton("Role",.Role.Reporter)%><%= Role.Reporter%> <%=Html.RadioButton("Role",Role.User)%><%= Role.User%> My enum would be having the numbers 1 to 3 for e.g. How can I check the Role.Viewer if enum value selected is 1?

    Read the article

  • Cast enum to integer

    - by Shanish
    I have a enum class called Gender and I have values in this like public enum GENDER { MALE = 1, FAMALE = 2, OTHERS = 3, } and in my business object I just created a property for this like public GENDER Gender { get { return gender; } set { gender = value; } } in my database its in type integer. For this I tried to assign the Gender value in the add function by its name Gender. but its showing error. Is it possible to cast the enum to integer so that it'll get the value automatically. can anyone help me out here....

    Read the article

  • Behaviour to simulate an enum implementing an interface

    - by fearofawhackplanet
    Say I have an enum something like: enum OrderStatus { AwaitingAuthorization, InProduction, AwaitingDespatch } I've also created an extension method on my enum to tidy up the displayed values in the UI, so I have something like: public static string ToDisplayString(this OrderStatus status) { switch (status) { case Status.AwaitingAuthorization: return "Awaiting Authorization"; case Status.InProduction: return "Item in Production"; ... etc } } Inspired by the excellent post here, I want to bind my enums to a SelectList with an extension method: public static SelectList ToSelectList<TEnum>(this TEnum enumObj) however, to use the DisplayString values in the UI drop down I'd need to add a constraint along the lines of : where TEnum has extension ToDisplayString Obviously none of this is going to work at all with the current approach, unless there's some clever trick I don't know about. Does anyone have any ideas about how I might be able to implement something like this?

    Read the article

  • Setting enum values to 4-byte strings - why?

    - by psychotik
    I saw code similar to this in the Mac OS SDK: enum { kAudioFileStreamProperty_ReadyToProducePackets = 'redy', kAudioFileStreamProperty_FileFormat = 'ffmt', kAudioFileStreamProperty_DataFormat = 'dfmt', kAudioFileStreamProperty_FormatList = 'flst', kAudioFileStreamProperty_MagicCookieData = 'mgic', kAudioFileStreamProperty_AudioDataByteCount = 'bcnt', kAudioFileStreamProperty_AudioDataPacketCount = 'pcnt', kAudioFileStreamProperty_MaximumPacketSize = 'psze', kAudioFileStreamProperty_DataOffset = 'doff', kAudioFileStreamProperty_ChannelLayout = 'cmap', kAudioFileStreamProperty_PacketToFrame = 'pkfr', kAudioFileStreamProperty_FrameToPacket = 'frpk', kAudioFileStreamProperty_PacketToByte = 'pkby', kAudioFileStreamProperty_ByteToPacket = 'bypk', kAudioFileStreamProperty_PacketTableInfo = 'pnfo', kAudioFileStreamProperty_PacketSizeUpperBound = 'pkub', kAudioFileStreamProperty_AverageBytesPerPacket = 'abpp', kAudioFileStreamProperty_BitRate = 'brat' }; It's the first time I've seen this - I assume the compiler assigns the 32-bit integer equivalent of the strings to the enum values. I cannot think of a single good reason why this might be preferred over using simple integers. It looks hideous in a debugger (how do you tell which of these values corresponds to 1919247481?) and makes debugging just hard in general. So, is there any reason where assigning such strings to enum values actually makes sense.

    Read the article

  • how can this inner enum code be improved ?

    - by mafalda
    I have this construct public class Constants{ enum SystemA implements Marker{ ConstOne(1), ConstTwo(2), ConstThree(3); SystemA(int i) { number =i; } int number; } enum SystemB implements Marker{ ConstFour(4), ConstFive(5), ConstSix(6); SystemB(int i) { number =i; } int number; } } I have Marker so I can pass to method like this method(Constants.SystemA) or method(Constants.SystemB) What is the best way to list all the enum values ? I also want to make sure that it is not duplicating the number in any of the enums

    Read the article

  • Reflection alternative for switch on enum in order to select namespace/class

    - by Am
    Hi, I have an interface named IHarvester. There are 3 implementations of that interface, each under their own namespace: Google Yahoo Bing A HarvesterManager uses the given harvester. It knows the interface and all 3 implementations. I want some way of letting the class user say in which harvester it wants to use. And in the code select that implementation, without a switch-case implementation. Can reflection save my day? Here is the code bits: // repeat for each harvester namespace Harvester.Google { public abstract class Fetcher : BaseHarvester, IInfoHarvester {...} } public enum HarvestingSource { Google, Yahoo, Bing, } class HarvesterManager { public HarvestingSource PreferedSource {get;set;} public HarvestSomthing() { switch (PreferedSource) .... // awful... } } Thanks. I will give my 2 cents of why I want to change this. There several people writing harvesters, I want them to focus only on building more harvesters, without ever needing to update the enum, or at worst, update only the enum.

    Read the article

  • PowerShell - Parameter Value Tab Expansion for Enum types

    - by Adam Driscoll
    Is it possible to implement parameter value tab expansion for enum parameter types? Creating a binary cmdlet with parameter definition: [Parameter] public SomeEnum Type {get;set;} Is there some way to type: Add-MyThing -Type S<tab> To get: Add-MyThing -Type SomeEnumValue Where: public enum SomeEnum { SomeEnumValue, SomeEnumValue2 } I know it may be possible with overriding the TabExpansion function but I was wondering if there was something I could do within my cmdlet to expose this type of functionality.

    Read the article

  • Choosing the default value of an Enum type without having to change values

    - by frou
    In C#, is it possible to decorate an Enum type with an attribute or do something else to specify what the default value should be, without having the change the values? The numbers required might be set in stone for whatever reason, and it'd be handy to still have control over the default. enum Orientation { None = -1, North = 0, East = 1, South = 2, West = 3 } Orientation o; // Is 'North' by default.

    Read the article

  • Convert integer enum to string

    - by user216205
    Hi Guys, considering the following enum: public enum LeadStatus { Cold = 1, Warm = 2, Hot = 3, Quote = 5, Convert = 6 } How can I convert the integer value back to string when I pull the value from a database. I've tried: DomainModel.LeadStatus status = (DomainModel.LeadStatus)Model.Status; but all I seem to get is "status = 0"

    Read the article

  • Doxygen autolink not working to global enum types

    - by MeThinks
    I am trying to use Doxygen Automatic link generation to document some enum types. However, it is not generating links for the global enum types. It does generates links for the global struct types. Is there something I am missing? I am using the example provided on the link above. As required, I have documented the file in which the types are defined. update1: I am using Doxygen version 1.6.3 update2: global structs are ok

    Read the article

  • C# enum to string auto-conversion?

    - by dcompiled
    Is it possible to have the compiler automatically convert my Enum values to strings so I can avoid explicitly calling the ToString method every time. Here's an example of what I'd like to do: enum Rank { A, B, C } Rank myRank = Rank.A; string myString = Rank.A; // Error: Cannot implicitly convert type 'Rank' to 'string' string myString2 = Rank.A.ToString(); // OK: but is extra work

    Read the article

  • Why and what for: java enum

    - by Mat Banik
    Today I was browsing through some question on this site and I found mention of enum being used in singleton pattern and that there are some thread safety benefits to such solution. I never used enums and I have been programing in java for more than couple a years now. And apparently they changed a lot and now they even do full blown support of OOP within them selfs. Now why and what for should I used enum in day to day programing?

    Read the article

< Previous Page | 4 5 6 7 8 9 10 11 12 13 14 15  | Next Page >