New Posts New Posts RSS Feed: BaseOperation Replacement
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

BaseOperation Replacement

 Post Reply Post Reply
Author
mitchell_bu View Drop Down
Newbie
Newbie


Joined: 23-Feb-2012
Posts: 10
Post Options Post Options   Quote mitchell_bu Quote  Post ReplyReply Direct Link To This Post Topic: BaseOperation Replacement
    Posted: 06-Dec-2013 at 10:33am
We're currently in the process of migrating from DevForce 2010 to 2012. We're using the Compatibility Pack because we use a separate library to handle asynchronous calls. As part of this, we use the BaseOperation class extensively. However, this class has been removed and only the abstract BaseOperation<TArgs, TOp> class remains. We have an interface that defines a BaseOperation Operation member, which is then implemented by various classes as a BaseOperation, EntityQueryOperation or InvokeServerMethodOperation. Is there a way to convert BaseOperation to BaseOperation<TArgs, TOp>?
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 06-Dec-2013 at 1:44pm
Can you use IBaseOperation instead of BaseOperation in your interface?  It might be a bit uglier than before, but the various sub-types of BaseOperation<TArgs, TOp> all implement this.
Back to Top
mitchell_bu View Drop Down
Newbie
Newbie


Joined: 23-Feb-2012
Posts: 10
Post Options Post Options   Quote mitchell_bu Quote  Post ReplyReply Direct Link To This Post Posted: 06-Dec-2013 at 1:49pm
I thought of that.  But IBaseOperation doesn't define the Completed event handler, which we use.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1391
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 06-Dec-2013 at 2:33pm
Hmm.  This is quite ugly, but might work:
 
public interface ISomeInterface<TArgs, TOp>
where TArgs: AsyncEventArgs
where U: BaseOperation<TArgs, TOp> {
   BaseOperation<TArgs, TOp> Operation { get; }
}
 
public class LoginWrapper : ISomeInterface<LoginEventArgs, LoginOperation> {
  public BaseOperation<LoginEventArgs, LoginOperation> Operation { get { .... }}
}
 
public class QueryWrapper : ISomeInterface<EntityQueriedEventArgs, EntityQueryOperation> {
  public BaseOperation<EntityQueriedEventArgs, EntityQueryOperation { get { .... }}
}
 
If not, you may need some sort of wrapper class over the DF *Operation classes to get the behavior you need.
 
I'll put a plug in for the new async/await API too.  I know it can be work migrating to it, but it really does simplify one's code quite a bit.
Back to Top
mitchell_bu View Drop Down
Newbie
Newbie


Joined: 23-Feb-2012
Posts: 10
Post Options Post Options   Quote mitchell_bu Quote  Post ReplyReply Direct Link To This Post Posted: 09-Dec-2013 at 8:36am
We were trying to avoid having to rework our code to use the new async/await API, but it looks like that is what we should do. Thanks for the help.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down