This is what sample code reminds me of when compared to production code.
http://www.youtube.com/watch?v=bufTna0WArc>The parameters are passed as XML string. This is the typical method and I am following the pattern which was developed before me:
>
>This is part of the code of the method I wrote today and unit testing right now
>
>
>internal static String GetGuestActivity(Dictionary<String, String> parameters)
> {
> Logging.Log(1, "Entering GetGuestActivity");
>
> List<String> requiredParameters = new List<String>() { "tnGuestNo", "ttStartDate", "ttEndDate" };
> //always required parameters (but not used) { "tcSalesPoint", "tcOperator" };
> //optional parameters { "tcFilter"};
>
> //TODO: get rid of not used tcFilter parameter in the code and SP
>
> HashSet<String> availableReturnTypes = new HashSet<String>(StringComparer.OrdinalIgnoreCase) { "STR", "ADO", "XML", "XM2" };
>
> String messageText = "";
> Int32 errorValue = 0;
> Int32 statusCode = 0;
>
> // If all necessary parameters are present and valid, proceed...
> if (Functions.CheckRequiredParameters(parameters, requiredParameters, availableReturnTypes, out statusCode, out messageText))
> {
> // Parse out the parameters
> String tcGuestNo = Functions.GetParameterValue(parameters, "tnGuestNo");
> String tcStartDate = Functions.GetParameterValue(parameters, "ttStartDate");
> String tcEndDate = Functions.GetParameterValue(parameters, "ttEndDate");
> String tcFilter = Functions.GetParameterValue(parameters, "tcFilter");
>
> Decimal guestNo;
>
> if (!Decimal.TryParse(tcGuestNo, out guestNo) || 0 == guestNo)
> {
> statusCode = 999;
> messageText = "tnGuestNo expression can not be zero";
> return Base.LogAndReturnResult(errorValue, statusCode, messageText);
> }
>
>UPDATE. I changed this method to use only 1 exit point as it has only 2 exit points, so it was relatively easy to convert.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer