Created
March 21, 2011 09:33
-
-
Save forki/879219 to your computer and use it in GitHub Desktop.
Mechanical transformation from out parameters to tuples.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SdkClass | |
{ | |
public int GetInfo(string param1, out string outParam) | |
{ | |
// ... | |
var errorCode = 1; | |
outParam = "MyInfo"; | |
return errorCode; | |
} | |
} | |
// This transformation is very mechanical, but allows to access both function results in a pipelined manner. | |
// I think I would not write tests for this class, but I would consider to codegen this code if you use it a lot. | |
public class TupledSdkClass | |
{ | |
readonly SdkClass _sdk; | |
public TupledSdkClass(SdkClass sdk) | |
{ | |
_sdk = sdk; | |
} | |
public Tuple<int, string> GetInfo(string param1) | |
{ | |
string outParam; | |
var result = _sdk.GetInfo(param1, out outParam); | |
return Tuple.Create(result, outParam); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment