Calling methods in C# like in VB.NET - vb.net-to-c#

I'm trying to migrate VB.NET to C#:
Public Sub customfunc()
"my codes here"
End Sub
Public Sub main()
Call customfunc()
End Sub
So i'm trying to call customfunc() inside main() but there is no call function in c#.
How do I do this in c#?

Just do it without the Call:
customfunc();

Related

Pass in Camunda execution environment to Java Delegate Expression?

I am trying to use a Java Delegate Expression (Similar to TaskListener's Expression where you can pass a TaskDelegate to the expression context).
In a nutshell - am trying to accomplish what taskListener allows to pass in a TaskDelegate using the expression ${myDelegate.doSomething(task)} which works fine for TaskListener!
However Im trying to do the same using the Delegate's expression. I understand we can do this which works ${myDelegate.doSomething()} (without any Runtime Engine's params) but I need the Runtime from which we can get the ProcessRuntimeExecution etc! I don't want to use the Java Delegate's execute method since I am reusing this Delegate for a User Task's TaskListener methods.
${myDelegate.doSomething(WHAT DO I PASS HERE TO GET Camunda Runtime?)}
public class MyDelegate implements JavaDelegate {
public void doSomething( CAMUNDA RUNTIME? ) {
// Get the ProcessEngine etc
}
}
You are looking for the DelegateExcecution.

UnsatisfiedLinkError when calling native method packaged in jar file

I am getting java.lang.UnsatisfiedLinkError: com.fundamenture.solvocommons.utility.parsers.tklib.test()V when calling native C method test() when calling the class packaged in a jar file. Same code runs fine when calling the java file directly
Note that loading the library with code
System.loadLibrary("tklib");
runs fine, it is only at the point of calling the method test() that the exception occurs. This means that the java code can load the library properly, only calling the method is failing
The code runs fine when called via command line in a main method as follows
java -cp . -Djava.library.path=. tklib
Below is my java code with the main method running fine from command line
class tklib {
static {
System.loadLibrary("tklib"); // loading libtklib.so
}
private native void test();
private native boolean initialize(String configuration);
private native void shutdown();
private native String unpack(String keyname, String secureddata);
public static void main(String[] args) {
new tklib().test();
new tklib().shutdown();
}
}
When I package the project as a jar file and calling the method I am getting the UnsatisfiedLinkError at the point when new tklib().test() is called.

Implement VB.NET Interface Class in C++.NET (2010)

I wonder how I can import an Interface Class in C++.NET which was written in VB.NET.
The Dll contains only a Interface class. If I write "Implement iInterface" in VB.NET, it'll load all Functions and Methods from the Interface.dll.
But how can I do this in C++.NET?
This is what the Interface.dll looks like:
Public Interface IPlugin
Function CreateInstance( _
ByRef pntMemory As MemoryArbiter, _
ByRef pntMessageQueue As clsMessageQueue, _
ByRef pntGPIO As clsGPIO, _
ByRef pntProgramSettings As Types, _
ByRef pntDisplayDriver As DisplayDriver _
) As Boolean
Function DeleteInstance() As Boolean
Sub Main_Loop()
Sub ForceUnload()
Sub Interrupt()
End Interface
This structure has to be imported to the c++ code.
In VB.NET it looks like this:
Imports System.ComponentModel.Composition
Imports System.Windows.Forms.Application
Imports Plugin_Interface
Imports SharedLibrary
Imports SharedLibrary.DisplayDriver
<Export(GetType(IPlugin))>
Public Class cPlugin
Implements IPlugin
'.... Class functions come here
I, however, just need a tanslation of the file above so I can import the C++ DLL via MEF in my VB.NET 2010 Application.
Hope someone knows how to handle this ... :)

Can we a static ( A Utility class) method for a webservice

Inside a Webservice method , i have created a helper class whose responsibility is to take the XML String passed as a Method arguement to it and then construct
Array List obect from that .
My question is can i have this method as static ??
This utility methos will be called from a Webservice ?? Is this okay ??
public class UtilStaxParser {
public static List parseData(String XMLdocument) {
}
}
Of course you can... you would have found that if you had simply tried it :)
The webservice method can call a static method, but the webservice method cannot be static.

How do you assert a generic method was called with Rhino Mocks?

I have the following test to verify that my repository is calling it's respective session (I've rewritten it to highlight the actual problem):
[Test]
public void Why_Does_This_Fail()
{
var objectUnderTest = new SomeGenericsProblem();
var fakeSession = MockRepository.GenerateMock<ISession>();
fakeSession.Expect(s => s.Query<SomeClass>());
objectUnderTest.NotWorking<SomeClass>();
fakeSession.AssertWasCalled(t => t.Query<SomeClass>());
}
but when I run the test I get this:
System.InvalidOperationException :
Invalid call, the last call has been
used or no call has been made (make
sure that you are calling a virtual
(C#) / Overridable (VB) method).(C#) / Overridable (VB) method).
Any ideas what I'm doing wrong here? The session that I'm mocking is an interface, so it has to be virtual/overridable.
I have a feeling it has something to do with the fact that my Query method is a generic, but I don't know any other way to express what I'm trying to test.
Also, If I remove the part that sets up the expectation (i.e. this line of code:)
fakeSession.Expect(s => s.Query<SomeClass>());
I get a different exception which is equally confusing to me:
System.InvalidOperationException : No
expectations were setup to be
verified, ensure that the method call
in the action is a virtual (C#) /
overridable (VB.Net) method calloverridable (VB.Net) method call
So I figured out what was wrong.
ISession comes from NHibernate, which I probably should have mentioned.
The reason why this is cruicialy important is because
session.Query<T>
(which is what I'm trying to mock), is an EXTENSION METHOD.
Rhino Mocks apparently does not have the capability of mocking extension methods, hence why it's giving me the weird error.
So hopefully I'll have saves someone else the time and agony I've gone through in trying to figure out why my test won't pass.
The only solution that I've read about for this is to actually change the design of the extension method (which I can't do because it's part of NHibernate), or to use a different mocking framework like TypeMock.
[Test]
public void Query_WhenCalled_CallsSessionQuery()
{
// arrange
var session = MockRepository.GenerateStub<ISession>();
var r = new Repository(session);
// act
r.Query<SomeClass>();
// assert
session.AssertWasCalled(s => s.Query<SomeClass>());
}