From 1294cf735c95b48da11ac40b117c189080892f68 Mon Sep 17 00:00:00 2001 From: m-nash Date: Mon, 14 Jun 2021 11:16:55 -0700 Subject: [PATCH 1/2] remove ph classes --- .../src/Adapters/PhWrappingAsyncPageable.cs | 67 ------------------- .../src/Adapters/PhWrappingPageable.cs | 57 ---------------- .../src/Adapters/WrappingPage.cs | 45 ------------- 3 files changed, 169 deletions(-) delete mode 100644 sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhWrappingAsyncPageable.cs delete mode 100644 sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhWrappingPageable.cs delete mode 100644 sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/WrappingPage.cs diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhWrappingAsyncPageable.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhWrappingAsyncPageable.cs deleted file mode 100644 index 43a76a766317..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhWrappingAsyncPageable.cs +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace Azure.ResourceManager.Core -{ - /// - /// Returns an AsyncPageable that transforms each page of contents after they are retrieved from the server - /// according to the profived transformation function - /// - /// The model returned by existing AsyncPageable methods. - /// The to convert TModel into. - public class PhWrappingAsyncPageable : AsyncPageable - where TOperations : class - where TModel : class - { - private readonly Func _converter; - private readonly IEnumerable> _wrapped; - - /// - /// Initializes a new instance of the class for mocking. - /// - protected PhWrappingAsyncPageable() - { - } - - /// - /// Initializes a new instance of the class. - /// - /// The results to wrap. - /// The function used to convert from existing type to new type. - public PhWrappingAsyncPageable(AsyncPageable wrapped, Func converter) - { - _wrapped = new[] { wrapped }; - _converter = converter; - } - - /// - /// Initializes a new instance of the class. - /// - /// The results to wrap. - /// The function used to convert from existing type to new type. - public PhWrappingAsyncPageable(IEnumerable> wrapped, Func converter) - { - _wrapped = wrapped; - _converter = converter; - } - - /// - public override async IAsyncEnumerable> AsPages( - string continuationToken = null, - int? pageSizeHint = null) - { - foreach (var pageEnum in _wrapped) - { - await foreach (var page in pageEnum.AsPages().WithCancellation(CancellationToken)) - { - yield return new WrappingPage(page, _converter); - } - } - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhWrappingPageable.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhWrappingPageable.cs deleted file mode 100644 index c11077cb0107..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/PhWrappingPageable.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; - -namespace Azure.ResourceManager.Core -{ - /// - /// This class allows performing conversions on pages of data as they are accessed - used in the prototype to convett - /// between underlying model types and the new model types that extend Resource, - /// and also for returning Operations classes for those underlying objects. - /// - /// The type parameter of the Pageable we are wrapping. - /// The desired type parameter of the returned pageable. - public class PhWrappingPageable : Pageable - where TOperations : class - where TModel : class - { - private readonly Func _converter; - private readonly IEnumerable> _wrapped; - - /// - /// Initializes a new instance of the class. - /// - /// The results to wrap. - /// The function used to convert from existing type to new type. - public PhWrappingPageable(Pageable wrapped, Func converter) - { - _wrapped = new[] { wrapped }; - _converter = converter; - } - - /// - /// Initializes a new instance of the class. - /// - /// The results to wrap. - /// The function used to convert from existing type to new type. - public PhWrappingPageable(IEnumerable> wrapped, Func converter) - { - _wrapped = wrapped; - _converter = converter; - } - - /// - public override IEnumerable> AsPages(string continuationToken = null, int? pageSizeHint = null) - { - foreach (var pages in _wrapped) - { - foreach (var page in pages.AsPages()) - { - yield return new WrappingPage(page, _converter); - } - } - } - } -} diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/WrappingPage.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/WrappingPage.cs deleted file mode 100644 index df1faea2f915..000000000000 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/Adapters/WrappingPage.cs +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.Collections.Generic; -using System.Linq; - -namespace Azure.ResourceManager.Core -{ - /// - /// A class representing a wrapper over - /// - /// The type parameter we are wrapping. - /// The desired type parameter of the returned page. - internal class WrappingPage : Page - where TOperations : class - where TModel : class - { - private readonly Func _converter; - private readonly Page _wrapped; - - /// - /// Initializes a new instance of the class. - /// - /// The results to wrap. - /// The function used to convert from existing type to new type. - internal WrappingPage(Page wrapped, Func converter) - { - _wrapped = wrapped; - _converter = converter; - } - - /// - public override IReadOnlyList Values => _wrapped.Values.Select(_converter).ToList(); - - /// - public override string ContinuationToken => _wrapped.ContinuationToken; - - /// - public override Response GetRawResponse() - { - return _wrapped.GetRawResponse(); - } - } -} From f03188fef3ae242123f92b789f811cb832618218 Mon Sep 17 00:00:00 2001 From: m-nash Date: Mon, 14 Jun 2021 11:22:47 -0700 Subject: [PATCH 2/2] add temp files to proto --- .../Adapters/PhWrappingAsyncPageable.cs | 67 +++++++++++++++++++ .../compute/Adapters/PhWrappingPageable.cs | 57 ++++++++++++++++ .../compute/Adapters/WrappingPage.cs | 45 +++++++++++++ .../Adapters/PhWrappingAsyncPageable.cs | 67 +++++++++++++++++++ .../network/Adapters/PhWrappingPageable.cs | 57 ++++++++++++++++ .../network/Adapters/WrappingPage.cs | 45 +++++++++++++ 6 files changed, 338 insertions(+) create mode 100644 sdk/resourcemanager/Proto.Client/compute/Adapters/PhWrappingAsyncPageable.cs create mode 100644 sdk/resourcemanager/Proto.Client/compute/Adapters/PhWrappingPageable.cs create mode 100644 sdk/resourcemanager/Proto.Client/compute/Adapters/WrappingPage.cs create mode 100644 sdk/resourcemanager/Proto.Client/network/Adapters/PhWrappingAsyncPageable.cs create mode 100644 sdk/resourcemanager/Proto.Client/network/Adapters/PhWrappingPageable.cs create mode 100644 sdk/resourcemanager/Proto.Client/network/Adapters/WrappingPage.cs diff --git a/sdk/resourcemanager/Proto.Client/compute/Adapters/PhWrappingAsyncPageable.cs b/sdk/resourcemanager/Proto.Client/compute/Adapters/PhWrappingAsyncPageable.cs new file mode 100644 index 000000000000..43a76a766317 --- /dev/null +++ b/sdk/resourcemanager/Proto.Client/compute/Adapters/PhWrappingAsyncPageable.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Core +{ + /// + /// Returns an AsyncPageable that transforms each page of contents after they are retrieved from the server + /// according to the profived transformation function + /// + /// The model returned by existing AsyncPageable methods. + /// The to convert TModel into. + public class PhWrappingAsyncPageable : AsyncPageable + where TOperations : class + where TModel : class + { + private readonly Func _converter; + private readonly IEnumerable> _wrapped; + + /// + /// Initializes a new instance of the class for mocking. + /// + protected PhWrappingAsyncPageable() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + public PhWrappingAsyncPageable(AsyncPageable wrapped, Func converter) + { + _wrapped = new[] { wrapped }; + _converter = converter; + } + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + public PhWrappingAsyncPageable(IEnumerable> wrapped, Func converter) + { + _wrapped = wrapped; + _converter = converter; + } + + /// + public override async IAsyncEnumerable> AsPages( + string continuationToken = null, + int? pageSizeHint = null) + { + foreach (var pageEnum in _wrapped) + { + await foreach (var page in pageEnum.AsPages().WithCancellation(CancellationToken)) + { + yield return new WrappingPage(page, _converter); + } + } + } + } +} diff --git a/sdk/resourcemanager/Proto.Client/compute/Adapters/PhWrappingPageable.cs b/sdk/resourcemanager/Proto.Client/compute/Adapters/PhWrappingPageable.cs new file mode 100644 index 000000000000..c11077cb0107 --- /dev/null +++ b/sdk/resourcemanager/Proto.Client/compute/Adapters/PhWrappingPageable.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Core +{ + /// + /// This class allows performing conversions on pages of data as they are accessed - used in the prototype to convett + /// between underlying model types and the new model types that extend Resource, + /// and also for returning Operations classes for those underlying objects. + /// + /// The type parameter of the Pageable we are wrapping. + /// The desired type parameter of the returned pageable. + public class PhWrappingPageable : Pageable + where TOperations : class + where TModel : class + { + private readonly Func _converter; + private readonly IEnumerable> _wrapped; + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + public PhWrappingPageable(Pageable wrapped, Func converter) + { + _wrapped = new[] { wrapped }; + _converter = converter; + } + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + public PhWrappingPageable(IEnumerable> wrapped, Func converter) + { + _wrapped = wrapped; + _converter = converter; + } + + /// + public override IEnumerable> AsPages(string continuationToken = null, int? pageSizeHint = null) + { + foreach (var pages in _wrapped) + { + foreach (var page in pages.AsPages()) + { + yield return new WrappingPage(page, _converter); + } + } + } + } +} diff --git a/sdk/resourcemanager/Proto.Client/compute/Adapters/WrappingPage.cs b/sdk/resourcemanager/Proto.Client/compute/Adapters/WrappingPage.cs new file mode 100644 index 000000000000..df1faea2f915 --- /dev/null +++ b/sdk/resourcemanager/Proto.Client/compute/Adapters/WrappingPage.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Core +{ + /// + /// A class representing a wrapper over + /// + /// The type parameter we are wrapping. + /// The desired type parameter of the returned page. + internal class WrappingPage : Page + where TOperations : class + where TModel : class + { + private readonly Func _converter; + private readonly Page _wrapped; + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + internal WrappingPage(Page wrapped, Func converter) + { + _wrapped = wrapped; + _converter = converter; + } + + /// + public override IReadOnlyList Values => _wrapped.Values.Select(_converter).ToList(); + + /// + public override string ContinuationToken => _wrapped.ContinuationToken; + + /// + public override Response GetRawResponse() + { + return _wrapped.GetRawResponse(); + } + } +} diff --git a/sdk/resourcemanager/Proto.Client/network/Adapters/PhWrappingAsyncPageable.cs b/sdk/resourcemanager/Proto.Client/network/Adapters/PhWrappingAsyncPageable.cs new file mode 100644 index 000000000000..43a76a766317 --- /dev/null +++ b/sdk/resourcemanager/Proto.Client/network/Adapters/PhWrappingAsyncPageable.cs @@ -0,0 +1,67 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace Azure.ResourceManager.Core +{ + /// + /// Returns an AsyncPageable that transforms each page of contents after they are retrieved from the server + /// according to the profived transformation function + /// + /// The model returned by existing AsyncPageable methods. + /// The to convert TModel into. + public class PhWrappingAsyncPageable : AsyncPageable + where TOperations : class + where TModel : class + { + private readonly Func _converter; + private readonly IEnumerable> _wrapped; + + /// + /// Initializes a new instance of the class for mocking. + /// + protected PhWrappingAsyncPageable() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + public PhWrappingAsyncPageable(AsyncPageable wrapped, Func converter) + { + _wrapped = new[] { wrapped }; + _converter = converter; + } + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + public PhWrappingAsyncPageable(IEnumerable> wrapped, Func converter) + { + _wrapped = wrapped; + _converter = converter; + } + + /// + public override async IAsyncEnumerable> AsPages( + string continuationToken = null, + int? pageSizeHint = null) + { + foreach (var pageEnum in _wrapped) + { + await foreach (var page in pageEnum.AsPages().WithCancellation(CancellationToken)) + { + yield return new WrappingPage(page, _converter); + } + } + } + } +} diff --git a/sdk/resourcemanager/Proto.Client/network/Adapters/PhWrappingPageable.cs b/sdk/resourcemanager/Proto.Client/network/Adapters/PhWrappingPageable.cs new file mode 100644 index 000000000000..c11077cb0107 --- /dev/null +++ b/sdk/resourcemanager/Proto.Client/network/Adapters/PhWrappingPageable.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; + +namespace Azure.ResourceManager.Core +{ + /// + /// This class allows performing conversions on pages of data as they are accessed - used in the prototype to convett + /// between underlying model types and the new model types that extend Resource, + /// and also for returning Operations classes for those underlying objects. + /// + /// The type parameter of the Pageable we are wrapping. + /// The desired type parameter of the returned pageable. + public class PhWrappingPageable : Pageable + where TOperations : class + where TModel : class + { + private readonly Func _converter; + private readonly IEnumerable> _wrapped; + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + public PhWrappingPageable(Pageable wrapped, Func converter) + { + _wrapped = new[] { wrapped }; + _converter = converter; + } + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + public PhWrappingPageable(IEnumerable> wrapped, Func converter) + { + _wrapped = wrapped; + _converter = converter; + } + + /// + public override IEnumerable> AsPages(string continuationToken = null, int? pageSizeHint = null) + { + foreach (var pages in _wrapped) + { + foreach (var page in pages.AsPages()) + { + yield return new WrappingPage(page, _converter); + } + } + } + } +} diff --git a/sdk/resourcemanager/Proto.Client/network/Adapters/WrappingPage.cs b/sdk/resourcemanager/Proto.Client/network/Adapters/WrappingPage.cs new file mode 100644 index 000000000000..df1faea2f915 --- /dev/null +++ b/sdk/resourcemanager/Proto.Client/network/Adapters/WrappingPage.cs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Linq; + +namespace Azure.ResourceManager.Core +{ + /// + /// A class representing a wrapper over + /// + /// The type parameter we are wrapping. + /// The desired type parameter of the returned page. + internal class WrappingPage : Page + where TOperations : class + where TModel : class + { + private readonly Func _converter; + private readonly Page _wrapped; + + /// + /// Initializes a new instance of the class. + /// + /// The results to wrap. + /// The function used to convert from existing type to new type. + internal WrappingPage(Page wrapped, Func converter) + { + _wrapped = wrapped; + _converter = converter; + } + + /// + public override IReadOnlyList Values => _wrapped.Values.Select(_converter).ToList(); + + /// + public override string ContinuationToken => _wrapped.ContinuationToken; + + /// + public override Response GetRawResponse() + { + return _wrapped.GetRawResponse(); + } + } +}