Print Page | Close Window

BaseOperation Replacement

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2012
Forum Discription: For .NET 4.5
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=4622
Printed Date: 06-Sep-2025 at 4:31am


Topic: BaseOperation Replacement
Posted By: mitchell_bu
Subject: BaseOperation Replacement
Date 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>?



Replies:
Posted By: kimj
Date 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.


Posted By: mitchell_bu
Date Posted: 06-Dec-2013 at 1:49pm
I thought of that.  But IBaseOperation doesn't define the Completed event handler, which we use.


Posted By: kimj
Date 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.


Posted By: mitchell_bu
Date 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.



Print Page | Close Window