示例#1
0
        public string GenerateMethod(FunctionABI functionABI)
        {
            var functionCQSMessageModel = new FunctionCQSMessageModel(functionABI, _model.CQSNamespace);
            var functionOutputDTOModel  = new FunctionOutputDTOModel(functionABI, _model.FunctionOutputNamespace);
            var functionABIModel        = new FunctionABIModel(functionABI, _typeConvertor);

            var messageType         = functionCQSMessageModel.GetTypeName();
            var messageVariableName = functionCQSMessageModel.GetVariableName();
            var functionNameUpper   = _commonGenerators.GenerateClassName(functionABI.Name);

            if (functionABIModel.IsMultipleOutput() && !functionABIModel.IsTransaction())
            {
                var functionOutputDTOType = functionOutputDTOModel.GetTypeName();
                return
                    ($@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}QueryAsync(ByVal {messageVariableName} As {messageType}, ByVal Optional blockParameter As BlockParameter = Nothing) As Task(Of {functionOutputDTOType})
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.QueryDeserializingToObjectAsync(Of {messageType}, {functionOutputDTOType})({messageVariableName}, blockParameter)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function");
            }

            if (functionABIModel.IsSingleOutput() && !functionABIModel.IsTransaction())
            {
                if (functionABI.OutputParameters != null && functionABI.OutputParameters.Length == 1 &&
                    functionABI.Constant)
                {
                    var type = functionABIModel.GetSingleOutputReturnType();

                    return
                        ($@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}QueryAsync(ByVal {messageVariableName} As {messageType}, ByVal Optional blockParameter As BlockParameter = Nothing) As Task(Of {type})
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.QueryAsync(Of {messageType}, {type})({messageVariableName}, blockParameter)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function");
                }
            }

            if (functionABIModel.IsTransaction())
            {
                var transactionRequest =
                    $@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}RequestAsync(ByVal {messageVariableName} As {messageType}) As Task(Of String)
{SpaceUtils.TwoTabs}            
{SpaceUtils.ThreeTabs}Return ContractHandler.SendRequestAsync({messageVariableName})
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                var transactionRequestAndReceipt =
                    $@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}RequestAndWaitForReceiptAsync(ByVal {messageVariableName} As {messageType}, ByVal Optional cancellationToken As CancellationTokenSource = Nothing) As Task(Of TransactionReceipt)
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.SendRequestAndWaitForReceiptAsync({messageVariableName}, cancellationToken)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                return(transactionRequest + Environment.NewLine + transactionRequestAndReceipt);
            }

            return(null);
        }
        public string GenerateMethod(FunctionABI functionABI)
        {
            var functionCQSMessageModel = new FunctionCQSMessageModel(functionABI, _model.CQSNamespace);
            var functionOutputDTOModel  = new FunctionOutputDTOModel(functionABI, _model.FunctionOutputNamespace);
            var functionABIModel        = new FunctionABIModel(functionABI, _typeConvertor);

            var messageType         = functionCQSMessageModel.GetTypeName();
            var messageVariableName = functionCQSMessageModel.GetVariableName();
            var functionNameUpper   = _commonGenerators.GenerateClassName(functionABI.Name);

            if (functionABIModel.IsMultipleOutput() && !functionABIModel.IsTransaction())
            {
                var functionOutputDTOType = functionOutputDTOModel.GetTypeName();

                return
                    ($@"{SpaceUtils.TwoTabs}member this.{functionNameUpper}QueryAsync({messageVariableName}: {messageType}, ?blockParameter: BlockParameter): Task<{functionOutputDTOType}> =
{SpaceUtils.ThreeTabs}let blockParameterVal = defaultArg blockParameter null
{SpaceUtils.ThreeTabs}this.ContractHandler.QueryDeserializingToObjectAsync<{messageType}, {functionOutputDTOType}>({messageVariableName}, blockParameterVal)
{SpaceUtils.ThreeTabs}");
            }

            if (functionABIModel.IsSingleOutput() && !functionABIModel.IsTransaction())
            {
                if (functionABI.OutputParameters != null && functionABI.OutputParameters.Length == 1 &&
                    functionABI.Constant)
                {
                    var type = functionABIModel.GetSingleOutputReturnType();

                    return
                        ($@"{SpaceUtils.TwoTabs}member this.{functionNameUpper}QueryAsync({messageVariableName}: {messageType}, ?blockParameter: BlockParameter): Task<{type}> =
{SpaceUtils.ThreeTabs}let blockParameterVal = defaultArg blockParameter null
{SpaceUtils.ThreeTabs}this.ContractHandler.QueryAsync<{messageType}, {type}>({messageVariableName}, blockParameterVal)
{SpaceUtils.ThreeTabs}");
                }
            }

            if (functionABIModel.IsTransaction())
            {
                var transactionRequest =
                    $@"{SpaceUtils.TwoTabs}member this.{functionNameUpper}RequestAsync({messageVariableName}: {messageType}): Task<string> =
{SpaceUtils.ThreeTabs}this.ContractHandler.SendRequestAsync({messageVariableName});
{SpaceUtils.TwoTabs}";

                var transactionRequestAndReceipt =
                    $@"{SpaceUtils.TwoTabs}member this.{functionNameUpper}RequestAndWaitForReceiptAsync({messageVariableName}: {messageType}, ?cancellationTokenSource : CancellationTokenSource): Task<TransactionReceipt> =
{SpaceUtils.ThreeTabs}let cancellationTokenSourceVal = defaultArg cancellationTokenSource null
{SpaceUtils.ThreeTabs}this.ContractHandler.SendRequestAndWaitForReceiptAsync({messageVariableName}, cancellationTokenSourceVal);
{SpaceUtils.TwoTabs}";

                return(transactionRequest + Environment.NewLine + transactionRequestAndReceipt);
            }

            return(null);
        }
        public string GenerateMethod(FunctionABI functionABI)
        {
            var functionCQSMessageModel = new FunctionCQSMessageModel(functionABI, _model.CQSNamespace);
            var functionOutputDTOModel  = new FunctionOutputDTOModel(functionABI, _model.FunctionOutputNamespace);
            var functionABIModel        = new FunctionABIModel(functionABI, _typeConvertor);

            var messageType         = functionCQSMessageModel.GetTypeName();
            var messageVariableName = functionCQSMessageModel.GetVariableName();
            var functionNameUpper   = _commonGenerators.GenerateClassName(functionABI.Name);

            if (functionABIModel.IsMultipleOutput() && !functionABIModel.IsTransaction())
            {
                var functionOutputDTOType = functionOutputDTOModel.GetTypeName();

                var returnWithInputParam =
                    $@"{SpaceUtils.TwoTabs}public Task<{functionOutputDTOType}> {functionNameUpper}QueryAsync({messageType} {messageVariableName}, BlockParameter blockParameter = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs}return ContractHandler.QueryDeserializingToObjectAsync<{messageType}, {functionOutputDTOType}>({messageVariableName}, blockParameter);
{SpaceUtils.TwoTabs}}}";

                var returnWithoutInputParam =
                    $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}public Task<{functionOutputDTOType}> {functionNameUpper}QueryAsync(BlockParameter blockParameter = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs}return ContractHandler.QueryDeserializingToObjectAsync<{messageType}, {functionOutputDTOType}>(null, blockParameter);
{SpaceUtils.TwoTabs}}}";

                var returnWithSimpleParams =
                    $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}public Task<{functionOutputDTOType}> {functionNameUpper}QueryAsync({_parameterAbiFunctionDtocSharpTemplate.GenerateAllFunctionParameters(functionABIModel.FunctionABI.InputParameters)}, BlockParameter blockParameter = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs}var {messageVariableName} = new {messageType}();
{_parameterAbiFunctionDtocSharpTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.FourTabs)}
{SpaceUtils.ThreeTabs}
{SpaceUtils.ThreeTabs}return ContractHandler.QueryDeserializingToObjectAsync<{messageType}, {functionOutputDTOType}>({messageVariableName}, blockParameter);
{SpaceUtils.TwoTabs}}}";

                if (functionABIModel.HasNoInputParameters())
                {
                    return(returnWithInputParam + GenerateLineBreak() + returnWithoutInputParam + GenerateLineBreak());
                }
                else
                {
                    return(returnWithInputParam + GenerateLineBreak() + returnWithSimpleParams + GenerateLineBreak());
                }
            }

            if (functionABIModel.IsSingleOutput() && !functionABIModel.IsTransaction())
            {
                if (functionABI.OutputParameters != null && functionABI.OutputParameters.Length == 1 &&
                    functionABI.Constant)
                {
                    var type = functionABIModel.GetSingleOutputReturnType();

                    var returnWithInputParam =
                        $@"{SpaceUtils.TwoTabs}public Task<{type}> {functionNameUpper}QueryAsync({messageType} {messageVariableName}, BlockParameter blockParameter = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs}return ContractHandler.QueryAsync<{messageType}, {type}>({messageVariableName}, blockParameter);
{SpaceUtils.TwoTabs}}}";


                    var returnWithoutInputParam =
                        $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}public Task<{type}> {functionNameUpper}QueryAsync(BlockParameter blockParameter = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs}return ContractHandler.QueryAsync<{messageType}, {type}>(null, blockParameter);
{SpaceUtils.TwoTabs}}}";

                    var returnWithSimpleParams =
                        $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}public Task<{type}> {functionNameUpper}QueryAsync({_parameterAbiFunctionDtocSharpTemplate.GenerateAllFunctionParameters(functionABIModel.FunctionABI.InputParameters)}, BlockParameter blockParameter = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs}var {messageVariableName} = new {messageType}();
{_parameterAbiFunctionDtocSharpTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.FourTabs)}
{SpaceUtils.ThreeTabs}
{SpaceUtils.ThreeTabs}return ContractHandler.QueryAsync<{messageType}, {type}>({messageVariableName}, blockParameter);
{SpaceUtils.TwoTabs}}}";

                    if (functionABIModel.HasNoInputParameters())
                    {
                        return(returnWithInputParam + GenerateLineBreak() + returnWithoutInputParam + GenerateLineBreak());
                    }
                    else
                    {
                        return(returnWithInputParam + GenerateLineBreak() + returnWithSimpleParams + GenerateLineBreak());
                    }
                }
            }

            if (functionABIModel.IsTransaction())
            {
                var transactionRequestWithInput =
                    $@"{SpaceUtils.TwoTabs}public Task<string> {functionNameUpper}RequestAsync({messageType} {messageVariableName})
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs} return ContractHandler.SendRequestAsync({messageVariableName});
{SpaceUtils.TwoTabs}}}";

                var transactionRequestWithoutInput =
                    $@"{SpaceUtils.TwoTabs}public Task<string> {functionNameUpper}RequestAsync()
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs} return ContractHandler.SendRequestAsync<{messageType}>();
{SpaceUtils.TwoTabs}}}";


                var transactionRequestWithSimpleParams =
                    $@"{SpaceUtils.TwoTabs}public Task<string> {functionNameUpper}RequestAsync({_parameterAbiFunctionDtocSharpTemplate.GenerateAllFunctionParameters(functionABIModel.FunctionABI.InputParameters)})
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs}var {messageVariableName} = new {messageType}();
{_parameterAbiFunctionDtocSharpTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.FourTabs)}
{SpaceUtils.ThreeTabs}
{SpaceUtils.ThreeTabs} return ContractHandler.SendRequestAsync({messageVariableName});
{SpaceUtils.TwoTabs}}}";


                var transactionRequestAndReceiptWithInput =
                    $@"{SpaceUtils.TwoTabs}public Task<TransactionReceipt> {functionNameUpper}RequestAndWaitForReceiptAsync({messageType} {messageVariableName}, CancellationTokenSource cancellationToken = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs} return ContractHandler.SendRequestAndWaitForReceiptAsync({messageVariableName}, cancellationToken);
{SpaceUtils.TwoTabs}}}";

                var transactionRequestAndReceiptWithoutInput =
                    $@"{SpaceUtils.TwoTabs}public Task<TransactionReceipt> {functionNameUpper}RequestAndWaitForReceiptAsync(CancellationTokenSource cancellationToken = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs} return ContractHandler.SendRequestAndWaitForReceiptAsync<{messageType}>(null, cancellationToken);
{SpaceUtils.TwoTabs}}}";

                var transactionRequestAndReceiptWithSimpleParams =
                    $@"{SpaceUtils.TwoTabs}public Task<TransactionReceipt> {functionNameUpper}RequestAndWaitForReceiptAsync({_parameterAbiFunctionDtocSharpTemplate.GenerateAllFunctionParameters(functionABIModel.FunctionABI.InputParameters)}, CancellationTokenSource cancellationToken = null)
{SpaceUtils.TwoTabs}{{
{SpaceUtils.ThreeTabs}var {messageVariableName} = new {messageType}();
{_parameterAbiFunctionDtocSharpTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.FourTabs)}
{SpaceUtils.ThreeTabs}
{SpaceUtils.ThreeTabs} return ContractHandler.SendRequestAndWaitForReceiptAsync({messageVariableName}, cancellationToken);
{SpaceUtils.TwoTabs}}}";

                if (functionABIModel.HasNoInputParameters())
                {
                    return(transactionRequestWithInput + GenerateLineBreak()
                           + transactionRequestWithoutInput +
                           GenerateLineBreak() +
                           transactionRequestAndReceiptWithInput +
                           GenerateLineBreak() +
                           transactionRequestAndReceiptWithoutInput);
                }

                return(transactionRequestWithInput + GenerateLineBreak() + transactionRequestAndReceiptWithInput +
                       GenerateLineBreak() +
                       transactionRequestWithSimpleParams +
                       GenerateLineBreak() +
                       transactionRequestAndReceiptWithSimpleParams);
            }

            return(null);
        }
