Search Results

Search found 12222 results on 489 pages for 'initial context'.

Page 97/489 | < Previous Page | 93 94 95 96 97 98 99 100 101 102 103 104  | Next Page >

  • Play! Framework - Can my view template be localised when rendering it as an AsyncResult?

    - by avik
    I've recently started using the Play! framework (v2.0.4) for writing a Java web application. In the majority of my controllers I'm following the paradigm of suspending the HTTP request until the promise of a web service response has been fulfilled. Once the promise has been fulfilled, I return an AsyncResult. This is what most of my actions look like (with a bunch of code omitted): public static Result myActionMethod() { Promise<MyWSResponse> wsResponse; // Perform a web service call that will return the promise of a MyWSResponse... return async(wsResponse.map(new Function<MyWSResponse, Result>() { @Override public Result apply(MyWSResponse response) { // Validate response... return ok(myScalaViewTemplate.render(response.data())); } })); } I'm now trying to internationalise my app, but hit the following error when I try to render a template from an async method: [error] play - Waiting for a promise, but got an error: There is no HTTP Context available from here. java.lang.RuntimeException: There is no HTTP Context available from here. at play.mvc.Http$Context.current(Http.java:27) ~[play_2.9.1.jar:2.0.4] at play.mvc.Http$Context$Implicit.lang(Http.java:124) ~[play_2.9.1.jar:2.0.4] at play.i18n.Messages.get(Messages.java:38) ~[play_2.9.1.jar:2.0.4] at views.html.myScalaViewTemplate$.apply(myScalaViewTemplate.template.scala:40) ~[classes/:na] at views.html.myScalaViewTemplate$.render(myScalaViewTemplate.template.scala:87) ~[classes/:na] at views.html.myScalaViewTemplate.render(myScalaViewTemplate.template.scala) ~[classes/:na] In short, where I've got a message bundle lookup in my view template, some Play! code is attempting to access the original HTTP request and retrieve the accept-languages header, in order to know which message bundle to use. But it seems that the HTTP request is inaccessible from the async method. I can see a couple of (unsatisfactory) ways to work around this: Go back to the 'one thread per request' paradigm and have threads block waiting for responses. Figure out which language to use at Controller level, and feed that choice into my template. I also suspect this might not be an issue on trunk. I know that there is a similar issue in 2.0.4 with regards to not being able to access or modify the Session object which has recently been fixed. However I'm stuck on 2.0.4 for the time being, so is there a better way that I can resolve this problem?

    Read the article

  • Image Handler for Sharepoint Not Working

    - by Peter
    My ImageHandler.ashx is not working when the webpart is calling it. any ideas on what is the correct way on calling or adding a handler in sharepoint? Thanks in advance Here My ImageHandler.ashx code byte[] buffer = (byte[])image.ImageData; context.Response.ContentType = "image/jpeg"; context.Response.OutputStream.Write(buffer, 0, buffer.Length); In my webpart imgcontrol.ImageUrl = "ImageHandler.aspx?id=1";

    Read the article

  • Infinite sharing system (PHP/MySQLi)

    - by Toine Lille
    I'm working on a discount system for whichever customer shares a product and brings in new customers. Each unique visit = $0.05 off, each new customer = $0.50 off (it's a cheap product so yeah, no big numbers). When a new customer shares the site, the customer initially responsible for the new customer (if any) will get half of the new customer's discount as well. The initial customer would get a fourth for the next level and the new customer half of that, etc, creating a tree or pyramid that way that could be infinite. Initial customer ($1.35 discount: 2 new+3 visits + half of 1 new+2 visits) Visitor ($0) Visitor ($0) New customer ($0.60) Visitor ($0) Visitor ($0) Newer customer ($0) New customer ($0) Visitor ($0) The customers are saved along with their IP addresses (bin2hex(inet_pton)) in a database table (customers) with info like a unique id, e-mail address and first date/time the purchased a product (= time of registration). The shares are saved in a separate table within the same database (sharing). Each unique IP addresses that visits the site creates a new row featuring the IP address (also saved as bin2hex(inet_pton)), the id of the customer who shared it and the date/time of the visit. Sharing goes via URL, featuring a GET element containing the customer's id. Visits and new customers overlap, as visits will always occur before the new customer does. That's fine. The date/times are used just to make it a little more secure (I also use the IP along with cookies to see if people cheat the system). If an IP is already in the sharing or customer tables, it does not count and will not create a new entry. Now the problem is, how to make the infinity happen and apply the different values to it? That's all I'd need to know. It needs to calculate the discount for each customer separately, but also allow for monitoring altogether (though that's just a matter of passing all ID's through it). I figured I'd start (after the database connection) with $stmt = $con->prepare('SELECT ip,datetime FROM sharing WHERE sender=?'); $stmt->bind_param('i',$customerid); $stmt->execute(); $stmt->store_result(); $discount = $discount + ($stmt->num_rows * 0.05); $stmt->bind_result($ip,$timeofsharing); to translate all the visits to $0.05 of discount each. To check for the new customers that came from these visits, I wrote the following: while ($sql->fetch()) { $stmt2 = $con->prepare("SELECT datetime FROM users WHERE ip=?"); $stmt2->bind_param('s',$ip); $stmt2->execute(); $stmt2->store_result(); $stmt2->bind_result($timeofpurchase); Followed by a little more security comparing the datetimes: while ($stmt2->fetch()) { if (strtotime($timeofpurchase) < strtotime($timeofsharing)) { $discount = $discount + $0.50; } But this is just for the initial customer's direct results. If I'd want to check for the next level, I'd basically have to put the exact same check and loop in itself, checking each new customer the initial customer they brought to the site, and then for the next level again to check all of the newer customers, etc, etc. What to do? / Where to go? / What would be the correct practice for this? Thanks!

    Read the article

  • Silverlight Handle App MouseLeftButtonDown?

    - by user492488
    Hi All, In my silverlight project I have a Context Menu (right click menu) that I want to close it if I click anywhere outside it. I add handler to the click event on App: AddHandler App.Current.RootVisual.MouseLeftButtonDown, AddressOf HideMenu But the problem that: it does not enter the Handler when I click on any other command, or click on the same control that have the context menu, it is enter only when I click on an empty area outside the menu. Thanks.

    Read the article

  • Converting a pointer C# type to F#??

    - by Brendon
    Hello all I am just a beginner in programing i wish covert some code from C# to F#, I have encotered this code: "float[] v1=new float[10]" I need to use this pointer to pass to the function: "ComputeBuffer bufV1 = new ComputeBuffer(Context, ComputeMemoryFlags.ReadWrite | ComputeMemoryFlags.UseHostPointer, v1);" If i creat an array in F# like this: "let v1 = [| 1.0..10.0 |]" and call now the funaction like this: "let bufV1 = new ComputeBuffer(Context, ComputeMemoryFlags.ReadWrite ||| ComputeMemoryFlags.UseHostPointer, v1)" Is it an error?? How do i pass a pointer??

    Read the article

  • Why does OpenGL's glDrawArrays() fail with GL_INVALID_OPERATION under Core Profile 3.2, but not 3.3 or 4.2?

    - by metaleap
    I have OpenGL rendering code calling glDrawArrays that works flawlessly when the OpenGL context is (automatically / implicitly obtained) 4.2 but fails consistently (GL_INVALID_OPERATION) with an explicitly requested OpenGL core context 3.2. (Shaders are always set to #version 150 in both cases but that's beside the point here I suspect.) According to specs, there are only two instances when glDrawArrays() fails with GL_INVALID_OPERATION: "if a non-zero buffer object name is bound to an enabled array and the buffer object's data store is currently mapped" -- I'm not doing any buffer mapping at this point "if a geometry shader is active and mode? is incompatible with [...]" -- nope, no geometry shaders as of now. Furthermore: I have verified & double-checked that it's only the glDrawArrays() calls failing. Also double-checked that all arguments passed to glDrawArrays() are identical under both GL versions, buffer bindings too. This happens across 3 different nvidia GPUs and 2 different OSes (Win7 and OSX, both 64-bit -- of course, in OSX we have only the 3.2 context, no 4.2 anyway). It does not happen with an integrated "Intel HD" GPU but for that one, I only get an automatic implicit 3.3 context (trying to explicitly force a 3.2 core profile with this GPU via GLFW here fails the window creation but that's an entirely different issue...) For what it's worth, here's the relevant routine excerpted from the render loop, in Golang: func (me *TMesh) render () { curMesh = me curTechnique.OnRenderMesh() gl.BindBuffer(gl.ARRAY_BUFFER, me.glVertBuf) if me.glElemBuf > 0 { gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, me.glElemBuf) gl.VertexAttribPointer(curProg.AttrLocs["aPos"], 3, gl.FLOAT, gl.FALSE, 0, gl.Pointer(nil)) gl.DrawElements(me.glMode, me.glNumIndices, gl.UNSIGNED_INT, gl.Pointer(nil)) gl.BindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0) } else { gl.VertexAttribPointer(curProg.AttrLocs["aPos"], 3, gl.FLOAT, gl.FALSE, 0, gl.Pointer(nil)) /* BOOM! */ gl.DrawArrays(me.glMode, 0, me.glNumVerts) } gl.BindBuffer(gl.ARRAY_BUFFER, 0) } So of course this is part of a bigger render-loop, though the whole "*TMesh" construction for now is just two instances, one a simple cube and the other a simple pyramid. What matters is that the entire drawing loop works flawlessly with no errors reported when GL is queried for errors under both 3.3 and 4.2, yet on 3 nvidia GPUs with an explicit 3.2 core profile fails with an error code that according to spec is only invoked in two specific situations, none of which as far as I can tell apply here. What could be wrong here? Have you ever run into this? Any ideas what I have been missing?

    Read the article

  • How to deploy the same webapp with different logging? (Tomcat, Solr)

    - by Karussell
    We are using multiple solr instances on tomcat but want that they log into different log files. How could we do this? We are using the follwing xml file under tomcat/conf/Catalina/localhost to make it working: <Context docBase="/pathtosolr/dist/apache-solr-1.4.0.war" debug="0" crossContext="true" > <Environment name="solr/home" type="java.lang.String" value="/pathtosolr/solr" override="true" /> </Context>

    Read the article

  • call a python function in another class from a class?

    - by user3527697
    hi i'am begginer in pYthon and openerp , i want to call a function exists in another class for example: i have 2 class : class a: def notif_personne_event(self, cr, uid,ids,context=None): and import a class b: notifier(self, cr, uid,ids,context=None): self.notifiernotif_personne_event() but when i do this an error is displayed telling me that class b have not an attribute notifiernotif_personne_event() someone help me please

    Read the article

  • RequestFactoryEditorDriver getting edited data after flush

    - by Deanna
    Let me start with I have a solution, but I don't really think it is elegant. So, I am looking for a cleaner way to do this. I have an EntityProxy displayed in a view panel. The view panel is a RequestFactoryEditorDriver only using display mode. The user clicks on a data element and opens a popup editor to edit a data element of the EntityProxy with a few more bits of data than is displayed in the view panel. When the user saves the element I need the view panel to update the display. I ran into a problem because the RequestFactoryEditorDriver of the popup editor flow doesn't let you get to the edited data. The driver uses the passed in context and sends it to the server. The context returned out of flush only allows a Receiver even if you cast it to the type of context you stored in the editor driver in the edit() call. It doesn't appear to send and EntityProxyChanged event either, so I couldn't listen for that and update the display view. The solution I found was to change my domain object persist to return the newly saved entity. Then create the popup editor like this editor.getSaveButtonClickHandler().addClickHandler(createSaveHandler(driver, editor)); // initialize the Driver and edit the given text. driver.initialize(rf, editor); PlayerProfileCtx ctx = rf.playerProfile(); ctx.persist().using(playerProfile).with(driver.getPaths()) .to(new Receiver<PlayerProfileProxy>(){ @Override public void onSuccess(PlayerProfileProxy profile) { editor.hide(); playerProfile = profile; viewDriver.display(playerProfile); } }); driver.edit(playerProfile, ctx); editor.centerAndShow(); Then in the save handler I just fire the context I get from the flush. While this approach works, it doesn't seem right. It would seem I should subscribe to the entitychanged event in the display view and update the entity and the view from there. Also this approach saves the complete entity, not just the changed bits, which will increase bandwidth usage. What I would think should happen, is when you flush the entity it should 'optimistically' update the rf managed version of the entity and fire the entity proxy changed event. Only reverting the entity if something went wrong in the save. The actual save should only send the changed bits. In this way there isn't a need to refetch the whole entity and send that complete data over the wire twice. Is there a better solution?

    Read the article

  • Query Entity Framework 4

    - by nick
    Hi, Is it possible to run a query on an EF4.0 data context and get all objects of a certain type? Say the context has books, genres & authors but I only have a generic parameter, t. Is it possible to get all of type just by using this t? I don't think it is :(

    Read the article

  • Objective-C: iPad Crash When Screen Shot Button Clicked

    - by SeongHo
    OK, i am making a Coloring app and it has a "Save" button that will take the screen shot of the view where the drawing is. I have 6 images to color. In the intro page there 6 buttons, each will link you to a particular coloring page. All are working well including the "Save" button except for one. All coloring views has the same contents and functions but in one image, it crashes the iPad whenever i clicked the "Save" button. Here's some of my codes: On Button Click: [self saveScreenshotToPhotosAlbum]; camFlash = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 1024, 768)]; [camFlash setBackgroundColor:[UIColor whiteColor]]; [camFlash setAlpha:0.0]; [cbHolder addSubview:camFlash]; [cbHolder bringSubviewToFront:camFlash]; [UIView beginAnimations:@"Flash-On" context:NULL]; [UIView setAnimationDuration:0.2]; [UIView setAnimationRepeatAutoreverses:NO]; [camFlash setAlpha:1.0]; [UIView commitAnimations]; NSString *soundPath = [[NSBundle mainBundle] pathForResource:@"flash" ofType:@"wav"]; AVAudioPlayer *flashSFX = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:soundPath] error:NULL]; flashSFX.volume = 0.5; flashSFX.numberOfLoops = 0; self->camFlashSFX = flashSFX; if ([flashSFX currentTime] != 0) [flashSFX setCurrentTime:0]; [flashSFX play]; [self performSelector:@selector(removeFlash) withObject:nil afterDelay:0.2]; Remove Flash: - (void) removeFlash { [camFlash removeFromSuperview]; } For the screenshot: - (UIImage*)captureView { UIGraphicsBeginImageContext(CGSizeMake(1024, 768)); CGContextRef context = UIGraphicsGetCurrentContext(); [cbHolder.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } - (void)saveScreenshotToPhotosAlbum { UIImageWriteToSavedPhotosAlbum([self captureView], nil, nil, nil); } This one is for the button that will show the coloring page: uc4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tpUncolored1.png"]]; [uc4 setUserInteractionEnabled:YES]; [uc4 setFrame:CGRectMake(0, 0, 1024, 768)]; [cbHolder addSubview:uc4]; clrd4 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tpColored1.png"]]; [clrd4 setUserInteractionEnabled:YES]; [clrd4 setFrame:CGRectMake(0, 0, 1024, 768)]; [cbHolder addSubview:clrd4]; [UIView beginAnimations:@"fabe-out" context:NULL]; [UIView setAnimationDuration:1.5]; [clrd4 setAlpha:0.0]; [UIView commitAnimations]; [self performSelector:@selector(cb4) withObject:nil afterDelay:1.5];

    Read the article

  • Thread class closing from other Class (Activity) with protected void onStop() Android

    - by user1761337
    I have a Problem with Closing the Thread. I will Closing the Thread with onStop,onPause and onDestroy. This is my Source in the Activity Class: @Override protected void onStop(){ super.onStop(); finish(); } @Override protected void onPause() { super.onPause(); finish(); } @Override public void onDestroy() { this.mWakeLock.release(); super.onDestroy(); } And the Thread Class: public class GameThread extends Thread { private SurfaceHolder mSurfaceHolder; private Handler mHandler; private Context mContext; private Paint mLinePaint; private Paint blackPaint; //for consistent rendering private long sleepTime; //amount of time to sleep for (in milliseconds) private long delay=1000/30; //state of game (Running or Paused). int state = 1; public final static int RUNNING = 1; public final static int PAUSED = 2; public final static int STOPED = 3; GameSurface gEngine; public GameThread(SurfaceHolder surfaceHolder, Context context, Handler handler,GameSurface gEngineS){ //data about the screen mSurfaceHolder = surfaceHolder; mHandler = handler; mContext = context; gEngine=gEngineS; } //This is the most important part of the code. It is invoked when the call to start() is //made from the SurfaceView class. It loops continuously until the game is finished or //the application is suspended. private long beforeTime; @Override public void run() { //UPDATE while (state==RUNNING) { Log.d("State","Thread is runnig"); //time before update beforeTime = System.nanoTime(); //This is where we update the game engine gEngine.Update(); //DRAW Canvas c = null; try { //lock canvas so nothing else can use it c = mSurfaceHolder.lockCanvas(null); synchronized (mSurfaceHolder) { //clear the screen with the black painter. //reset the canvas c.drawColor(Color.BLACK); //This is where we draw the game engine. gEngine.doDraw(c); } } finally { // do this in a finally so that if an exception is thrown // during the above, we don't leave the Surface in an // inconsistent state if (c != null) { mSurfaceHolder.unlockCanvasAndPost(c); } } this.sleepTime = delay-((System.nanoTime()-beforeTime)/1000000L); try { //actual sleep code if(sleepTime>0){ this.sleep(sleepTime); } } catch (InterruptedException ex) { Logger.getLogger(GameThread.class.getName()).log(Level.SEVERE, null, ex); } while (state==PAUSED){ Log.d("State","Thread is pausing"); try { this.sleep(1000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }} How i can close the Thread from Activity Class??

    Read the article

  • Why is my custom view not appearing?

    - by user351469
    When I comment out setContentView(boardView); in my Game.java my custom view in BoardView works fine and displays everything nicely... but onSizeChanged never gets called in BoardView.java... so I can't read the device width and height at runtime. If I leave setContentView uncommented onSizeChanged works... but the screen is blank! I want to be able to read the screen width and height at runtime and set the sizes of my ImageViews at creation so they are the optimal size. public class Game extends Activity implements OnClickListener{ private BoardView boardView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); boardView = new BoardView(this); setContentView(boardView); // when this line disabled, it looks ok boardView.requestFocus(); } public class BoardView extends View { private final Game game; private float width; // width of one unit private float height; // height of one unit public BoardView(Context context){ super(context); this.game = (Game)context; setFocusable(true); setFocusableInTouchMode(true); LinearLayout maincontainer = new LinearLayout(game); maincontainer.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,LayoutParams.FILL_PARENT)); maincontainer.setGravity(Gravity.CENTER); maincontainer.setOrientation(LinearLayout.VERTICAL); maincontainer.setBackgroundColor(Color.BLACK); LinearLayout innercontainer = new LinearLayout(game); innercontainer.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); innercontainer.setGravity(Gravity.CENTER); innercontainer.setOrientation(LinearLayout.HORIZONTAL); // declare a new table TableLayout layout = new TableLayout(game); layout.setLayoutParams(new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT)); // build a grid of ImageViews in a TableLayout for (int f=1; f<=7; f++) { TableRow tr = new TableRow(game); for (int c=1; c<=7; c++) { ImageView b = new ImageView(game); b.setImageResource(R.drawable.neworb); b.setOnClickListener(game); tr.addView(b, 30,30); // I'd like to not use fixed values here } // for layout.addView(tr); } // for innercontainer.addView(layout); maincontainer.addView(innercontainer); game.setContentView(maincontainer); } @Override protected void onSizeChanged(int w, int h, int oldw, int oldh){ width = w/9f; height = width; super.onSizeChanged(w, h, oldw, oldh); } }

    Read the article

  • Vagrant sahara plugin - multiple snapshots

    - by BazZy
    How I can make more than one snapshot when in sahara sandbox mode? Or, can I see list of all commits I've ever made and rollback to any? Why do I need all this? I just want to setup initial VM. After that I want to compile number of packages from sources, and this takes pretty long time. So right now I thinking of this order: Setup initial ubuntu 12.04 vagrant box Snapshot this state Compile sources, install system wide rbenv (it make compilation also) Snapshot second state Start all my infrastructure experiments Rollback to any of my previous states or commit third state

    Read the article

  • Spring noHandlerFound

    - by Justin
    I am trying to set up my Spring MVC testing environment. But I always get this noHandlerFound error: Aug 21, 2014 4:43:25 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/restful/firstPage] in DispatcherServlet with name 'spring' Aug 21, 2014 4:47:21 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/restful/firstPage2] in DispatcherServlet with name 'spring' Aug 21, 2014 5:10:27 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/restful/index.html] in DispatcherServlet with name 'spring' I already searched for solution, but none can fix my problem. My spring mvc version: 3.1.3.RELEASE This is my web.xml: <servlet> <servlet-name>spring</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>spring</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping> <context-param> <param-name>contextConfigLocation</param-name> <param-value> /WEB-INF/applicationContext.xml </param-value> </context-param> this is my spring-servlet.xml: <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" p:prefix="/WEB-INF/jsp/" p:suffix=".jsp" /> this is my applicationContext.xml: <context:annotation-config /> <context:component-scan base-package="test.spring" /> <mvc:annotation-driven /> <mvc:resources mapping="/index.html" location="/index.html" /> <mvc:view-controller path="/firstPage" /> This is my Controller: package test.spring; .... @Controller @RequestMapping("/") public class FirstController { @RequestMapping(value = "firstPage2", method = RequestMethod.GET) public String showFirstPage(Map<String,Object> model){ return "firstPage"; } } My server is tomcat 7, there is no error and warning when it is deployed. I also tried this with no luck: <mvc:default-servlet-handler/> Before I start Spring MVC, I can access index.html

    Read the article

  • How to use method hiding (new) with generic constrained class

    - by ongle
    I have a container class that has a generic parameter which is constrained to some base class. The type supplied to the generic is a sub of the base class constraint. The sub class uses method hiding (new) to change the behavior of a method from the base class (no, I can't make it virtual as it is not my code). My problem is that the 'new' methods do not get called, the compiler seems to consider the supplied type to be the base class, not the sub, as if I had upcast it to the base. Clearly I am misunderstanding something fundamental here. I thought that the generic where T: xxx was a constraint, not an upcast type. This sample code basically demonstrates what I'm talking about. using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace GenericPartialTest { class ContextBase { public string GetValue() { return "I am Context Base: " + this.GetType().Name; } public string GetOtherValue() { return "I am Context Base: " + this.GetType().Name; } } partial class ContextSub : ContextBase { public new string GetValue() { return "I am Context Sub: " + this.GetType().Name; } } partial class ContextSub { public new string GetOtherValue() { return "I am Context Sub: " + this.GetType().Name; } } class Container<T> where T: ContextBase, new() { private T _context = new T(); public string GetValue() { return this._context.GetValue(); } public string GetOtherValue() { return this._context.GetOtherValue(); } } class Program { static void Main(string[] args) { Console.WriteLine("Simple"); ContextBase myBase = new ContextBase(); ContextSub mySub = new ContextSub(); Console.WriteLine(myBase.GetValue()); Console.WriteLine(myBase.GetOtherValue()); Console.WriteLine(mySub.GetValue()); Console.WriteLine(mySub.GetOtherValue()); Console.WriteLine("Generic Container"); Container<ContextBase> myContainerBase = new Container<ContextBase>(); Container<ContextSub> myContainerSub = new Container<ContextSub>(); Console.WriteLine(myContainerBase.GetValue()); Console.WriteLine(myContainerBase.GetOtherValue()); Console.WriteLine(myContainerSub.GetValue()); Console.WriteLine(myContainerSub.GetOtherValue()); Console.ReadKey(); } } }

    Read the article

  • Whats the relationship between Spring and javax.enterprise.inject?

    - by HDave
    I was reading a Wikipedia article about Java EE application servers here: http://en.wikipedia.org/wiki/Java_Platform,_Enterprise_Edition#Java_EE_5_certified It says that 2 APIs that Java App Services implement are: javax.enterprise.inject javax.enterprise.context These both relate to application context and dependency injection JSR-299. I had never heard of these APIs before. Does Spring implement these APIs? Would it matter to anyone if they did?

    Read the article

  • Setting class properties quickly

    - by uzay95
    class UserClass{ #region Class properties which are binding from DB . . . #endregion #region Constructor Methods public UserClass(int _iUser_id) { // of course this is wrong but how can i quickly set properties // which are coming from DB by extension method over context class? this = DAO.context.GetById<UserClass>(_iUser_id); } #endregion }

    Read the article

  • Make service indepented from activity (Android).

    - by shuwo
    I have an activity with two buttons, start and stop. If the user press the start button a service is created using Context.startService. And the stop button calls Context.stopService. I want the stop button to be the only way to destroy the service. Now, if i end the activity using a task manager, the service is killed as well. Is there any way to avoid this?

    Read the article

  • Adding Related Entities without using navigation properties

    - by Barisa Puter
    I have the following classes, set for testing: public class Company { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Name { get; set; } } public class Employee { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public int Id { get; set; } public string Name { get; set; } public int CompanyId { get; set; } public virtual Company Company { get; set; } } public class EFTestDbContext : DbContext { public DbSet<Employee> Employees { get; set; } public DbSet<Company> Companies { get; set; } } For the sake of testing, I wanted to insert one company and one employee for that company with single SaveChanges call, like this: Company company = new Company { Name = "Sample company" }; context.Companies.Add(company); // ** UNCOMMENTED FOR TEST 2 //Company company2 = new Company //{ // Name = "Some other company" //}; //context.Companies.Add(company2); Employee employee = new Employee { Name = "Hans", CompanyId = company.Id }; context.Employees.Add(employee); context.SaveChanges(); Even though I am not using navigational properties, but instead I've made relation over Id, this somehow mysteriously worked - employee was saved with proper foreign key to company which got updated from 0 to real value, which made me go ?!?! Some hidden C# feature? Then I've decided to add more code, which is commented in the snippet above, making it to be inserting of 2 x Company entity and 1 x Employee entity, and then I got exception: Unable to determine the principal end of the 'CodeLab.EFTest.Employee_Company' relationship. Multiple added entities may have the same primary key. Does this mean that in cases where foreign key is 0, and there is a single matching entity being inserted in same SaveChanges transaction, Entity Framework will assume that foreign key should be for that matching entity? In second test, when there are two entities matching the relation type, Entity Framework throws an exception as it is not able to figure out to which of the Companies Employee should be related to.

    Read the article

  • ordering by a property on a joined table linq to sql

    - by Gazeth
    I have the following linq query from o in context.Opportunities join i in context.Interactions on o.OpportunityID equals i.OpportunityID into ints from i in ints.DefaultIfEmpty() orderby i.StatusID descending, o.StatusID descending select o Now i want to then do a distinct on the opportunities table but doing so removes my orderby. I know that you can do Distinct().OrderBy but how do i get a reference to the interactions table that was joined when I'm only selecting the opportunity entity?

    Read the article

  • How to check results of LINQ to SQL query?

    - by rem
    In a WPF app I'd like to check if a return of a LINQ to SQL query contains some records, but my approach doesn't work: TdbDataContext context = new TdbDataContext(); var sh = from p in context.Items where p.Selected == true select p; if (sh == null) { MessageBox.Show("There are no Selected Items"); } Where am I wrong?

    Read the article

  • Can SQLite file copied successfully on the data folder of an unrooted android device ?

    - by student
    I know that in order to access the data folder on the device, it needs to be rooted. However, if I just want to copy the database from my assets folder to the data folder on my device, will the copying process works on an unrooted phone? The following is my Database Helper class. From logcat, I can verify that the methods call to copyDataBase(), createDataBase() and openDataBase() are returned successfully. However, I got this error message android.database.sqlite.SQLiteException: no such table: TABLE_NAME: when my application is executing rawQuery. I'm suspecting the database file is not copied successfully (cannot be too sure as I do not have access to data folder), yet the method call to copyDatabase() are not throwing any exception. What could it be? Thanks. ps: My device is still unrooted, I hope it is not the main cause of the error. public DatabaseHelper(Context context) { super(context, DB_NAME, null, 1); this.myContext = context; } public void createDataBase() throws IOException{ boolean dbExist = checkDataBase(); String s = new Boolean(dbExist).toString(); Log.d("dbExist", s ); if(dbExist){ //do nothing - database already exist Log.d("createdatabase","DB exists so do nothing"); }else{ this.getReadableDatabase(); try { copyDataBase(); Log.d("copydatabase","Successful return frm method call!"); } catch (IOException e) { throw new Error("Error copying database"); } } } private boolean checkDataBase(){ File dbFile = new File(DB_PATH + DB_NAME); return dbFile.exists(); } private void copyDataBase() throws IOException{ //Open your local db as the input stream InputStream myInput = null; myInput = myContext.getAssets().open(DB_NAME); Log.d("copydatabase","InputStream successful!"); // Path to the just created empty db String outFileName = DB_PATH + DB_NAME; //Open the empty db as the output stream OutputStream myOutput = new FileOutputStream(outFileName); //transfer bytes from the inputfile to the outputfile byte[] buffer = new byte[1024]; int length; while ((length = myInput.read(buffer))>0){ myOutput.write(buffer, 0, length); } //Close the streams myOutput.flush(); myOutput.close(); myInput.close(); } public void openDataBase() throws SQLException{ //Open the database String myPath = DB_PATH + DB_NAME; myDataBase = SQLiteDatabase.openDatabase(myPath, null, SQLiteDatabase.OPEN_READONLY); } /* @Override public synchronized void close() { if(myDataBase != null) myDataBase.close(); super.close(); }*/ public void close() { // NOTE: openHelper must now be a member of CallDataHelper; // you currently have it as a local in your constructor if (myDataBase != null) { myDataBase.close(); } } @Override public void onCreate(SQLiteDatabase db) { } @Override public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) { } }

    Read the article

  • request: compile c++ source for 64bit windows

    - by Kellyh
    Hi, First of all, i hope i post in the right section. I came across this best media convertor open source software. It works fine and the most convenience thing about this software is the context menu however the context menu isn't working on Windows 7 64bit. Since i have no knowledge with c++, Can you one here generously help me compile it into 64bit version. Below are the software I am talking about Homepage: htp://www.oxelon.com/media_converter.html Source: http://sourceforge.net/projects/oxelonmediaconv/files/oxelonmediaconv/oxelon_source_code/omc_src.zip/download

    Read the article

< Previous Page | 93 94 95 96 97 98 99 100 101 102 103 104  | Next Page >