calling the Execute method of IExternalLateBoundService - mdriven

The question about the calling of the custom .net method implemented in the TurnKey_ExternalLateBound.dll.
I remember that it worked for me, but it was long time ago.
I tried this article and I put simple code:
public IElement Execute(IClassifier classifier, IObject theobject, IMethod method, IModifiableVariableList variableList)
{
throw new NotImplementedException();
}
But I got nothing in the Turnkey. The tagged value of the class's method is ok. Viewmodel's action column calls this method.
Could you please advise what should I do else?
Thanks a lot!

Related

How can I call 'BeginPlay' on 'UDataAsset' ? (unreal)

I made UDataAsset.
And I want to call BeginPlay function on UDataAsset.
I just put BeginPlay function on UDataAsset script just like Actor does.
But it didn't work.
How can I do this?
UCLASS()
class GAME_API UCData : public UDataAsset
{
GENERATED_BODY()
public:
void BeginPlay(class ACharacter* InCharacter);
}
This didn't work for me...
Am I missing something?
Please help me..
For reference, UDataAsset inherits from UObject; UObject doesn't include a function for BeginPlay, so you won't get the behaviour you would expect if the data asset inherited from AActor.
If there is an owner for the data asset, they can provide that call into your version of BeginPlay.
I found the solution. UDataAsset can't have beginPlay so I called BeginPlay on DataAsset from the other component.

How to invoke a delegate beginInvoke within a DBContext

I have a code like this
using (SomeDBContext db = new SomeDBContext())
{
foreach (var r in someColection)
{
MyDelegate.BeginInvoke(db, parm1, parm2, etc, null, null);
}
}
The problem is, the function that is fed to MyDelegate uses the db dbcontext passed to it, and since the delegate is run asynchronously the db context was closed while the function is trying to access the database. Could someone please help resolving this problem? Thank you sooo much!
A Context is not thread safe,you will have problems if you try to use it
(Unfortunately sometimes you will not notice anything wrong... )
Anyway ,the best approach is to create a new Context inside your method which will solve your original problem

Is there any way to know that from where PlaceRequest is called in GWT?

In my presenter I have prepareFromRequest() method where I want to know that from which place request has come to this method.
As revealPlace() gets called from many places with my current name token, is there any way to find out from where exactly current method getting called?
As my issue is not reproducible when launched through eclipse and only reproducible through jetty, I can't put logger statements to all places.
Please suggest a way to find the caller of prepareFromRequest() method?
If you need to know the current place in the app, you can use two options:
String currentPlace = History.getToken();
Place place = clientFactory.getPlaceController().getWhere();
However, in your case you may simply add an argument to your method:
public void doSomething(String fromWhere) {
if ("home".equals(fromWhere)) {
...
}
}
Then simply pass the parameter to this method when you call it.

Assigning to a stub class method in Moles while using partial stubs

I've seen this question regarding partial stubs, but it does not quite tell me what I need to know.
I understand that, if I am using a Moles stub for a class (let's say, for DataService, I'm using SDataService), I can set the CallBase property to true so that, if there is no delegate for a particular method, the base implementation's method will be called. Great, but how do I assign a delegate to a particular method in this case?
If there is no way to do that, say I have an interface IDataService that I stub using SIDataService. I can easily assign a delegate to a method here. But, how do I tell it to call the corresponding method on DataService (an implementation of IDataService) if there is no delegate for a given method?
Thank you!
Edit:
I see now that the method needs to be virtual to be overridden in the first scenario above. I don't think that makes a whole lot of sense, but it is what it is.
So, focusing on the second scenario, would I have to create a Behavior? (And why isn't there one already for stubs like there is for moles?) Or is there a simpler way?
Delegates (detours) are set to stubs types the same way as mole types. For example, SIDataService.GetMemberProfile() is configured to return a mock object like this:
var memberMock = new Member() { Firstname="Joe", LastName="Schmoe" };
var stub = new SIDataService();
stub.GetMemberProfileMember = i => memberMock;

DelegateCommand<object> test with EventArg parameter mstest

I currently have an event trigger firing a custom trigger action.
The action passes back a EventArgs type of object to the view's view-model.
This is all well and good when I run the code it works perfectly. However, when I come to test this portion of code it all goes a bit rubbish.
As stated We are using an MVVM type pattern so I'm testing the 'Doing' end of the event trigger in my view-model and what I want to do is create a 'mocked' EventArgs object to pass into the execute method of my command under test. However it requires a RoutedEvent as it's ID property as stated above and I don't have access to it's constructor!
Cannot Access Internal Constructor for 'RoutedEvent' here.
Has anyone got any ideas? The code converage in test is more important than the current implimentation so if this is thought to be 'untestable', then I can make changes.
I have answered my own Question I think.
Casting the object passed back from the view at an earlier point means that the object I am passing to the methods under test is more easily created.
This is what I have now for the method under test.
public void DoItemsChanged(IList param)
Before I had
public void DoItemsChanged(object param)
Where the param is a SelectedItemCollection (previously a RoutedEventArgs, but now I use the IvokeCommandAction on the event trigger in the view, passign the SelectedItems). The param is now more easily passed into the method for the test and the code it much more descriptive as well. So it's all good for everyone.