/// <summary> /// Changes paginated method signatures to return Page type. /// </summary> /// <param name="serviceClient"></param> private void NormalizePaginatedMethods(ServiceClient serviceClient) { if (serviceClient == null) { throw new ArgumentNullException("serviceClient"); } var convertedTypes = new Dictionary<IType, Response>(); foreach (var method in serviceClient.Methods.Where(m => m.Extensions.ContainsKey(AzureExtensions.PageableExtension))) { foreach (var responseStatus in method.Responses.Where(r => r.Value.Body is CompositeType).Select(s => s.Key)) { var compositType = (CompositeType)method.Responses[responseStatus].Body; var sequenceType = compositType.Properties.Select(p => p.Type).FirstOrDefault(t => t is SequenceType) as SequenceType; // if the type is a wrapper over page-able response if (sequenceType != null) { string pagableTypeName = GetPagingSetting(method.Extensions, sequenceType.ElementType.Name); CompositeType pagedResult = new CompositeType { Name = pagableTypeName }; convertedTypes[compositType] = new Response(pagedResult, null); method.Responses[responseStatus] = convertedTypes[compositType]; break; } } if (convertedTypes.ContainsKey(method.ReturnType.Body)) { method.ReturnType = convertedTypes[method.ReturnType.Body]; } } AzureExtensions.RemoveUnreferencedTypes(serviceClient, convertedTypes.Keys.Cast<CompositeType>().Select(t => t.Name)); }
public override Response NormalizeTypeReference(Response typePair) { return new Response((ITypeModel) NormalizeTypeReference(typePair.Body), (ITypeModel) NormalizeTypeReference(typePair.Headers)); }
public AzureResponseModel(Response response, AzureMethodTemplateModel method) : base (response) { this._response = response; this._method = method; }
public ResponseModel(Response response) { this._response = response; this._interfaceImports = new List<string>(); this._implImports = new List<string>(); }