Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}
}