Search Results

Search found 45013 results on 1801 pages for 'example'.

Page 18/1801 | < Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >

  • wp7 odata v2 dataservicestate save and restore methods tombstoning example needed

    - by MIantosca
    I am looking for an example of how to use the new DataServiceState Save and Restore methods in a WP7 application in order to tombstone a datacontext - I cannot find any examples and the approach I used resulted in an exception this saves the data context correctly PhoneApplicationService.Current.State["DataContext"] = DataServiceState.Save(this.Model.Entities); this attempts to restore it after the app is re-activated var dc = (PhoneApplicationService.Current.State["DataContext"] as DataServiceState).Restore(); but throws an exception An item could not be added to the collection. When items in a DataServiceCollection are tracked by the DataServiceContext, new items cannot be added before items have been loaded into the collection. This is the same exception I get if I try to reload a datacontext that I stored "directly" (without using the DataServiceState.Save method) in the PhoneApplicationService.Current.State. I cannot find any offical documentation on the new ODATA v2 DataServiceState class or examples. thanks Michael

    Read the article

  • Animated record deletion with jquery like mootools example

    - by twitter
    I was reading around and saw this example from David Walsh about how to animate record deletion with mootools. Does the exact same effect exist in jquery? This is his mootools code. window.addEvent('domready',function() { $$('a.delete').each(function(el) { el.addEvent('click',function(e) { e.stop(); var parent = el.getParent('div'); var request = new Request({ url: 'mootools-record-delete.php', link: 'chain', method: 'get', data: { 'delete': parent.get('id').replace('record-',''), ajax: 1 }, onRequest: function() { new Fx.Tween(parent,{ duration:300 }).start('background-color', '#fb6c6c'); }, onSuccess: function() { new Fx.Slide(parent,{ duration:300, onComplete: function() { parent.dispose(); } }).slideOut(); } }).send(); }); }); });

    Read the article

  • Noob tab widget example not running

    - by michbeck
    hey all, i'm trying to reproduce the tabwidget example (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html). i'm not really sure what's the problem, i've git no errors while compiling, but i cannot see the application on emulators screen :-/ would be excellent if maybe anyone could have a look at my classes and tell me what's my mistake? I've packed my project here: http://etanto.com/TabTest.zip thanx a lot in advance, folks! michbeck here's the console dump while the run: [2010-06-10 09:18:34 - TabTest] Launching a new emulator with Virtual Device 'Virtual1' [2010-06-10 09:18:35 - TabTest] New emulator found: emulator-5554 [2010-06-10 09:18:35 - TabTest] Waiting for HOME ('android.process.acore') to be launched... [2010-06-10 09:19:05 - TabTest] WARNING: Application does not specify an API level requirement! [2010-06-10 09:19:05 - TabTest] Device API version is 8 (Android 2.2) [2010-06-10 09:19:05 - TabTest] HOME is up on device 'emulator-5554' [2010-06-10 09:19:05 - TabTest] Uploading TabTest.apk onto device 'emulator-5554' [2010-06-10 09:19:05 - TabTest] Installing TabTest.apk... [2010-06-10 09:19:22 - TabTest] Success! [2010-06-10 09:19:22 - TabTest] \TabTest\bin\TabTest.apk installed on device [2010-06-10 09:19:22 - TabTest] Done!

    Read the article

  • Delegate Example From C# In Depth Confusion

    - by ChloeRadshaw
    I am looking at this example: List<Product> products = Product. GetSampleProducts() ; products.Sort( (first, second) => first.Name.CompareTo(second. Name) ) ; foreach (Product product in products) { Console. WriteLine(product) ; } What function is actually called in the API when you do that? Does the compiler create a class which implemnents the IComparer interface? I thought delegates were anonymous methods - Here it seems to be an anonymous interface implementation which is casuing confusion

    Read the article

  • Application file (Real world example)

    - by aalhamad
    Looking for guidelines to create application file. For example I have an application that store user input into a file (Textbox, DataGrid, ListBox etc). I'm looking for WPF-C# implementation. I would like to have the following: If user edit a any form(Textbox, etc) an asterisk is displayed to the window title. When window is closed and asterisk is still there, a promote "Would you like to save changes" appears. If then saved the asterisk disappear. What do real applications use to create their application file? (Note: I'm not looking for database saving or SQL) I'm just looking for hints and guidelines. Thank you.

    Read the article

  • Difference between jQuery click, bind, live, delegate & trigger functions( with example)

    - by I Like PHP
    Hello All, I know there are a lot of questions similar to this, but I want to know clear difference between all of these jQuery functions together on this page with an example, so that it will be very helpful for me to understand the mechanism of all of these functions. I have also read the reference on jQuery main site, but there is no comparison between these: $().click(fn) $().bind('click',fn) $().live('click',fn) $().delegate('td','click',fn) $().trigger('click') // UPDATED Please do not refer any link if there is a part of question belong to that. Please describe how all four function exactly works in different manner, and which should be preferred in which situation. Note: If there are any other function with same functionality/mechanism , then please share. Thanks a lot. Update i have also seen $(trigger) function? is this works similar to above four function ?

    Read the article

  • warning: dict_ldap_lookup: Search error 1: Operations error

    - by drecute
    Please I need help with ldap search filter to use to retrieve the user email information from ldap. I'm running postfix_ldap of Ubuntu server 12.04. Everything seems to work fine, except getting the values returned from the search. Version 1 server_host = ldap://samba.example.com search_base = dc=company, dc=example, dc=com query_filter = mail=%s bind = no domain = example.com Version 2 server_host = ldap://samba.example.com search_base = dc=company, dc=example, dc=com query_filter = mail=%s bind_dn = cn=Users,dc=company,dc=example,dc=com domain = example.com mail logs Nov 26 11:13:26 mail postfix/smtpd[19662]: match_string: example.com ~? example.com Nov 26 11:13:26 mail postfix/smtpd[19662]: dict_ldap_lookup: No existing connection for LDAP source /etc/postfix/ldap-aliases.cf, reopening Nov 26 11:13:26 mail postfix/smtpd[19662]: dict_ldap_connect: Connecting to server ldap://samba.example.com Nov 26 11:13:26 mail postfix/smtpd[19662]: dict_ldap_connect: Actual Protocol version used is 3. Nov 26 11:13:26 mail postfix/smtpd[19662]: dict_ldap_connect: Binding to server ldap://samba.example.com with dn cn=Users,dc=company,dc=example,dc=com Nov 26 11:13:26 mail postfix/smtpd[19662]: warning: dict_ldap_connect: Unable to bind to server ldap://samba.example.com with dn cn=Users,dc=company,dc=example,dc=com: 49 (Invalid credentials) Nov 26 11:13:26 mail postfix/smtpd[19662]: warning: ldap:/etc/postfix/ldap-aliases.cf lookup error for "[email protected]" Nov 26 11:13:26 mail postfix/smtpd[19662]: maps_find: virtual_alias_maps: [email protected]: search aborted Nov 26 11:13:26 mail postfix/smtpd[19662]: mail_addr_find: [email protected] -> (try again) Nov 26 11:13:26 mail postfix/smtpd[19662]: NOQUEUE: reject: RCPT from col0-omc3-s2.col0.hotmail.com[65.55.34.140]: 451 4.3.0 <[email protected]>: Temporary lookup failure; from=<[email protected]> to=<[email protected]> proto=ESMTP helo=<col0-omc3-s2.col0.hotmail.com> Nov 26 11:13:26 mail postfix/smtpd[19662]: > col0-omc3-s2.col0.hotmail.com[65.55.34.140]: 451 4.3.0 <[email protected]>: Temporary lookup failure here's another log with successful search result but fialed to get the values of the result Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: Using existing connection for LDAP source /etc/postfix/ldap-aliases.cf Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: /etc/postfix/ldap-aliases.cf: Searching with filter [email protected] Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_get_values[1]: Search found 1 match(es) Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_get_values[1]: Leaving dict_ldap_get_values Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: Search returned nothing Nov 26 12:04:56 mail postfix/smtpd[20463]: maps_find: virtual_alias_maps: [email protected]: not found Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: In dict_ldap_lookup Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: /etc/postfix/ldap-aliases.cf: Skipping lookup of key 'tola.akintola': domain mismatch Nov 26 12:04:56 mail postfix/smtpd[20463]: maps_find: virtual_alias_maps: tola.akintola: not found Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: In dict_ldap_lookup Nov 26 12:04:56 mail postfix/smtpd[20463]: dict_ldap_lookup: /etc/postfix/ldap-aliases.cf: Skipping lookup of key '@example.com': domain mismatch Nov 26 12:04:56 mail postfix/smtpd[20463]: maps_find: virtual_alias_maps: @example.com: not found Nov 26 12:04:56 mail postfix/smtpd[20463]: mail_addr_find: [email protected] -> (not found) My refined ldap-aliases.cf looks like this: server_host = ldap://samba.example.com server_port = 3268 search_base = dc=company, dc=example, dc=com query_filter = mail=%s result_attribute = uid bind_dn = cn=Administrator,cn=Users,dc=company,dc=example,dc=com bind_pw = pass domain = example.com So I'll like to know what ldap filter is appropriate to get this to work. Thanks for helping out.

    Read the article

  • Moq Testing a private method .Many posts but still cannot make one example work

    - by devnet247
    Hi, I have seen many posts and questions about "Mocking a private method" but still cannot make it work and not found a real answer. Lets forget the code smell and you should not do it etc.... From what I understand I have done the following: 1) Created a class Library "MyMoqSamples" 2) Added a ref to Moq and NUnit 3) Edited the AssemblyInfo file and added [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] [assembly: InternalsVisibleTo("MyMoqSamples")] 4) Now need to test a private method.Since it's a private method it's not part of an interface. 5) added the following code [TestFixture] public class Can_test_my_private_method { [Test] public void Should_be_able_to_test_my_private_method() { //TODO how do I test my DoSomthing method } } public class CustomerInfo { public string Name { get; set; } public string Surname { get; set; } } public interface ICustomerService { List<CustomerInfo> GetCustomers(); } public class CustomerService: ICustomerService { public List<CustomerInfo> GetCustomers() { return new List<CustomerInfo> {new CustomerInfo {Surname = "Bloggs", Name = "Jo"}}; } protected virtual void DoSomething() { } } Could you provide me an example on how you would test my private method? Thanks a lot

    Read the article

  • JQuery - Slide Example

    - by gav
    Hi All, I want to perform a simple slide motion on an HTML element. JQuery is already available on the site in question so the next logical step for me was to look at their documentation. JQuery - Slide down When I check out their demo however, it doesn't seem to be functioning. In firebug they have an error; missing ) after argument list wyciwyg://0/http://docs.jquery.com/UI/Effects/Slide Line 18 Whilst the error seems simple, I can't work out how to correct it (On thier site by editing the JS). On my own site using the same example an error is found in the JQuery 1.4.2 script itself; jQuery.easing[specialEasing || defaultEasing] is not a function file:///home/gav/ee-workspaces/web/site/php/jquery-1.4.2.js Line 5854 I don't mean to sound lazy / rude but what's going on? Is the JQuery site and newest release actually broken, I doubt it, what am I doing wrong? I'm a CS grad with no real web dev experience so I'm not used to this method of debugging, where should I start with this? Thanks, Gav

    Read the article

  • trying to delete a song from a list UITableView sigbart error - addMusic Example

    - by Pavan
    hi im trying to implement a delete feature into the addmusic example this is the code ive added it doesnt work, i cant get my head around whats wrong. can someone please tell me whats wrong and what i need to do to make sure it works. - (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath { } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // If row is deleted, remove it from the list. if (editingStyle == UITableViewCellEditingStyleDelete) { MainViewController *mainViewController = (MainViewController *) self.delegate; NSUInteger index = [indexPath row]; MPMediaItem *itemToDelete = [mainViewController.userMediaItemCollection mediaItemAtIndex:index]; if ([itemToDelete isEqual:mainViewController.musicPlayer.nowPlayingItem]) { [mainViewController.musicPlayer skipToNextItem]; } MPMediaItemCollection *newCollection = [mainViewController.userMediaItemCollection collectionByDeletingMediaItemAtIndex:index]; mainViewController.userMediaItemCollection = newCollection; NSUInteger indices[] = {0, index}; NSIndexPath *deletePath = [NSIndexPath indexPathWithIndexes:indices length:2]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:deletePath] withRowAnimation:UITableViewRowAnimationFade]; I also get these warnings when i compile the program and run it: heres the image: http://www.freeimagehosting.net/uploads/6e42f166b9.png Any ideas and help appreciated.

    Read the article

  • OSMDroid simple example required

    - by Bex
    Hi! I am trying to create an app that uses offline maps and custom tiles. For this I have decided to use OSMDroid and have included the jar within my project. I will create my custom tiles using MOBAC. I have been directed to these examples: http://code.google.com/p/osmdroid/source/browse/#svn%2Ftrunk%2FOpenStreetMapViewer%2Fsrc%2Forg%2Fosmdroid%2Fsamples but I am struggling to follow them as I am new to both java and android. I have created a class file called test (which I have created following an example!): public class test extends Activity { /** Called when the activity is first created. */ protected static final String PROVIDER_NAME = LocationManager.GPS_PROVIDER; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); MapView map = (MapView) findViewById(R.id.map); map.setTileSource(TileSourceFactory.MAPQUESTOSM); map.setBuiltInZoomControls(true); map.setMultiTouchControls(true); map.getController().setZoom(16); map.getController().setCenter(new GeoPoint(30266000, -97739000)); } } with a layout file: <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <org.osmdroid.views.MapView android:id="@+id/map" android:layout_width="fill_parent" android:layout_height="fill_parent" tilesource="MapquestOSM" android:layout_weight="1" /> </LinearLayout> When I run this I see no map, just an empty grid. I think this is due to my tilesource but I'm not sure what I need to change it to. Can anyone help? Bex

    Read the article

  • Running Hadoop example in psuedo-distributed mode on vm

    - by manas
    I have set-up Hadoop on a OpenSuse 11.2 VM using Virtualbox.I have made the prerequisite configs. I ran this example in the Standalone mode successfully. But in psuedo-distributed mode I get the following error: $./bin/hadoop fs -put conf input 10/04/13 15:56:25 INFO hdfs.DFSClient: Exception in createBlockOutputStream java.net.SocketException: Protocol not available 10/04/13 15:56:25 INFO hdfs.DFSClient: Abandoning block blk_-8490915989783733314_1003 10/04/13 15:56:31 INFO hdfs.DFSClient: Exception in createBlockOutputStream java.net.SocketException: Protocol not available 10/04/13 15:56:31 INFO hdfs.DFSClient: Abandoning block blk_-1740343312313498323_1003 10/04/13 15:56:37 INFO hdfs.DFSClient: Exception in createBlockOutputStream java.net.SocketException: Protocol not available 10/04/13 15:56:37 INFO hdfs.DFSClient: Abandoning block blk_-3566235190507929459_1003 10/04/13 15:56:43 INFO hdfs.DFSClient: Exception in createBlockOutputStream java.net.SocketException: Protocol not available 10/04/13 15:56:43 INFO hdfs.DFSClient: Abandoning block blk_-1746222418910980888_1003 10/04/13 15:56:49 WARN hdfs.DFSClient: DataStreamer Exception: java.io.IOException: Unable to create new block. at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream(DFSClient.java:2845) at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2000(DFSClient.java:2102) at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run(DFSClient.java:2288) 10/04/13 15:56:49 WARN hdfs.DFSClient: Error Recovery for block blk_-1746222418910980888_1003 bad datanode[0] nodes == null 10/04/13 15:56:49 WARN hdfs.DFSClient: Could not get block locations. Source file "/user/max/input/core-site.xml" - Aborting... put: Protocol not available 10/04/13 15:56:49 ERROR hdfs.DFSClient: Exception closing file /user/max/input/core-site.xml : java.net.SocketException: Protocol not available java.net.SocketException: Protocol not available at sun.nio.ch.Net.getIntOption0(Native Method) at sun.nio.ch.Net.getIntOption(Net.java:178) at sun.nio.ch.SocketChannelImpl$1.getInt(SocketChannelImpl.java:419) at sun.nio.ch.SocketOptsImpl.getInt(SocketOptsImpl.java:60) at sun.nio.ch.SocketOptsImpl.sendBufferSize(SocketOptsImpl.java:156) at sun.nio.ch.SocketOptsImpl$IP$TCP.sendBufferSize(SocketOptsImpl.java:286) at sun.nio.ch.OptionAdaptor.getSendBufferSize(OptionAdaptor.java:129) at sun.nio.ch.SocketAdaptor.getSendBufferSize(SocketAdaptor.java:328) at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.createBlockOutputStream(DFSClient.java:2873) at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.nextBlockOutputStream(DFSClient.java:2826) at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream.access$2000(DFSClient.java:2102) at org.apache.hadoop.hdfs.DFSClient$DFSOutputStream$DataStreamer.run(DFSClient.java:2288) Any leads will be highly appreciated.

    Read the article

  • Example with Visitor Pattern

    - by devoured elysium
    public class Song { public string Genre { get; protected set; } public string Name { get; protected set; } public string Band { get; protected set; } public Song(string name, string band, string genre) { Name = name; Genre = genre; Band = band; } } public interface IMusicVisistor { void Visit(List<Song> items); } public class MusicLibrary { List<Song> _songs = new List<Song> { ...songs ... }; public void Accept(IMusicVisitor visitor) { visitor.Visit(_songs); } } and now here's one Visitor I made: public class RockMusicVisitor : IMusicVisitor { public List<Song> Songs { get; protected set; } public void Visit(List<Song> items) { Songs = items.Where(x => x.Genre == "Rock").ToList(); } } Why is this any better than just putting a public property Songs and then letting any kind of class do with it anything that it wants to? This example comes from this post.

    Read the article

  • C# Help with a basic pedagogic example of a BackGroundWorker process populating a DataGridView

    - by Roger
    Scenario: I have a windows form that holds a DataGridWiew with 3 pre-defined columns. I have 3 variables declared outside the function and assigned to inside the function. I have a function that enumerates stuff and puts it in the 3 columns, line by line: string VARIABLE1; string VARIABLE2; string VARIABLE3; private void FunctionEnumerateStuff() { foreach (StuffObject STUFF in StuffCollection) { VARIABLE1 = STUFF.SubStuff1.ToString(); VARIABLE2 = STUFF.SubStuff2.ToString(); VARIABLE3 = STUFF.SubStuff3.ToString(); DatagridWiew1.Rows.Add(VALUE1, VALUE2, VALUE3); } } What I want to do, is to execute this function from a BackGroundWorker process, so that the GUI of the application will be smooth and responsive. I have read up on backgroundworkers but I am having trouble relating, because all examples seems to be of entirely different scenarios and most of them are overwelmingly complex. San some helpful pedagogic soul help me and others with a very basic example of how to get this to work in the simplest way possible. Thanks.

    Read the article

  • delete UITableView row apple addMusic example

    - by Pavan
    Hi, i am trying to add a swipe to delete feature to the addmusic example project (downloaded free from apple) so that i am able able to delete a specific row. Ive added the following code just so that i can enable to delete feature but i dont know how to remove the song from the list which i believe to be the mediaItemCollection and actually deleting it from the userMediaItemCollection which is used to queue the songs to the player. - (void)tableView:(UITableView*)tableView willBeginEditingRowAtIndexPath:(NSIndexPath *)indexPath { } - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { // If row is deleted, remove it from the list. if (editingStyle == UITableViewCellEditingStyleDelete) { // delete your data item here // Animate the deletion from the table. [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationFade]; } } The swipe to delete feature works nicely, the delete button only appears when swiped, but when i click delete, a SIGBART error occurs, the whole application freezes, (although the musix does continue to play, lol). Can someone please tell me how i can delete the row at that index and how i can delete it from the mediaitemcollection please. When taking that single line of code out: [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath]withRowAnimation:UITableViewRowAnimationFade]; the swipe to delete works, except that it does not delete anything obviously since i havent added any actual delete functionality/coding that needs to be done. All ideas appreciated.

    Read the article

  • Trying to build the basic python extension example fails (windows)

    - by Alexandros
    Hello, I have Python 2.6 and Visual Studio 2008 running on a Win7 x64 machine. When I try to build the basic python extension example in c "example_nt" as found in the python 2.6 sources distribution, it fails: python setup.py build And this results in: running build running build_ext building 'aspell' extension Traceback (most recent call last): File "setup.py", line 7, in <module> ext_modules = [module1]) File "C:\Python26\lib\distutils\core.py", line 152, in setup dist.run_commands() File "C:\Python26\lib\distutils\dist.py", line 975, in run_commands self.run_command(cmd) File "C:\Python26\lib\distutils\dist.py", line 995, in run_command cmd_obj.run() File "C:\Python26\lib\distutils\command\build.py", line 134, in run self.run_command(cmd_name) File "C:\Python26\lib\distutils\cmd.py", line 333, in run_command self.distribution.run_command(command) File "C:\Python26\lib\distutils\dist.py", line 995, in run_command cmd_obj.run() File "C:\Python26\lib\distutils\command\build_ext.py", line 343, in run self.build_extensions() File "C:\Python26\lib\distutils\command\build_ext.py", line 469, in build_extensions self.build_extension(ext) File "C:\Python26\lib\distutils\command\build_ext.py", line 534, in build_extension depends=ext.depends) File "C:\Python26\lib\distutils\msvc9compiler.py", line 448, in compile self.initialize() File "C:\Python26\lib\distutils\msvc9compiler.py", line 358, in initialize vc_env = query_vcvarsall(VERSION, plat_spec) File "C:\Python26\lib\distutils\msvc9compiler.py", line 274, in query_vcvarsall raise ValueError(str(list(result.keys()))) ValueError: [u'path'] What can I do to fix this? Any help will be appreciated

    Read the article

  • Avoiding anemic domain model - a real example

    - by cbp
    I am trying to understand Anemic Domain Models and why they are supposedly an anti-pattern. Here is a real world example. I have an Employee class, which has a ton of properties - name, gender, username, etc public class Employee { public string Name { get; set; } public string Gender { get; set; } public string Username { get; set; } // Etc.. mostly getters and setters } Next we have a system that involves rotating incoming phone calls and website enquiries (known as 'leads') evenly amongst sales staff. This system is quite complex as it involves round-robining enquiries, checking for holidays, employee preferences etc. So this system is currently seperated out into a service: EmployeeLeadRotationService. public class EmployeeLeadRotationService : IEmployeeLeadRotationService { private IEmployeeRepository _employeeRepository; // ...plus lots of other injected repositories and services public void SelectEmployee(ILead lead) { // Etc. lots of complex logic } } Then on the backside of our website enquiry form we have code like this: public void SubmitForm() { var lead = CreateLeadFromFormInput(); var selectedEmployee = Kernel.Get<IEmployeeLeadRotationService>() .SelectEmployee(lead); Response.Write(employee.Name + " will handle your enquiry. Thanks."); } I don't really encounter many problems with this approach, but supposedly this is something that I should run screaming from because it is an Anemic Domain Model. But for me its not clear where the logic in the lead rotation service should go. Should it go in the lead? Should it go in the employee? What about all the injected repositories etc that the rotation service requires - how would they be injected into the employee, given that most of the time when dealing with an employee we don't need any of these repositories?

    Read the article

  • win32 console - form example!

    - by Bach
    I'm trying to build a simple form in a c++ win32 console application. instead of using cin and keep prompting the user to enter the details, i would like to display the form labels then using the tab key, allow the user to tab through. What is the simplest way of doing this, without having to use ncurses? all I need is cout the below all at once: Name: Username: Email: set the cursor position next to name Field, then each time you hit tab, i gotoxy, and set the cursor at the next position, then set the the cin to the next variable eg. at startup gotoxy(nameX, nameY); cin >> name; Hit Tab/enter gotoxy(usernameX, usernameY); cin >> username; Hit Tab/enter gotoxy(emailX, emailY); cin >> email; is this even doable? I tried while loops with, GetAsyncKeyState, and keyboard events, but the cin is not working properly in that loop. is there any good example for a super simple form, or reference for doing that? I know how to SetConsoleCursorPosition, but how to implement the tabbing while still being able to capture cin? thanks

    Read the article

  • Mutex example / tutorial ?

    - by Nav
    I've noticed that asking questions for the sake of creating a reference list etc. is encouraged in SO. This is one such question, so that anyone Googling for a mutex tutorial will find a good one here. I'm new to multithreading, and was trying to understand how mutexes work. Did a lot of Googling and this is the only decent tutorial I found, but it still left some doubts of how it works because I created my own program and the locking didn't work. One absolutely non-intuitive syntax of the mutex is pthread_mutex_lock( &mutex1 );, where it looks like the mutex is being locked, when what I really want to lock is some other variable. Does this syntax mean that locking a mutex locks a region of code until the mutex is unlocked? Then how do threads know that the region is locked? And isn't such a phenomenon supposed to be called critical section? In short, could you please help with the simplest possible mutex example program and the simplest possible explanation on the logic of how it works? I'm sure this will help plenty of other newbies.

    Read the article

  • Kernighan & Ritchie word count example program in a functional language

    - by Frank
    I have been reading a little bit about functional programming on the web lately and I think I got a basic idea about the concepts behind it. I'm curious how everyday programming problems which involve some kind of state are solved in a pure functional programing language. For example: how would the word count program from the book 'The C programming Language' be implemented in a pure functional language? Any contributions are welcome as long as the solution is in a pure functional style. Here's the word count C code from the book: #include <stdio.h> #define IN 1 /* inside a word */ #define OUT 0 /* outside a word */ /* count lines, words, and characters in input */ main() { int c, nl, nw, nc, state; state = OUT; nl = nw = nc = 0; while ((c = getchar()) != EOF) { ++nc; if (c == '\n') ++nl; if (c == ' ' || c == '\n' || c = '\t') state = OUT; else if (state == OUT) { state = IN; ++nw; } } printf("%d %d %d\n", nl, nw, nc); }

    Read the article

  • Cassandra Batch_insert example in C#.net

    - by Sandeep
    Can any one please give me an example on how to work on Cassandra batch_insert in C# thrift client? If possible please let me know where am I going wrong in the following code. Dictionary dictionary = new Dictionary(); Dictionary subColumns = new Dictionary(); List listOfMutations = new List(); listOfMutations.Add(new Mutation() { Column_or_supercolumn = new ColumnOrSuperColumn() { Column = new Column() { Name = utf8Encoding.GetBytes("AA"), Value = utf8Encoding.GetBytes("Answer Automation"), Timestamp = timeStamp } } }); listOfMutations.Add(new Mutation() { Column_or_supercolumn = new ColumnOrSuperColumn() { Column = new Column() { Name = utf8Encoding.GetBytes("CT"), Value = utf8Encoding.GetBytes("Call Tracker"), Timestamp = timeStamp } } }); listOfMutations.Add( new Mutation() { Column_or_supercolumn = new ColumnOrSuperColumn() { Column = new Column() { Name = utf8Encoding.GetBytes("TL"), Value = utf8Encoding.GetBytes("Track That Lead"), Timestamp = timeStamp } } }); SuperColumn superColumn = new SuperColumn() { Name=utf8Encoding.GetBytes("Indatus") }; subColumns.Add("Super1", listOfMutations); dictionary.Add("Indatus", subColumns); client.batch_mutate("Keyspace1",dictionary, ConsistencyLevel.ONE); I understand that SuperColumn struct expects List but I does not have a list of Columns. Rather I have List. Thanks in Advance.

    Read the article

  • iPhone SpeakHere example produces different number of samples

    - by pion
    I am looking at the SpeakHere example and added the following: // Overriding the output audio route UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; AudioSessionSetProperty(kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride); assert(status == noErr); // Changing the default output route. The new output route remains in effect unless you change the audio session category. This option is available starting in iPhone OS 3.1. UInt32 doChangeDefaultRoute = 1; status = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryDefaultToSpeaker, sizeof(doChangeDefaultRoute), &doChangeDefaultRoute); assert(status == noErr); // Enable Bluetooth. See audioRouteOverride & doChangeDefaultRoute above // http://developer.apple.com/iphone/library/documentation/Audio/Conceptual/AudioSessionProgrammingGuide/Cookbook/Cookbook.html#//apple_ref/doc/uid/TP40007875-CH6-SW2 UInt32 allowBluetoothInput = 1; status = AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof(allowBluetoothInput), &allowBluetoothInput); assert(status == noErr); Also, void AQRecorder::handleInputBufferCallback(void *aqData, ... ... if (inNumPackets > 0) { NSLog(@"Number of samples = %d", inBuffer->mAudioDataByteSize/2); // print out the number of sample status = AudioFileWritePackets(aqr->mAudioFile, FALSE, inBuffer->mAudioDataByteSize, inPacketDesc, aqr->mCurrentPacket, &inNumPackets, inBuffer->mAudioData); assert(status == noErr); aqr->mCurrentPacket += inNumPackets; } ... Notice the "NSLog(@"Number of samples = %d", inBuffer-mAudioDataByteSize/2); // print out the number of sample" statement above. I am using iPhone SDK 3.1.3. I got the following results The number of samples is around 44,100 on Simulator The number of samples is around 22,000 on iPhone The number of samples is around 4,000 on iPhone using Jawbone Bluetooth I am new on this. Why did itproduce different number of samples? Thanks in advance for your help.

    Read the article

  • Learn Prolog Now! DCG Practice Example

    - by Timothy
    I have been progressing through Learn Prolog Now! as self-study and am now learning about Definite Clause Grammars. I am having some difficulty with one of the Practical Session's tasks. The task reads: The formal language anb2mc2mdn consists of all strings of the following form: an unbroken block of as followed by an unbroken block of bs followed by an unbroken block of cs followed by an unbroken block of ds, such that the a and d blocks are exactly the same length, and the c and d blocks are also exactly the same length and furthermore consist of an even number of cs and ds respectively. For example, ε, abbccd, and aaabbbbccccddd all belong to anb2mc2mdn. Write a DCG that generates this language. I am able to write rules that generate andn, b2mc2m, and even anb2m and c2mndn... but I can't seem to join all these rules into anb2mc2mdn. The following are my rules that can generate andn and b2mc2m. s1 --> []. s1 --> a,s1,d. a --> [a]. d --> [d]. s2 --> []. s2 --> c,c,s2,d,d. c --> [c]. d --> [d]. Is anb2mc2mdn really a CFG, and is it possible to write a DCG using only what was taught in the lesson (no additional arguments or code, etc)? If so, can anyone offer me some guidance how I can join these so that I can solve the given task?

    Read the article

  • DNS protocol message example

    - by virtual-lab
    hello there, I am trying to figure out how to send out DNS messages from an application socket adapter to a DNSBL. I spent the last two days understanding the basics, including experimenting with WireShark to catch an example of message exchanged. Now I would like to query the DNS without using dig or host command (I'm using Ubuntu); how can I perform this action at low level, without the help of these tools in wrapping the request in a proper DNS message format? How the message should be post it? Hex or String? Thanks in advance for any help. Regards Alessandro Ilardo Comment added I am investigating on JDev and Oracle SOA. The platform provides a Socket Adapter which simply apply a transformation (XSLT) and send the message straight to the socket. How the payload parameters (ex. the host I'm looking up) are wrapped within the message is left to the developer. So basically I have an idea on how the all DNS message is structured, but rather than put everything on JDev stright away I'd like to make some tests on my own just to make sure I got a valid message format. So, I am not using any specific language (I don't even understand why they moved my question from serverfault) and I don't want to use any tools which would hide part of the message, such as the header. I know they work well btw. I guess this stuff has something to do with packet injection. Someone suggested me to use telnet, but I've only used for SMTP or HTTP, I haven't got a clue on how it works for DNS request. Does it make more sense now?

    Read the article

  • Downloading a webpage in C# example

    - by Chris
    I am trying to understand some example code on this web page: (http://www.csharp-station.com/HowTo/HttpWebFetch.aspx) that downloads a file from the internet. The piece of code quoted below goes through a loop getting chunks of data and saving them to a string until all the data has been downloaded. As I understand it, "count" contains the size of the downloaded chunk and the loop runs until count is 0 (an empty chunk of data is downloaded). My question is, isn't it possible that count could be 0 without the file being completely downloaded? Say if the network connection is interrupted, the stream may not have any data to read on a pass of the loop and count should be 0, ending the download prematurely. Or does ResStream.Read stop the program until it gets data? Is this the correct way to save a stream? int count = 0; do { // fill the buffer with data count = resStream.Read(buf, 0, buf.Length); // make sure we read some data if (count != 0) { // translate from bytes to ASCII text tempString = Encoding.ASCII.GetString(buf, 0, count); // continue building the string sb.Append(tempString); } } while (count 0); // any more data to read?

    Read the article

< Previous Page | 14 15 16 17 18 19 20 21 22 23 24 25  | Next Page >