diff --git a/src/AutoRest.CSharp/Common/Output/Models/RestClient.cs b/src/AutoRest.CSharp/Common/Output/Models/RestClient.cs index b7864cb2ea3..f1e2aa27a81 100644 --- a/src/AutoRest.CSharp/Common/Output/Models/RestClient.cs +++ b/src/AutoRest.CSharp/Common/Output/Models/RestClient.cs @@ -95,7 +95,7 @@ protected virtual Dictionary EnsureNormalMetho return requestMethods; } - protected virtual Dictionary EnsureGetNextPageMethods() + protected Dictionary EnsureGetNextPageMethods() { var nextPageMethods = new Dictionary(); foreach (var operation in OperationGroup.Operations) @@ -177,13 +177,13 @@ protected static RestClientMethod BuildNextPageMethod(RestClientMethod method, O operation); } - public virtual RestClientMethod? GetNextOperationMethod(ServiceRequest request) + public RestClientMethod? GetNextOperationMethod(ServiceRequest request) { _nextPageMethods.TryGetValue(request, out RestClientMethod? value); return value; } - public virtual RestClientMethod GetOperationMethod(ServiceRequest request) + public RestClientMethod GetOperationMethod(ServiceRequest request) { return _requestMethods[request]; } diff --git a/src/AutoRest.CSharp/DataPlane/Output/DataPlaneRestClient.cs b/src/AutoRest.CSharp/DataPlane/Output/DataPlaneRestClient.cs index 74e012749b3..6e02670f384 100644 --- a/src/AutoRest.CSharp/DataPlane/Output/DataPlaneRestClient.cs +++ b/src/AutoRest.CSharp/DataPlane/Output/DataPlaneRestClient.cs @@ -1,35 +1,21 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See License.txt in the project root for license information. -using System; using System.Collections.Generic; -using System.Linq; -using AutoRest.CSharp.Generation.Types; using AutoRest.CSharp.Input; using AutoRest.CSharp.Output.Models.Requests; -using AutoRest.CSharp.Output.Models.Responses; -using AutoRest.CSharp.Output.Models.Serialization; -using AutoRest.CSharp.Output.Models.Shared; using AutoRest.CSharp.Output.Models.Types; -using AutoRest.CSharp.Utilities; -using Azure.Core; -using Request = AutoRest.CSharp.Output.Models.Requests.Request; -using StatusCodes = AutoRest.CSharp.Output.Models.Responses.StatusCodes; namespace AutoRest.CSharp.Output.Models { internal class DataPlaneRestClient : RestClient { - private CachedDictionary _requestMethods; - private CachedDictionary _nextPageMethods; private BuildContext _context; public DataPlaneRestClient(OperationGroup operationGroup, BuildContext context) : base(operationGroup, context, context.Library.FindClient(operationGroup)?.Declaration?.Name) { _context = context; - _requestMethods = new CachedDictionary (EnsureNormalMethods); - _nextPageMethods = new CachedDictionary (EnsureGetNextPageMethods); } protected override Dictionary EnsureNormalMethods() @@ -53,49 +39,5 @@ protected override Dictionary EnsureNormalMeth return requestMethods; } - - protected override Dictionary EnsureGetNextPageMethods() - { - var nextPageMethods = new Dictionary(); - foreach (var operation in OperationGroup.Operations) - { - var paging = operation.Language.Default.Paging; - if (paging == null) - { - continue; - } - foreach (var serviceRequest in operation.Requests) - { - RestClientMethod? nextMethod = null; - if (paging.NextLinkOperation != null) - { - nextMethod = GetOperationMethod(paging.NextLinkOperation.Requests.Single()); - } - else if (paging.NextLinkName != null) - { - var method = GetOperationMethod(serviceRequest); - nextMethod = BuildNextPageMethod(method, operation); - } - - if (nextMethod != null) - { - nextPageMethods.Add(serviceRequest, nextMethod); - } - } - } - - return nextPageMethods; - } - - public override RestClientMethod? GetNextOperationMethod(ServiceRequest request) - { - _nextPageMethods.TryGetValue(request, out RestClientMethod? value); - return value; - } - - public override RestClientMethod GetOperationMethod(ServiceRequest request) - { - return _requestMethods[request]; - } } }