Dobrý den, mám problem s překladem kódu z C# do VB.NET. V C# mám následující kód:
namespace SmartformValidatorTest
{
class Validator
{
private long announceIdCounter = 0;
private AnnounceResponse lastResponse;
/// <summary>
/// Zvaliduje zadanou adresu
/// </summary>
/// <param name="fieldValues">mapa policek adresy</param>
/// <returns>vysledek validace nebo null pri chybe spojeni</returns>
public AnnounceResponse validate(Dictionary<OracleFieldType, string> fieldValues)
{
AnnounceRequest announceRequest = new AnnounceRequest(++announceIdCounter, fieldValues, password);
lock (this)
{
SmartformWsHelper.sendRequest<AnnounceResponse>("announce", announceRequest, announceCallback);
Monitor.Wait(this, 5000);
if (lastResponse == null) return null;
if (lastResponse.Id != announceIdCounter) return null;
return lastResponse;
}
}
private void announceCallback(AnnounceResponse response)
{
lock (this)
{
lastResponse = response;
Monitor.Pulse(this);
}
}
private string password;
public string Password
{
set { password = value; }
}
}
}
překlad automatickým překladačem vyhodil toto:
Namespace SmartformValidator
Class Validator
Private announceIdCounter As Long = 0
Private lastResponse As AnnounceResponse
''' <summary>
''' Zvaliduje zadanou adresu
''' </summary>
''' <param name="fieldValues">mapa policek adresy</param>
''' <returns>vysledek validace nebo null pri chybe spojeni</returns>
Public Function validate(fieldValues As Dictionary(Of OracleFieldType, String)) As AnnounceResponse
Dim announceRequest As New AnnounceRequest(System.Threading.Interlocked.Increment(announceIdCounter), fieldValues, m_password)
SyncLock Me
'SmartformWsHelper.sendRequest(Of AnnounceResponse)("announce", announceRequest, announceCallback)
Monitor.Wait(Me, 5000)
If lastResponse Is Nothing Then
Return Nothing
End If
If lastResponse.Id <> announceIdCounter Then
Return Nothing
End If
Return lastResponse
End SyncLock
End Function
Private Sub announceCallback(response As AnnounceResponse)
SyncLock Me
lastResponse = response
Monitor.Pulse(Me)
End SyncLock
End Sub
Private m_password As String
Public WriteOnly Property Password() As String
Set(value As String)
m_password = value
End Set
End Property
End Class
End Namespace
Bohužel přeložený kód hlásí ERR na řádku
SmartformWsHelper.sendRequest(Of AnnounceResponse)("announce", announceRequest, announceCallback)
Error 1 Argument not specified for parameter 'response' of 'Private Sub announceCallback(response As SmartformWsClient.AnnounceResponse) V původním kódu jsem ale parametr nenašel, i když se přiznám, že C# je pro mě velká neznámá. Můžete mi, prosím poradit, kde vznikla chyba v překladu? Díky Martin
|