Reputation: 272
I have been trying to convert some c# code to VB.NET for a while now. The purpose of this is that i am trying to build some kind of Twitter client, i have nearly converted all fo the following code for a class within my project, which is currently:
Friend Shared Function GetRequestTokenQuery() As OAuthWebQuery
Dim oauth = New OAuthWorkflow() With { _
Key .ConsumerKey = AppSettings.consumerKey, _
Key .ConsumerSecret = AppSettings.consumerKeySecret, _
Key .SignatureMethod = OAuthSignatureMethod.HmacSha1, _
Key .ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, _
Key .RequestTokenUrl = AppSettings.RequestTokenUri, _
Key .Version = AppSettings.oAuthVersion, _
Key .CallbackUrl = AppSettings.CallbackUri _
}
Dim info = oauth.BuildRequestTokenInfo(WebMethod.[Get])
Dim objOAuthWebQuery = New OAuthWebQuery(info, False)
objOAuthWebQuery.HasElevatedPermissions = True
objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock"
Return objOAuthWebQuery
End Function
However i then get the error 'Name of field or property being initialized in an object initializer must start with '.'' with the first mention of 'key' underlined in blue. Anyone got any ideas as to how i need to change my code?
Upvotes: 0
Views: 88
Reputation: 2024
The Correct syntax in VB.net would be like this
Friend Shared Function GetRequestTokenQuery() As OAuthWebQuery
Dim oauth = New OAuthWorkflow() With { _
.ConsumerKey = AppSettings.consumerKey, _
.ConsumerSecret = AppSettings.consumerKeySecret, _
.SignatureMethod = OAuthSignatureMethod.HmacSha1, _
.ParameterHandling = OAuthParameterHandling.HttpAuthorizationHeader, _
.RequestTokenUrl = AppSettings.RequestTokenUri, _
.Version = AppSettings.oAuthVersion, _
.CallbackUrl = AppSettings.CallbackUri _
}
Dim info = oauth.BuildRequestTokenInfo(WebMethod.[Get])
Dim objOAuthWebQuery = New OAuthWebQuery(info, False)
objOAuthWebQuery.HasElevatedPermissions = True
objOAuthWebQuery.SilverlightUserAgentHeader = "Hammock"
Return objOAuthWebQuery
End Function
Upvotes: 2