Search Results

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

Page 29/50 | < Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >

  • Loop through enumeration

    - by Germ
    What is best way to loop through an enumeration looking for a matching value? string match = "A"; enum Sample { A, B, C, D } foreach(...) { //should return Sample.A }

    Read the article

  • Entity Framework 4 missing features?

    - by Roger Alsing
    I'm well aware that similair topics have been brought up before e.g. http://stackoverflow.com/questions/1639043/entity-framework-4-vs-nhibernate But instead of arguments like: NHibernate have been around longer and is more mature EF4 is drag n drop and not enterprisy EF4 and LinqToSql are ... I would like to see a more detailed list of features that you consider missing from EF4. Personally, I think the lack of enum support is the biggest drawback of EF4.

    Read the article

  • Problems with UK.Elect() method

    - by codeulike
    I'm calling UK.Elect() but getting a weird result back. I was expecting a value of Enum.ElectoralReform but it seems to be throwing an InfufficientSeatsException I think I probably need to re-factor the whole PoliticalClass Any suggestions?

    Read the article

  • convert Arabic numerical to English

    - by hamitay
    i am looking for a way to convert the Arabic numerical string "??????????" to an English numerical string "0123456789" Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click dim Anum as string ="??????????" dim Enum as string =get_egnlishNum(Anum) End Sub private function get_egnlishNum(byval _Anum as string) as string '' converting code end function

    Read the article

  • Change user control appearance based on state

    - by John
    I have a user control that consists of four overlapping items: 2 rectangles, an ellipse and a lable <UserControl x:Class="UserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="50.1" Height="45.424" Background="Transparent" FontSize="24"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="3.303*" /> <RowDefinition Height="40*" /> <RowDefinition Height="2.121*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="5.344*" /> <ColumnDefinition Width="40.075*" /> <ColumnDefinition Width="4.663*" /> </Grid.ColumnDefinitions> <Rectangle Name="Rectangle1" RadiusX="5" RadiusY="5" Fill="DarkGray" Grid.ColumnSpan="3" Grid.RowSpan="3" /> <Ellipse Name="ellipse1" Fill="{Binding State}" Margin="0.016,0.001,4.663,0" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" Stroke="Black" IsEnabled="True" Panel.ZIndex="2" /> <Label Name="lblNumber" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" FontWeight="Bold" FontSize="24" Grid.Column="1" Grid.Row="1" Padding="0" Panel.ZIndex="3">9</Label> <Rectangle Grid.Column="1" Grid.Row="1" Margin="0.091,0,4.663,0" Fill="Blue" Name="rectangle2" Stroke="Black" Grid.ColumnSpan="2" Panel.ZIndex="1" /> </Grid> Here is my business object that I want to control the state of my user control: Imports System.Data Imports System.ComponentModel Public Class BusinessObject Implements INotifyPropertyChanged 'Public logger As log4net.ILog Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged Private _state As States Public Enum States State1 State2 State3 End Enum Public Property State() As States Get Return _state End Get Set(ByVal value As States) If (value <> _state) Then _state = value RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs("State")) End If End Set End Property Protected Sub OnPropertyChanged(ByVal name As String) RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(name)) End Sub I want to be able to change the state of a business object in the code behind and have that change the colors of multiple shapes in my usercontrol. I'm not sure about how to do the binding. I set the datacontext of the user control in the code behind but not sure if that's right. I'm new to WPF and programming in general and I'm stuck on where to go from here. Any recommendations would be greatly appreciated!!

    Read the article

  • pthread functions "_np" suffix

    - by osgx
    What does "_np" suffix mean here: pthread_mutex_timedlock_np or in macros PTHREAD_MUTEX_TIMED_NP Upd: From glibc2.2 enum { PTHREAD_MUTEX_TIMED_NP, PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_ADAPTIVE_NP #ifdef __USE_UNIX98 , PTHREAD_MUTEX_NORMAL = PTHREAD_MUTEX_TIMED_NP, PTHREAD_MUTEX_RECURSIVE = PTHREAD_MUTEX_RECURSIVE_NP, PTHREAD_MUTEX_ERRORCHECK = PTHREAD_MUTEX_ERRORCHECK_NP, PTHREAD_MUTEX_DEFAULT = PTHREAD_MUTEX_NORMAL #endif #ifdef __USE_GNU /* For compatibility. */ , PTHREAD_MUTEX_FAST_NP = PTHREAD_MUTEX_ADAPTIVE_NP #endif }; Does defining __USE_UNIX98 change portability of _NP functions/macro?

    Read the article

  • C++ Class Access Specifier Verbosity

    - by PolyTex
    A "traditional" C++ class (just some random declarations) might resemble the following: class Foo { public: Foo(); explicit Foo(const std::string&); ~Foo(); enum FooState { Idle, Busy, Unknown }; FooState GetState() const; bool GetBar() const; void SetBaz(int); private: struct FooPartialImpl; void HelperFunction1(); void HelperFunction2(); void HelperFunction3(); FooPartialImpl* m_impl; // smart ptr FooState m_state; bool m_bar; int m_baz; }; I always found this type of access level specification ugly and difficult to follow if the original programmer didn't organize his "access regions" neatly. Taking a look at the same snippet in a Java/C# style, we get: class Foo { public: Foo(); public: explicit Foo(const std::string&); public: ~Foo(); public: enum FooState { Idle, Busy, Unknown }; public: FooState GetState() const; public: bool GetBar() const; public: void SetBaz(int); private: struct FooPartialImpl; private: void HelperFunction1(); private: void HelperFunction2(); private: void HelperFunction3(); private: FooPartialImpl* m_impl; // smart ptr private: FooState m_state; private: bool m_bar; private: int m_baz; }; In my opinion, this is much easier to read in a header because the access specifier is right next to the target, and not a bunch of lines away. I found this especially true when working with header-only template code that wasn't separated into the usual "*.hpp/*.inl" pair. In that scenario, the size of the function implementations overpowered this small but important information. My question is simple and stems from the fact that I've never seen anyone else actively do this in their C++ code. Assuming that I don't have a "Class View" capable IDE, are there any obvious drawbacks to using this level of verbosity? Any other style recommendations are welcome!

    Read the article

  • Displaying xaml resources dynamically?

    - by Robert
    I used Mike Swanson's illustrator to xaml converter to convert some of my images to xaml. The convert creates a viewbox that contains the image. These viewboxes I made resource files in my program. The code below shows what I'm trying to do: I have a viewmodel that has an enum variable called PrimaryWinding of type Windings. The values PrimD and PrimY of the enum select the respective PrimD and PrimY xaml files in the resources. <UserControl.Resources> <DataTemplate x:Key="PrimTrafo" DataType="{x:Type l:Windings}"> <Frame Source="{Binding}" x:Name="PART_Image" NavigationUIVisibility="Hidden"> <Frame.LayoutTransform> <ScaleTransform ScaleX="0.5" ScaleY="0.5"/> </Frame.LayoutTransform> </Frame> <DataTemplate.Triggers> <DataTrigger Binding="{Binding}" Value="PrimD"> <Setter TargetName="PART_Image" Property="Source" Value="Resources\PrimD.xaml" /> </DataTrigger> <DataTrigger Binding="{Binding}" Value="PrimY"> <Setter TargetName="PART_Image" Property="Source" Value="Resources\PrimY.xaml" /> </DataTrigger> </DataTemplate.Triggers> </DataTemplate> </UserControl.Resources> <!--The contentcontrol that holds the datatemplate defined above--> <Grid > <Grid.ColumnDefinitions> <ColumnDefinition Width="2*"></ColumnDefinition> <ColumnDefinition Width="2*"></ColumnDefinition> <ColumnDefinition Width="1*"></ColumnDefinition> </Grid.ColumnDefinitions> <ContentControl Grid.Column="0" Content="{Binding PrimaryWinding}" ContentTemplate="{StaticResource PrimTrafo}"/> </Grid> This code works. Only I can't resize the drawings to the size of the grid cell. I added the ScaleTransform class to resize the image. Is a Frame the wrong class to hold the drawings? Should I use the ScaleTransform class to resize the drawing to the size of the cell? And how can I do that dynamically?

    Read the article

  • JOIN in SQL with one-to-many relationship

    - by Kristopher Ives
    I'm making a tool to track calls to house/senate reps, and I have 2 tables of importance here: reps rep_id rep_name # and more info comments rep_id status # enum about result of contact comment I want to query for all reps joining the most recent associated comments and in some cases joining comments of a specific status, but there might not be any comments associated with that rep yet. THANKS!

    Read the article

  • Compare class objects

    - by reto
    I have to compare a class object against a list of pre defined classes. Is it safe to use == or should I use equals()? if (klass == KlassA.class) { } else if (klass == KlassB.class) { } else if (klass == KlassC.class) { } else { } Note: I cannot use instanceof, I don't have an object, I just have the class object. I (mis)use it like an enum in this situation! Thanks!

    Read the article

  • C# some sort of plugin system

    - by nLL
    Hi, I am a mobile web developer and trying to monetize my traffic with mobile ad services and i have a problem. First of all to get most of out of your ads you usually need to do server side request to advert company's servers and there are quite few ad services. Problem starts when you want to use them in one site. All have different approaches to server side calls and trying to maintain and implement those ad codes becomes pain after a while. So I decided to write a class system where i can simply create methods for every company and upload it to my site. So far i have public Advert class public AdPublisher class with GetAd method that returns an Advert public Adservice class that has Service names as enum I also have converted server request codes of all ad services i use to classes. It works ok but I want to be able to create an ad service class upload it so that asp.net app can import/recognize it automatically like a plugin system. As I am new to .net I have no idea where to start or how to do it. To make thing clear here are my classes namespace Mobile.Publisher { public class AdPublisher { public AdPublisher() { IsTest = false; } public bool IsTest { get; set; } public HttpRequest CurrentVisitorRequestInfo { get; set; } public Advert GetAd(AdService service) { Advert returnAd = new Advert(); returnAd.Success = true; if (this.CurrentVisitorRequestInfo == null) { throw new Exception("CurrentVisitorRequestInfo for AdPublisher not set!"); } if (service == null) { throw new Exception("AdService not set!"); } if (service.ServiceName == AdServices.Admob) { returnAd.ReturnedAd = AdmobAds("000000"); } return returnAd; } } public enum AdServices { Admob, ServiceB, ServiceC } public class Advert { public bool Success { get; set; } public string ReturnedAd { get; set; } } public partial class AdService { public AdServices ServiceName { get; set; } public string PublisherOrSiteId { get; set; } public string ZoneOrChannelId { get; set; } } private string AdmobAds(string publisherid) { //snip return "test" } } Basically i want to be able to add another ad service and code like private string AdmobAds(string publisherid){ } So that it can be imported and recognised as ad service. I hope i was clear enough

    Read the article

  • Menu contribution for popupsubmenu ?

    - by Mathan
    In eclipse plugin development i could add files in toolbar, menu and popupmenu by using menu contribution. In my project I want to add a set of files in the popupsubmenu, eg : Like the following Project Explorer - Right Click - New - Annotation, Class, Enum .... I want to add my files abc,def and xyz.. under the new menu item What is the locationuri for popupsubmenu ? Help me on this Thanks in advance Regards Mathan

    Read the article

  • Inventory count in CakePHP

    - by metrobalderas
    We are developing an inventory tracking system. Basically we've got an order table in which orders are placed. When an order is payed, the status changes from 0 to 1. This table has multiple children in another table order_items. This is the main structure. CREATE TABLE order( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, user_id INT UNSIGNED, status INT(1), total INT UNSIGNED ); CREATE TABLE order_items( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, order_id INT UNSIGNED, article_id INT UNSIGNED, size enum('s', 'm', 'l', 'xl'), quantity INT UNSIGNED ); Now, we've got a stocks table with similar architecture for the acquisitions. This is the structure. CREATE TABLE stock( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, article_id INT UNSIGNED ); CREATE TABLE stock_items( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, stock_id INT UNSIGNED, size enum('s', 'm', 'l', 'xl'), quantity INT(2) ); The main difference is that stocks has no status field. What we are looking for is a way to sum each article size from stock_items, then sum each article size from order_items where Order.status = 1 and substract both these items to find our current inventory. This is the table we want to get from a single query: Size | Stocks | Sales | Available s | 10 | 3 | 7 m | 15 | 13 | 2 l | 7 | 4 | 3 Initially we thought abouth using complex find conditions, but perhaps that's the wrong approach. Also, since it's not a direct join, it turns out to be quite hard. This is the code we have to retrieve the stock's total for each item. function stocks_total($id){ $find = $this->StockItem->find('all', array( 'conditions' => array( 'StockItem.stock_id' => $this->find('list', array('conditions' => array('Stock.article_id' => $id))) ), 'fields' => array_merge( array( 'SUM(StockItem.cantidad) as total' ), array_keys($this->StockItem->_schema) ), 'group' => 'StockItem.size', 'order' => 'FIELD(StockItem.size, \'s\', \'m\' ,\'l\' ,\'xl\') ASC' )); return $find; } Thanks.

    Read the article

  • .Net 4.0, New methods in existing classes

    - by Yogesh
    Is there a blog or MSDN article, which lists all the new methods which are added in .Net 4.0 in existing classes? I could not find any. Two which I found on blogs till now: String.IsNullOrWhiteSpace Enum.HasFlag Are there more such methods added which anybody found? If yes, please share.

    Read the article

  • useless class storage specifier in empty declaration

    - by robUK
    Hello, gcc 4.4.1 c89 I have the following code and I get a warning: unless class storage specifier in empty declaration static enum states { ACTIVE, RUNNING, STOPPED, IDLE } However, if i remove the static keyword I don't get that warning. I am compiling with the following flags: -Wall -Wextra Many thanks for any suggestions,

    Read the article

  • Solve a maze using multicores?

    - by acidzombie24
    This question is messy, i dont need a working solution, i need some psuedo code. How would i solve this maze? This is a homework question. I have to get from point green to red. At every fork i need to 'spawn a thread' and go that direction. I need to figure out how to get to red but i am unsure how to avoid paths i already have taken (finishing with any path is ok, i am just not allowed to go in circles). Heres an example of my problem, i start by moving down and i see a fork so one goes right and one goes down (or this thread can take it, it doesnt matter). Now lets ignore the rest of the forks and say the one going right hits the wall, goes down, hits the wall and goes left, then goes up. The other thread goes down, hits the wall then goes all the way right. The bottom path has been taken twice, by starting at different sides. How do i mark this path has been taken? Do i need a lock? Is this the only way? Is there a lockless solution? Implementation wise i was thinking i could have the maze something like this. I dont like the solution because there is a LOT of locking (assuming i lock before each read and write of the haveTraverse member). I dont need to use the MazeSegment class below, i just wrote it up as an example. I am allowed to construct the maze however i want. I was thinking maybe the solution requires no connecting paths and thats hassling me. Maybe i could split the map up instead of using the format below (which is easy to read and understand). But if i knew how to split it up i would know how to walk it thus the problem. How do i walk this maze efficiently? The only hint i receive was dont try to conserve memory by reusing it, make copies. However that was related to a problem with ordering a list and i dont think the hint was a hint for this. class MazeSegment { enum Direction { up, down, left, right} List<Pair<Direction, MazeSegment*>> ConnectingPaths; int line_length; bool haveTraverse; } MazeSegment root; class MazeSegment { enum Direction { up, down, left, right} List<Pair<Direction, MazeSegment*>> ConnectingPaths; bool haveTraverse; } void WalkPath(MazeSegment segment) { if(segment.haveTraverse) return; segment.haveTraverse = true; foreach(var v in segment) { if(v.haveTraverse == false) spawn_thread(v); } } WalkPath(root);

    Read the article

  • How to go to particular Item in IEnumerable

    - by Subhen
    Hi, I have Ienum which contains number Data inside it. Attached the snapShot of Viual Studio, Enum that Contains Data: Just to brief about the above image, eLevelData is the IEnumerable variable, in which I have my data . Now I want to go to the data at index 4 or 5, but I don't want to use foreach loop. Any suggestions please. Thanks, Subhen

    Read the article

  • avoiding enums as interface identifiers c++ OOP

    - by AlasdairC
    Hi I'm working on a plugin framework using dynamic loaded shared libraries which is based on Eclipse's (and probally other's) extension-point model. All plugins share similar properties (name, id, version etc) and each plugin could in theory satisfy any extension-point. The actual plugin (ie Dll) handling is managed by another library, all I am doing really is managing collections of interfaces for the application. I started by using an enum PluginType to distinguish the different interfaces, but I have quickly realised that using template functions made the code far cleaner and would leave the grunt work up to the compiler, rather than forcing me to use lots of switch {...} statements. The only issue is where I need to specify like functionality for class members - most obvious example is the default plugin which provides a particular interface. A Settings class handles all settings, including the default plugin for an interface. ie Skin newSkin = settings.GetDefault<ISkin>(); How do I store the default ISkin in a container without resorting to some other means of identifying the interface? As I mentioned above, I currently use a std::map<PluginType, IPlugin> Settings::defaults member to achieve this (where IPlugin is an abstract base class which all plugins derive from. I can then dynamic_cast to the desired interface when required, but this really smells of bad design to me and introduces more harm than good I think. would welcome any tips edit: here's an example of the current use of default plugins typedef boost::shared_ptr<ISkin> Skin; typedef boost::shared_ptr<IPlugin> Plugin; enum PluginType { skin, ..., ... } class Settings { public: void SetDefault(const PluginType type, boost::shared_ptr<IPlugin> plugin) { m_default[type] = plugin; } boost::shared_ptr<IPlugin> GetDefault(const PluginType type) { return m_default[type]; } private: std::map<PluginType, boost::shared_ptr<IPlugin> m_default; }; SkinManager::Initialize() { Plugin thedefault = g_settings.GetDefault(skinplugin); Skin defaultskin = boost::dynamic_pointer_cast<ISkin>(theskin); defaultskin->Initialize(); } I would much rather call the getdefault as the following, with automatic casting to the derived class. However I need to specialize for every class type. template<> Skin Settings::GetDefault<ISkin>() { return boost::dynamic_pointer_cast<ISkin>(m_default(skin)); }

    Read the article

  • Need MYSQL query for finding lowest score per game player

    - by Chris Barnhill
    I have a game on Facebook called Rails Across Europe. I have a Best Scores page where I show the players with the best 20 scores, which in game terms refers to the lowest winning turn. The problem is that there are a small number of players who play frequently, and their scores dominate the page. I'd like to make the scores page open to more players. So I thought that I could display the single lowest winning turn for each player instead of displaying all of the lowest winning turns for all players. The problem is that the query for this eludes me. So I hope that one of you brilliant StackOverflow folks can help me with this. I have included the relevant MYSQL table schemas below. Here are the the table relationships: player_stats contains statistics for either a game in progress or a completed game. If a game is in progress, winning_turn is zero (which means that games with a winning_turn of zero should not be included in the query). player_stats has a game_player table id reference. game_player contains data describing games currently in progress. game_player has a player table id reference. player contains data describing a person who plays the game. Here's the query I'm currently using: 'SELECT p.fb_user_id, ps.winning_turn, gp.difficulty_level, c.name as city_name, g.name as goods_name, d.cost FROM game_player as gp, player as p, player_stats as ps, demand as d, city as c, goods as g WHERE p.status = "ACTIVE" AND gp.player_id = p.id AND ps.game_player_id = gp.id AND d.id = ps.highest_demand_id AND c.id = d.city_id AND g.id = d.goods_id AND ps.winning_turn > 0 ORDER BY ps.winning_turn ASC, d.cost DESC LIMIT '.$limit.';'; Here are the relevant table schemas: -- -- Table structure for table `player_stats` -- CREATE TABLE IF NOT EXISTS `player_stats` ( `id` int(11) NOT NULL auto_increment, `game_player_id` int(11) NOT NULL, `winning_turn` int(11) NOT NULL, `highest_demand_id` int(11) NOT NULL, PRIMARY KEY (`id`), KEY `game_player_id` (`game_player_id`,`highest_demand_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3814 ; -- -- Table structure for table `game_player` -- CREATE TABLE IF NOT EXISTS `game_player` ( `id` int(10) unsigned NOT NULL auto_increment, `game_id` int(10) unsigned NOT NULL, `player_id` int(10) unsigned NOT NULL, `player_number` int(11) NOT NULL, `funds` int(10) unsigned NOT NULL, `turn` int(10) unsigned NOT NULL, `difficulty_level` enum('STANDARD','ADVANCED','MASTER','ULTIMATE') NOT NULL, `date_last_used` datetime NOT NULL, PRIMARY KEY (`id`), KEY `game_id` (`game_id`,`player_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=3814 ; -- -- Table structure for table `player` -- CREATE TABLE IF NOT EXISTS `player` ( `id` int(11) NOT NULL auto_increment, `fb_user_id` char(255) NOT NULL, `fb_proxied_email` text NOT NULL, `first_name` char(255) NOT NULL, `last_name` char(255) NOT NULL, `birthdate` date NOT NULL, `date_registered` datetime NOT NULL, `date_last_logged_in` datetime NOT NULL, `status` enum('ACTIVE','SUSPENDED','CLOSED') NOT NULL, PRIMARY KEY (`id`), KEY `fb_user_id` (`fb_user_id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1646 ;

    Read the article

  • Generation of abstract class with JCodeModel

    - by SadJokerBY
    I'm trying to generate top-level abstract class with JCodeModel library, but I can't find any way to change class modifiers. It's possible for nested classes (JDefinedClass API provides methods that get modifiers as parameters). But for creation of top level classes I found only JCodeModel API methods that get fully qualified name with or without ClassType (class/interface/annotation/enum) as parameters. Does anybody can suggest me how to change modifiers of JDefinedClass to make it abstract?

    Read the article

< Previous Page | 25 26 27 28 29 30 31 32 33 34 35 36  | Next Page >