Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert breaking changes adding IContextCache to deploy connectors #13489

Merged
merged 2 commits into from
Nov 28, 2022
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
@@ -0,0 +1,48 @@
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Core.Deploy;

/// <summary>
/// Extension methods adding backwards-compatability between <see cref="IDataTypeConfigurationConnector" /> and <see cref="IDataTypeConfigurationConnector2" />.
/// </summary>
/// <remarks>
/// These extension methods will be removed in Umbraco 13.
/// </remarks>
public static class DataTypeConfigurationConnectorExtensions
{
/// <summary>
/// Gets the artifact configuration value corresponding to a data type configuration and gather dependencies.
/// </summary>
/// <param name="connector">The connector.</param>
/// <param name="dataType">The data type.</param>
/// <param name="dependencies">The dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The artifact configuration value.
/// </returns>
/// <remarks>
/// This extension method tries to make use of the <see cref="IContextCache" /> on types also implementing <see cref="IDataTypeConfigurationConnector2" />.
/// </remarks>
public static string? ToArtifact(this IDataTypeConfigurationConnector connector, IDataType dataType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
=> connector is IDataTypeConfigurationConnector2 connector2
? connector2.ToArtifact(dataType, dependencies, contextCache)
: connector.ToArtifact(dataType, dependencies);

/// <summary>
/// Gets the data type configuration corresponding to an artifact configuration value.
/// </summary>
/// <param name="connector">The connector.</param>
/// <param name="dataType">The data type.</param>
/// <param name="configuration">The artifact configuration value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The data type configuration.
/// </returns>
/// <remarks>
/// This extension method tries to make use of the <see cref="IContextCache" /> on types also implementing <see cref="IDataTypeConfigurationConnector2" />.
/// </remarks>
public static object? FromArtifact(this IDataTypeConfigurationConnector connector, IDataType dataType, string? configuration, IContextCache contextCache)
=> connector is IDataTypeConfigurationConnector2 connector2
? connector2.FromArtifact(dataType, configuration, contextCache)
: connector.FromArtifact(dataType, configuration);
}
32 changes: 4 additions & 28 deletions src/Umbraco.Core/Deploy/IDataTypeConfigurationConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,17 @@ public interface IDataTypeConfigurationConnector
/// <returns>
/// The artifact configuration value.
/// </returns>
[Obsolete("Use the overload accepting IContextCache instead. This overload will be removed in a future version.")]
string? ToArtifact(IDataType dataType, ICollection<ArtifactDependency> dependencies)
=> ToArtifact(dataType, dependencies, PassThroughCache.Instance);

/// <summary>
/// Gets the artifact configuration value corresponding to a data type configuration and gather dependencies.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="dependencies">The dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The artifact configuration value.
/// </returns>
string? ToArtifact(IDataType dataType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache);

/// <summary>
/// Gets the data type configuration corresponding to an artifact configuration value.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="configuration">The artifact configuration value.</param>
/// <returns>
/// The data type configuration.
/// </returns>
[Obsolete("Use the overload accepting IContextCache instead. This overload will be removed in a future version.")]
object? FromArtifact(IDataType dataType, string? configuration)
=> FromArtifact(dataType, configuration, PassThroughCache.Instance);
[Obsolete($"Implement {nameof(IDataTypeConfigurationConnector2)} and use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
string? ToArtifact(IDataType dataType, ICollection<ArtifactDependency> dependencies);

/// <summary>
/// Gets the data type configuration corresponding to an artifact configuration value.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="configuration">The artifact configuration value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The data type configuration.
/// </returns>
object? FromArtifact(IDataType dataType, string? configuration, IContextCache contextCache);
[Obsolete($"Implement {nameof(IDataTypeConfigurationConnector2)} and use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
object? FromArtifact(IDataType dataType, string? configuration);
}
56 changes: 56 additions & 0 deletions src/Umbraco.Core/Deploy/IDataTypeConfigurationConnector2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Core.Deploy;

/// <inheritdoc />
/// <remarks>
/// This interface will be merged back into <see cref="IDataTypeConfigurationConnector" /> and removed in Umbraco 13.
/// </remarks>
public interface IDataTypeConfigurationConnector2 : IDataTypeConfigurationConnector
{
/// <summary>
/// Gets the artifact configuration value corresponding to a data type configuration and gather dependencies.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="dependencies">The dependencies.</param>
/// <returns>
/// The artifact configuration value.
/// </returns>
[Obsolete($"Use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
string? IDataTypeConfigurationConnector.ToArtifact(IDataType dataType, ICollection<ArtifactDependency> dependencies)
=> ToArtifact(dataType, dependencies, PassThroughCache.Instance);

/// <summary>
/// Gets the artifact configuration value corresponding to a data type configuration and gather dependencies.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="dependencies">The dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The artifact configuration value.
/// </returns>
string? ToArtifact(IDataType dataType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache);

/// <summary>
/// Gets the data type configuration corresponding to an artifact configuration value.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="configuration">The artifact configuration value.</param>
/// <returns>
/// The data type configuration.
/// </returns>
[Obsolete($"Use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
object? IDataTypeConfigurationConnector.FromArtifact(IDataType dataType, string? configuration)
=> FromArtifact(dataType, configuration, PassThroughCache.Instance);

/// <summary>
/// Gets the data type configuration corresponding to an artifact configuration value.
/// </summary>
/// <param name="dataType">The data type.</param>
/// <param name="configuration">The artifact configuration value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The data type configuration.
/// </returns>
object? FromArtifact(IDataType dataType, string? configuration, IContextCache contextCache);
}
30 changes: 4 additions & 26 deletions src/Umbraco.Core/Deploy/IServiceConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,18 @@ public interface IServiceConnector : IDiscoverable
/// <returns>
/// The corresponding artifact, or null.
/// </returns>
[Obsolete("Use the overload accepting IContextCache instead. This overload will be removed in a future version.")]
IArtifact? GetArtifact(Udi udi)
=> GetArtifact(udi, PassThroughCache.Instance);

/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="udi">The entity identifier of the artifact.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The corresponding artifact, or null.
/// </returns>
IArtifact? GetArtifact(Udi udi, IContextCache contextCache);

/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="entity">The entity.</param>
/// <returns>
/// The corresponding artifact.
/// </returns>
[Obsolete("Use the overload accepting IContextCache instead. This overload will be removed in a future version.")]
IArtifact GetArtifact(object entity)
=> GetArtifact(entity, PassThroughCache.Instance);
[Obsolete($"Implement {nameof(IServiceConnector2)} and use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
IArtifact? GetArtifact(Udi udi);

/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="entity">The entity.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The corresponding artifact.
/// </returns>
IArtifact GetArtifact(object entity, IContextCache contextCache);
[Obsolete($"Implement {nameof(IServiceConnector2)} and use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
IArtifact GetArtifact(object entity);

/// <summary>
/// Initializes processing for an artifact.
Expand Down
38 changes: 38 additions & 0 deletions src/Umbraco.Core/Deploy/IServiceConnector2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
namespace Umbraco.Cms.Core.Deploy;

/// <inheritdoc />
/// <remarks>
/// This interface will be merged back into <see cref="IServiceConnector" /> and removed in Umbraco 13.
/// </remarks>
public interface IServiceConnector2 : IServiceConnector
{
/// <inheritdoc />
[Obsolete($"Use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
IArtifact? IServiceConnector.GetArtifact(Udi udi)
=> GetArtifact(udi, PassThroughCache.Instance);

/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="udi">The entity identifier of the artifact.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The corresponding artifact, or null.
/// </returns>
IArtifact? GetArtifact(Udi udi, IContextCache contextCache);

/// <inheritdoc />
[Obsolete($"Use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
IArtifact IServiceConnector.GetArtifact(object entity)
=> GetArtifact(entity, PassThroughCache.Instance);

/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="entity">The entity.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The corresponding artifact.
/// </returns>
IArtifact GetArtifact(object entity, IContextCache contextCache);
}
34 changes: 4 additions & 30 deletions src/Umbraco.Core/Deploy/IValueConnector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,44 +29,18 @@ public interface IValueConnector
/// <returns>
/// The deploy property value.
/// </returns>
[Obsolete("Use the overload accepting IContextCache instead. This overload will be removed in a future version.")]
string? ToArtifact(object? value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
=> ToArtifact(value, propertyType, dependencies, PassThroughCache.Instance);

/// <summary>
/// Gets the deploy property value corresponding to a content property value, and gather dependencies.
/// </summary>
/// <param name="value">The content property value.</param>
/// <param name="propertyType">The value property type</param>
/// <param name="dependencies">The content dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The deploy property value.
/// </returns>
string? ToArtifact(object? value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache);

/// <summary>
/// Gets the content property value corresponding to a deploy property value.
/// </summary>
/// <param name="value">The deploy property value.</param>
/// <param name="propertyType">The value property type</param>
/// <param name="currentValue">The current content property value.</param>
/// <returns>
/// The content property value.
/// </returns>
[Obsolete("Use the overload accepting IContextCache instead. This overload will be removed in a future version.")]
object? FromArtifact(string? value, IPropertyType propertyType, object? currentValue)
=> FromArtifact(value, propertyType, currentValue, PassThroughCache.Instance);
[Obsolete($"Implement {nameof(IValueConnector2)} and use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
string? ToArtifact(object? value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies);

/// <summary>
/// Gets the content property value corresponding to a deploy property value.
/// </summary>
/// <param name="value">The deploy property value.</param>
/// <param name="propertyType">The value property type</param>
/// <param name="currentValue">The current content property value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The content property value.
/// </returns>
object? FromArtifact(string? value, IPropertyType propertyType, object? currentValue, IContextCache contextCache);
[Obsolete($"Implement {nameof(IValueConnector2)} and use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
object? FromArtifact(string? value, IPropertyType propertyType, object? currentValue);
}
44 changes: 44 additions & 0 deletions src/Umbraco.Core/Deploy/IValueConnector2.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Umbraco.Cms.Core.Models;

namespace Umbraco.Cms.Core.Deploy;

/// <inheritdoc />
/// <remarks>
/// This interface will be merged back into <see cref="IValueConnector" /> and removed in Umbraco 13.
/// </remarks>
public interface IValueConnector2 : IValueConnector
{
/// <inheritdoc />
[Obsolete($"Use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
string? IValueConnector.ToArtifact(object? value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies)
=> ToArtifact(value, propertyType, dependencies, PassThroughCache.Instance);

/// <summary>
/// Gets the deploy property value corresponding to a content property value, and gather dependencies.
/// </summary>
/// <param name="value">The content property value.</param>
/// <param name="propertyType">The value property type</param>
/// <param name="dependencies">The content dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The deploy property value.
/// </returns>
string? ToArtifact(object? value, IPropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache);

/// <inheritdoc />
[Obsolete($"Use the overload accepting {nameof(IContextCache)} instead. This overload will be removed in Umbraco 13.")]
object? IValueConnector.FromArtifact(string? value, IPropertyType propertyType, object? currentValue)
=> FromArtifact(value, propertyType, currentValue, PassThroughCache.Instance);

/// <summary>
/// Gets the content property value corresponding to a deploy property value.
/// </summary>
/// <param name="value">The deploy property value.</param>
/// <param name="propertyType">The value property type</param>
/// <param name="currentValue">The current content property value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The content property value.
/// </returns>
object? FromArtifact(string? value, IPropertyType propertyType, object? currentValue, IContextCache contextCache);
}
44 changes: 44 additions & 0 deletions src/Umbraco.Core/Deploy/ServiceConnectorExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
namespace Umbraco.Cms.Core.Deploy;

/// <summary>
/// Extension methods adding backwards-compatability between <see cref="IServiceConnector" /> and <see cref="IServiceConnector2" />.
/// </summary>
/// <remarks>
/// These extension methods will be removed in Umbraco 13.
/// </remarks>
public static class ServiceConnectorExtensions
{
/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="connector">The connector.</param>
/// <param name="udi">The entity identifier of the artifact.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The corresponding artifact, or null.
/// </returns>
/// <remarks>
/// This extension method tries to make use of the <see cref="IContextCache" /> on types also implementing <see cref="IServiceConnector2" />.
/// </remarks>
public static IArtifact? GetArtifact(this IServiceConnector connector, Udi udi, IContextCache contextCache)
=> connector is IServiceConnector2 connector2
? connector2.GetArtifact(udi, contextCache)
: connector.GetArtifact(udi);

/// <summary>
/// Gets an artifact.
/// </summary>
/// <param name="connector">The connector.</param>
/// <param name="entity">The entity.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>
/// The corresponding artifact.
/// </returns>
/// <remarks>
/// This extension method tries to make use of the <see cref="IContextCache" /> on types also implementing <see cref="IServiceConnector2" />.
/// </remarks>
public static IArtifact GetArtifact(this IServiceConnector connector, object entity, IContextCache contextCache)
=> connector is IServiceConnector2 connector2
? connector2.GetArtifact(entity, contextCache)
: connector.GetArtifact(entity);
}
Loading