Exemplo n.º 1
0
        /// <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));
        }
Exemplo n.º 2
0
 public override Response NormalizeTypeReference(Response typePair)
 {
     return new Response((ITypeModel) NormalizeTypeReference(typePair.Body),
                         (ITypeModel) NormalizeTypeReference(typePair.Headers));
 }
Exemplo n.º 3
0
 public AzureResponseModel(Response response, AzureMethodTemplateModel method)
     : base (response)
 {
     this._response = response;
     this._method = method;
 }
Exemplo n.º 4
0
 public ResponseModel(Response response)
 {
     this._response = response;
     this._interfaceImports = new List<string>();
     this._implImports = new List<string>();
 }