New Posts New Posts RSS Feed: DevForce and Caliburn micro
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

DevForce and Caliburn micro

 Post Reply Post Reply
Author
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Topic: DevForce and Caliburn micro
    Posted: 23-Jan-2012 at 1:15pm
Hard to tell with the information I have. One reason that could happen is if the query got cancelled for some reason. Are you saying the e => error = e isn't called, either? result => {} would only be called if the query was actually succesfull.
Back to Top
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Posted: 23-Jan-2012 at 11:39am
Hello Marcel,
I've got a small iussue with the code you provided me...
In a ViewModel that calls the LoadData as it's loaded the IsBusy remains in true status and no call to result=> {} is made...why this happen?
Thanks

I can provide code tomorrow here it's 21PM and I'm out of office..
Thanks
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 30-Dec-2011 at 9:37pm
Never mind. I read your question again and it looks like you are already using DAF. Based on the SimplePopup I put together a sample that I think demostrates what you are asking:
        public IEnumerable<IResult> LoadData()
        {
            Exception error = null;
 
            // IsBusy = true;
 
            yield return CoroutineFns.AsResult(
                () => _repository.LoadData(result =>
                                               {
                                                   /* do something useful with the result */
                                               },
                                           e => error = e));
 
            // IsBusy = false;
 
            if (error != null)
                yield return new ShowMessageResult("Error", error.Message);
        }
You can download the entire sample from my SkyDrive. Just copy it into the DAF Samples folder if you want to build it.
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 30-Dec-2011 at 6:02pm
Paolo,
I'm not entirely sure about your question, but I think I know what you are asking. Are you familiar with the DevForce Application Framework? It's an open source framework that we make available to our customers. It integrates Caliburn Mirco with DevForce and provides the glue in between. I'm the primary author of the framework. I think you'll find your answers there. In particular check out the write-up on the recommended approach for repositories, I believe it answers your question about what to return.
If you download the framework, you'll also find a sample called SimplePopup in the Samples folder, which demonstrates how to do dialogs. I'm not familiar with Kevin Mees' implementation, but it migth be very similar.
Marcel
Back to Top
pponzano View Drop Down
Senior Member
Senior Member
Avatar

Joined: 28-Apr-2011
Location: Italy
Posts: 165
Post Options Post Options   Quote pponzano Quote  Post ReplyReply Direct Link To This Post Posted: 30-Dec-2011 at 8:33am
Hello,
refactoring my code I've seen that in some point I use MessageBoxes to show exceptions...

Here's an example

public void LoadData()

      {

          IsBusy = true;

          _repository.LoadData(idUser, Date,

                                     results =>

                                     {

                                         DataItems = new BindableCollection<myObj>(results.Cast<MarginCCSnapShotResult>());

 

                                         CanPrintExport = true;

                                         IsBusy = false;

                                     },

                                    e =>

                                    {

                                        CanPrintExport = false;

                                        IsBusy = false;

 

                                        MessageBox.Show(e.Message);

                                    });

      }

 I've decided to use the Kevin Mees implementation of Dialogs handling... but I don't knwo how to return the type since the Coorutine Error returns a IEnumerable<IResult>.

I tried yield return for error.AsResult() but it says “The yield statement cannot be used inside an anonymous method or lambda expression”


the other problem would be what type should I return instead of the void?

Thanks


Paolo



Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down