Skip to content

Commit

Permalink
5285 Remove TrackedResource<TIdentifier, TModel> class. (#21376)
Browse files Browse the repository at this point in the history
* Delete TrackedResource.cs

* Removed class from Core added to individual Proto Libraries

* Removing imported class in Proto.Client

* Add missing new lines
  • Loading branch information
JonathanCrd authored May 27, 2021
1 parent 09b2b13 commit d936847
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace Azure.ResourceManager.Core.Adapters
/// </summary>
/// <typeparam name="TIdentifier"> The type of the underlying resource id </typeparam>
/// <typeparam name="TModel"> The type of the underlying model this class wraps </typeparam>
public abstract class TrackedResource<TIdentifier, TModel> : TrackedResource<TIdentifier>
public abstract class TrackedResource<TIdentifier, TModel> : TrackedResource<TIdentifier>
where TIdentifier : TenantResourceIdentifier
where TModel : class
{
Expand All @@ -19,7 +19,7 @@ public abstract class TrackedResource<TIdentifier, TModel> : TrackedResource<TId
/// <param name="location"> The location of the resource. </param>
/// <param name="data"> The model to copy from. </param>
protected TrackedResource(TIdentifier id, LocationData location, TModel data)
:base(id, id?.Name, id?.ResourceType, location, null)
: base(id, id?.Name, id?.ResourceType, location, null)
{
Model = data;
}
Expand Down
41 changes: 41 additions & 0 deletions sdk/resourcemanager/Proto.Client/compute/TrackedResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.ResourceManager.Core.Adapters
{
/// <summary>
/// A class representing a generic tracked resource in Azure.
/// </summary>
/// <typeparam name="TIdentifier"> The type of the underlying resource id </typeparam>
/// <typeparam name="TModel"> The type of the underlying model this class wraps </typeparam>
public abstract class TrackedResource<TIdentifier, TModel> : TrackedResource<TIdentifier>
where TIdentifier : TenantResourceIdentifier
where TModel : class
{
/// <summary>
/// Initializes a new instance of the <see cref="TrackedResource{TModel, TIdentifier}"/> class.
/// </summary>
/// <param name="id"> The identifier of the resource that is the target of operations. </param>
/// <param name="location"> The location of the resource. </param>
/// <param name="data"> The model to copy from. </param>
protected TrackedResource(TIdentifier id, LocationData location, TModel data)
: base(id, id?.Name, id?.ResourceType, location, null)
{
Model = data;
}

/// <summary>
/// Gets or sets the Model this resource is based off.
/// </summary>
public virtual TModel Model { get; set; }

/// <summary>
/// Converts from a <see cref="TrackedResource{TModel}"/> into the TModel.
/// </summary>
/// <param name="other"> The tracked resource convert from. </param>
public static implicit operator TModel(TrackedResource<TIdentifier, TModel> other)
{
return other.Model;
}
}
}
41 changes: 41 additions & 0 deletions sdk/resourcemanager/Proto.Client/network/TrackedResource.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

namespace Azure.ResourceManager.Core.Adapters
{
/// <summary>
/// A class representing a generic tracked resource in Azure.
/// </summary>
/// <typeparam name="TIdentifier"> The type of the underlying resource id </typeparam>
/// <typeparam name="TModel"> The type of the underlying model this class wraps </typeparam>
public abstract class TrackedResource<TIdentifier, TModel> : TrackedResource<TIdentifier>
where TIdentifier : TenantResourceIdentifier
where TModel : class
{
/// <summary>
/// Initializes a new instance of the <see cref="TrackedResource{TModel, TIdentifier}"/> class.
/// </summary>
/// <param name="id"> The identifier of the resource that is the target of operations. </param>
/// <param name="location"> The location of the resource. </param>
/// <param name="data"> The model to copy from. </param>
protected TrackedResource(TIdentifier id, LocationData location, TModel data)
: base(id, id?.Name, id?.ResourceType, location, null)
{
Model = data;
}

/// <summary>
/// Gets or sets the Model this resource is based off.
/// </summary>
public virtual TModel Model { get; set; }

/// <summary>
/// Converts from a <see cref="TrackedResource{TModel}"/> into the TModel.
/// </summary>
/// <param name="other"> The tracked resource convert from. </param>
public static implicit operator TModel(TrackedResource<TIdentifier, TModel> other)
{
return other.Model;
}
}
}

0 comments on commit d936847

Please sign in to comment.