From 7af4fc123334e1c3586f8f721444111003d27a92 Mon Sep 17 00:00:00 2001 From: Feng Zhou Date: Tue, 15 Jun 2021 22:59:19 +0800 Subject: [PATCH] change Parent in ContainerBase to OperationsBase type --- .../Azure.ResourceManager.Core/src/ContainerBase.cs | 4 ++-- .../Azure.ResourceManager.Core/src/OperationsBase.cs | 10 ++++++++++ .../src/ResourceContainerBase.cs | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ContainerBase.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ContainerBase.cs index 74f5ad739b675..bbd1df865047b 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ContainerBase.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ContainerBase.cs @@ -54,7 +54,7 @@ protected ContainerBase(ArmClientOptions options, TokenCredential credential, Ur /// Initializes a new instance of the class. /// /// The resource representing the parent resource. - protected ContainerBase(ResourceOperationsBase parent) + protected ContainerBase(OperationsBase parent) : base(new ClientContext(parent.ClientOptions, parent.Credential, parent.BaseUri, parent.Pipeline), parent.Id) { Parent = parent; @@ -63,6 +63,6 @@ protected ContainerBase(ResourceOperationsBase parent) /// /// Gets the parent resource of this resource. /// - protected ResourceOperationsBase Parent { get; } + protected OperationsBase Parent { get; } } } diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/OperationsBase.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/OperationsBase.cs index 339722d4c5029..a30a545fcbbd0 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/OperationsBase.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/OperationsBase.cs @@ -20,6 +20,16 @@ protected OperationsBase() { } + /// + /// Initializes a new instance of the class. + /// + /// The resource representing the parent resource. + /// The identifier of the resource that is the target of operations. + protected OperationsBase(OperationsBase parentOperations, ResourceIdentifier id) + : this(new ClientContext(parentOperations.ClientOptions, parentOperations.Credential, parentOperations.BaseUri, parentOperations.Pipeline), id) + { + } + /// /// Initializes a new instance of the class. /// diff --git a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceContainerBase.cs b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceContainerBase.cs index 482b10d811628..18c1f368e3919 100644 --- a/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceContainerBase.cs +++ b/sdk/resourcemanager/Azure.ResourceManager.Core/src/ResourceContainerBase.cs @@ -48,6 +48,11 @@ protected ResourceContainerBase(ResourceOperationsBase parent) { } + /// + /// Gets the parent resource of this resource. + /// + protected new ResourceOperationsBase Parent { get {return base.Parent as ResourceOperationsBase;} } + /// /// Verify that the input resource Id is a valid container for this type. ///