public virtual string SuccessCallback(bool filterRequired = false) { IndentedStringBuilder builder = new IndentedStringBuilder(); if (ReturnTypeModel.NeedsConversion) { builder.AppendLine("ServiceResponse<{0}> result = {1}Delegate(response);", ReturnTypeModel.GenericBodyWireTypeString, this.Name); builder.AppendLine("{0} body = null;", ReturnTypeModel.BodyClientType) .AppendLine("if (result.getBody() != null) {") .Indent().AppendLine("{0}", ReturnTypeModel.ConvertBodyToClientType("result.getBody()", "body")) .Outdent().AppendLine("}"); builder.AppendLine("ServiceResponse<{0}> clientResponse = new ServiceResponse<{0}>(body, result.getResponse());", ReturnTypeModel.GenericBodyClientTypeString); builder.AppendLine("if (serviceCallback != null) {") .Indent().AppendLine("serviceCallback.success(clientResponse);", ReturnTypeModel.GenericBodyClientTypeString) .Outdent().AppendLine("}"); builder.AppendLine("serviceCall.success(clientResponse);"); } else { builder.AppendLine("{0} clientResponse = {1}Delegate(response);", ReturnTypeModel.WireResponseTypeString, this.Name); builder.AppendLine("if (serviceCallback != null) {") .Indent().AppendLine("serviceCallback.success(clientResponse);", this.Name) .Outdent().AppendLine("}"); builder.AppendLine("serviceCall.success(clientResponse);"); } return(builder.ToString()); }
public override string ClientResponse(bool filterRequired = false) { if (this.IsPagingOperation || this.IsPagingNextOperation) { IndentedStringBuilder builder = new IndentedStringBuilder(); builder.AppendLine("ServiceResponse<{0}> result = {1}Delegate(response);", ReturnTypeModel.GenericBodyWireTypeString, this.Name); builder.AppendLine("{0} body = null;", ReturnTypeModel.ServiceCallGenericParameterString) .AppendLine("if (result.getBody() != null) {") .Indent().AppendLine("{0}", ReturnTypeModel.ConvertBodyToClientType("result.getBody()", "body")) .Outdent().AppendLine("}"); builder.AppendLine("ServiceResponse<{0}> clientResponse = new ServiceResponse<{0}>(body, result.getResponse());", ReturnTypeModel.ServiceCallGenericParameterString); return(builder.ToString()); } else if (this.IsPagingNonPollingOperation) { IndentedStringBuilder builder = new IndentedStringBuilder(); builder.AppendLine("ServiceResponse<{0}> result = {1}Delegate(response);", ReturnTypeModel.GenericBodyWireTypeString, this.Name); builder.AppendLine("ServiceResponse<{0}> clientResponse = new ServiceResponse<{0}>(result.getBody().getItems(), result.getResponse());", ReturnTypeModel.ServiceCallGenericParameterString); return(builder.ToString()); } else { return(base.ClientResponse(filterRequired)); } }
public virtual string ResponseGeneration(bool filterRequired = false) { if (ReturnTypeModel.NeedsConversion) { IndentedStringBuilder builder = new IndentedStringBuilder(); builder.AppendLine("ServiceResponse<{0}> response = {1}Delegate(call.execute());", ReturnTypeModel.GenericBodyWireTypeString, this.Name.ToCamelCase()); builder.AppendLine("{0} body = null;", ReturnTypeModel.BodyClientType.Name) .AppendLine("if (response.getBody() != null) {") .Indent().AppendLine("{0}", ReturnTypeModel.ConvertBodyToClientType("response.getBody()", "body")) .Outdent().AppendLine("}"); return(builder.ToString()); } return(""); }