示例#4
0
        public string GenerateMethod(FunctionABI functionABI)
        {
            var functionCQSMessageModel = new FunctionCQSMessageModel(functionABI, _model.CQSNamespace);
            var functionOutputDTOModel  = new FunctionOutputDTOModel(functionABI, _model.FunctionOutputNamespace);
            var functionABIModel        = new FunctionABIModel(functionABI, _typeConvertor);

            var messageType         = functionCQSMessageModel.GetTypeName();
            var messageVariableName = functionCQSMessageModel.GetVariableName();
            var functionNameUpper   = _commonGenerators.GenerateClassName(functionABI.Name);

            if (functionABIModel.IsMultipleOutput() && !functionABIModel.IsTransaction())
            {
                var functionOutputDTOType = functionOutputDTOModel.GetTypeName();
                var returnWithInputParam  =
                    $@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}QueryAsync(ByVal {messageVariableName} As {messageType}, ByVal Optional blockParameter As BlockParameter = Nothing) As Task(Of {functionOutputDTOType})
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.QueryDeserializingToObjectAsync(Of {messageType}, {functionOutputDTOType})({messageVariableName}, blockParameter)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";


                var returnWithoutInputParam =
                    $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}Public Function {functionNameUpper}QueryAsync(ByVal Optional blockParameter As BlockParameter = Nothing) As Task(Of {functionOutputDTOType})
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}return ContractHandler.QueryDeserializingToObjectAsync(Of {messageType}, {functionOutputDTOType})(Nothing, blockParameter)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function
";

                var returnWithSimpleParams =
                    $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}Public Function {functionNameUpper}QueryAsync({_parameterAbiFunctionDtoVbTemplate.GenerateAllFunctionParameters(functionABIModel.FunctionABI.InputParameters)}, ByVal Optional blockParameter As BlockParameter = Nothing) As Task(Of {functionOutputDTOType})
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Dim {messageVariableName} = New {messageType}()
{_parameterAbiFunctionDtoVbTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.FourTabs)}
{SpaceUtils.ThreeTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.QueryDeserializingToObjectAsync(Of {messageType}, {functionOutputDTOType})({messageVariableName}, blockParameter)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                if (functionABIModel.HasNoInputParameters())
                {
                    return(returnWithInputParam + GenerateLineBreak() + returnWithoutInputParam + GenerateLineBreak());
                }
                else
                {
                    return(returnWithInputParam + GenerateLineBreak() + returnWithSimpleParams + GenerateLineBreak());
                }
            }

            if (functionABIModel.IsSingleOutput() && !functionABIModel.IsTransaction())
            {
                if (functionABI.OutputParameters != null && functionABI.OutputParameters.Length == 1 &&
                    functionABI.Constant)
                {
                    var type = functionABIModel.GetSingleOutputReturnType();

                    var returnWithInputParam =
                        $@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}QueryAsync(ByVal {messageVariableName} As {messageType}, ByVal Optional blockParameter As BlockParameter = Nothing) As Task(Of {type})
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.QueryAsync(Of {messageType}, {type})({messageVariableName}, blockParameter)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                    var returnWithoutInputParam =
                        $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}Public Function {functionNameUpper}QueryAsync(ByVal Optional blockParameter As BlockParameter = Nothing) As Task(Of {type})
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}return ContractHandler.QueryAsync(Of {messageType}, {type})(Nothing, blockParameter)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function
";

                    var returnWithSimpleParams =
                        $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}Public Function {functionNameUpper}QueryAsync({_parameterAbiFunctionDtoVbTemplate.GenerateAllFunctionParameters(functionABIModel.FunctionABI.InputParameters)}, ByVal Optional blockParameter As BlockParameter = Nothing) As Task(Of {type})
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Dim {messageVariableName} = New {messageType}()
{_parameterAbiFunctionDtoVbTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.FourTabs)}
{SpaceUtils.ThreeTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.QueryAsync(Of {messageType}, {type})({messageVariableName}, blockParameter)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                    if (functionABIModel.HasNoInputParameters())
                    {
                        return(returnWithInputParam + GenerateLineBreak() + returnWithoutInputParam + GenerateLineBreak());
                    }
                    else
                    {
                        return(returnWithInputParam + GenerateLineBreak() + returnWithSimpleParams + GenerateLineBreak());
                    }
                }
            }

            if (functionABIModel.IsTransaction())
            {
                var transactionRequestWithInput =
                    $@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}RequestAsync(ByVal {messageVariableName} As {messageType}) As Task(Of String)
{SpaceUtils.TwoTabs}            
{SpaceUtils.ThreeTabs}Return ContractHandler.SendRequestAsync(Of {messageType})({messageVariableName})
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                var transactionRequestWithoutInput =
                    $@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}RequestAsync() As Task(Of String)
{SpaceUtils.TwoTabs}            
{SpaceUtils.ThreeTabs}Return ContractHandler.SendRequestAsync(Of {messageType})
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                var transactionRequestWithSimpleParams =
                    $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}Public Function {functionNameUpper}RequestAsync({_parameterAbiFunctionDtoVbTemplate.GenerateAllFunctionParameters(functionABIModel.FunctionABI.InputParameters)}) As Task(Of String)
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Dim {messageVariableName} = New {messageType}()
{_parameterAbiFunctionDtoVbTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.FourTabs)}
{SpaceUtils.ThreeTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.SendRequestAsync(Of {messageType})({messageVariableName})
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                var transactionRequestAndReceiptWithInput =
                    $@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}RequestAndWaitForReceiptAsync(ByVal {messageVariableName} As {messageType}, ByVal Optional cancellationToken As CancellationTokenSource = Nothing) As Task(Of TransactionReceipt)
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.SendRequestAndWaitForReceiptAsync(Of {messageType})({messageVariableName}, cancellationToken)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";

                var transactionRequestAndReceiptWithoutInput =
                    $@"{SpaceUtils.TwoTabs}Public Function {functionNameUpper}RequestAndWaitForReceiptAsync(ByVal Optional cancellationToken As CancellationTokenSource = Nothing) As Task(Of TransactionReceipt)
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.SendRequestAndWaitForReceiptAsync(Of {messageType})(Nothing, cancellationToken)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";


                var transactionRequestAndReceiptWithSimpleParams =
                    $@"{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}Public Function {functionNameUpper}RequestAndWaitForReceiptAsync({_parameterAbiFunctionDtoVbTemplate.GenerateAllFunctionParameters(functionABIModel.FunctionABI.InputParameters)}, ByVal Optional cancellationToken As CancellationTokenSource = Nothing) As Task(Of TransactionReceipt)
{SpaceUtils.TwoTabs}
{SpaceUtils.ThreeTabs}Dim {messageVariableName} = New {messageType}()
{_parameterAbiFunctionDtoVbTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.FourTabs)}
{SpaceUtils.ThreeTabs}
{SpaceUtils.ThreeTabs}Return ContractHandler.SendRequestAndWaitForReceiptAsync(Of {messageType})({messageVariableName}, cancellationToken)
{SpaceUtils.TwoTabs}
{SpaceUtils.TwoTabs}End Function";


                if (functionABIModel.HasNoInputParameters())
                {
                    return(transactionRequestWithInput + GenerateLineBreak()
                           + transactionRequestWithoutInput +
                           GenerateLineBreak() +
                           transactionRequestAndReceiptWithInput +
                           GenerateLineBreak() +
                           transactionRequestAndReceiptWithoutInput);
                }

                return(transactionRequestWithInput + GenerateLineBreak() + transactionRequestAndReceiptWithInput +
                       GenerateLineBreak() +
                       transactionRequestWithSimpleParams +
                       GenerateLineBreak() +
                       transactionRequestAndReceiptWithSimpleParams);
            }

            return(null);
        }
        public string GenerateMethod(FunctionABI functionABI)
        {
            var functionCQSMessageModel = new FunctionCQSMessageModel(functionABI, null);
            var functionOutputDTOModel  = new FunctionOutputDTOModel(functionABI, null);
            var functionABIModel        = new FunctionABIModel(functionABI, _typeConvertor, CodeGenLanguage.CSharp);

            var messageType         = functionCQSMessageModel.GetTypeName();
            var messageVariableName = functionCQSMessageModel.GetVariableName();

            var functionNameUpper = _commonGenerators.GenerateClassName(functionABI.Name);

            if (functionABIModel.IsMultipleOutput() && !functionABIModel.IsTransaction())
            {
                var functionOutputDTOType      = functionOutputDTOModel.GetTypeName();
                var functionOutputVariableName = functionOutputDTOModel.GetVariableName();

                var returnWithInputParam =
                    $@"{SpaceUtils.ThreeTabs}var {messageVariableName} = new {messageType}(); 
{_parameterAbiFunctionDtocSharpTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.ThreeTabs)}
{SpaceUtils.ThreeTabs}var {functionOutputVariableName} = await contractHandler.QueryDeserializingToObjectAsync<{messageType}, {functionOutputDTOType}>({messageVariableName});";

                var returnWithoutInputParam =
                    $@"{SpaceUtils.ThreeTabs}var {functionOutputVariableName} = await contractHandler.QueryDeserializingToObjectAsync<{messageType}, {functionOutputDTOType}>();";

                if (functionABIModel.HasNoInputParameters())
                {
                    return(returnWithoutInputParam);
                }
                else
                {
                    return(returnWithInputParam);
                }
            }

            if (functionABIModel.IsSingleOutput() && !functionABIModel.IsTransaction())
            {
                if (functionABI.OutputParameters != null && functionABI.OutputParameters.Length == 1 &&
                    functionABI.Constant)
                {
                    var type                 = functionABIModel.GetSingleOutputReturnType();
                    var returnName           = functionCQSMessageModel.GetVariableName() + "Return";
                    var returnWithInputParam =
                        $@"{SpaceUtils.ThreeTabs}var {messageVariableName} = new {messageType}();
{_parameterAbiFunctionDtocSharpTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.ThreeTabs)}
{SpaceUtils.ThreeTabs}var {returnName} = await contractHandler.QueryAsync<{messageType}, {type}>({messageVariableName});";


                    var returnWithoutInputParam =
                        $@"{SpaceUtils.ThreeTabs}var {returnName} = await contractHandler.QueryAsync<{messageType}, {type}>();";


                    if (functionABIModel.HasNoInputParameters())
                    {
                        return(returnWithoutInputParam);
                    }
                    else
                    {
                        return(returnWithInputParam);
                    }
                }
            }

            if (functionABIModel.IsTransaction())
            {
                var returnName = functionCQSMessageModel.GetVariableName() + "TxnReceipt";
                var transactionRequestAndReceiptWithoutInput =
                    $@"{SpaceUtils.ThreeTabs}var {returnName} = await contractHandler.SendRequestAndWaitForReceiptAsync<{messageType}>();";

                var transactionRequestAndReceiptWithSimpleParams =
                    $@"{SpaceUtils.ThreeTabs}var {messageVariableName} = new {messageType}();
{_parameterAbiFunctionDtocSharpTemplate.GenerateAssigmentFunctionParametersToProperties(functionABIModel.FunctionABI.InputParameters, messageVariableName, SpaceUtils.ThreeTabs)}
{SpaceUtils.ThreeTabs}var {returnName} = await contractHandler.SendRequestAndWaitForReceiptAsync({messageVariableName});";

                if (functionABIModel.HasNoInputParameters())
                {
                    return(transactionRequestAndReceiptWithoutInput);
                }

                return(transactionRequestAndReceiptWithSimpleParams);
            }

            return(null);
        }