Skip to content

Commit 6413421

Browse files
Add additional caching using IContextCache (#59)
* Fix missing cached entity key lookup * Use throw expressions in constructors * Remove non-existent Umbraco.BlockEditor alias
1 parent 8ab65d0 commit 6413421

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

src/Umbraco.Deploy.Contrib.Connectors/GridCellValueConnectors/DocTypeGridEditorCellValueConnector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class DocTypeGridEditorCellValueConnector : GridCellValueConnectorBase2
2525

2626
public DocTypeGridEditorCellValueConnector(ILogger logger, IContentTypeService contentTypeService, Lazy<ValueConnectorCollection> valueConnectors)
2727
{
28-
_logger = logger;
28+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
2929
_contentTypeService = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService));
3030
_valueConnectorsLazy = valueConnectors ?? throw new ArgumentNullException(nameof(valueConnectors));
3131
}

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/BlockEditorValueConnector.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,17 @@ public abstract class BlockEditorValueConnector : ValueConnectorBase
2626
private readonly ILogger _logger;
2727

2828
/// <inheritdoc />
29-
public override IEnumerable<string> PropertyEditorAliases { get; } = new[]
30-
{
31-
"Umbraco.BlockEditor"
32-
};
29+
public override IEnumerable<string> PropertyEditorAliases { get; } = Enumerable.Empty<string>();
3330

3431
// cannot inject ValueConnectorCollection directly as it would cause a circular (recursive) dependency,
3532
// so we have to inject it lazily and use the lazy value when actually needing it
3633
private ValueConnectorCollection ValueConnectors => _valueConnectorsLazy.Value;
3734

3835
public BlockEditorValueConnector(IContentTypeService contentTypeService, Lazy<ValueConnectorCollection> valueConnectors, ILogger logger)
3936
{
40-
if (contentTypeService == null) throw new ArgumentNullException(nameof(contentTypeService));
41-
if (valueConnectors == null) throw new ArgumentNullException(nameof(valueConnectors));
42-
if (logger == null) throw new ArgumentNullException(nameof(logger));
43-
_contentTypeService = contentTypeService;
44-
_valueConnectorsLazy = valueConnectors;
45-
_logger = logger;
37+
_contentTypeService = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService));
38+
_valueConnectorsLazy = valueConnectors ?? throw new ArgumentNullException(nameof(valueConnectors));
39+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
4640
}
4741

4842
public override string ToArtifact(object value, PropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/BlockListValueConnector.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ namespace Umbraco.Deploy.Contrib.Connectors.ValueConnectors
1111
/// </summary>
1212
public class BlockListValueConnector : BlockEditorValueConnector
1313
{
14-
public override IEnumerable<string> PropertyEditorAliases => new[] { "Umbraco.BlockList" };
14+
public override IEnumerable<string> PropertyEditorAliases { get; } = new[]
15+
{
16+
"Umbraco.BlockList"
17+
};
1518

1619
public BlockListValueConnector(IContentTypeService contentTypeService, Lazy<ValueConnectorCollection> valueConnectors, ILogger logger)
1720
: base(contentTypeService, valueConnectors, logger)

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/MultiUrlPickerValueConnector.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ public class MultiUrlPickerValueConnector : ValueConnectorBase
5050
/// <param name="logger"></param>
5151
public MultiUrlPickerValueConnector(IEntityService entityService, IMediaService mediaService, ILogger logger)
5252
{
53-
if (entityService == null) throw new ArgumentNullException(nameof(entityService));
54-
if (mediaService == null) throw new ArgumentNullException(nameof(mediaService));
55-
_entityService = entityService;
56-
_mediaService = mediaService;
57-
_logger = logger;
53+
_entityService = entityService ?? throw new ArgumentNullException(nameof(entityService));
54+
_mediaService = mediaService ?? throw new ArgumentNullException(nameof(mediaService));
55+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
5856
}
5957

6058
public sealed override string ToArtifact(object value, PropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)
@@ -85,7 +83,7 @@ public sealed override string ToArtifact(object value, PropertyType propertyType
8583
: UmbracoObjectTypes.Document;
8684
var entityType = isMedia ? Constants.UdiEntityType.Media : Constants.UdiEntityType.Document;
8785

88-
var guidAttempt = _entityService.GetKey(intId, objectTypeId);
86+
var guidAttempt = contextCache.GetEntityKeyById(_entityService, intId, objectTypeId);
8987
if (guidAttempt.Success == false)
9088
continue;
9189

src/Umbraco.Deploy.Contrib.Connectors/ValueConnectors/NestedContentValueConnector.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,9 @@ public class NestedContentValueConnector : ValueConnectorBase
4141

4242
public NestedContentValueConnector(IContentTypeService contentTypeService, Lazy<ValueConnectorCollection> valueConnectors, ILogger logger)
4343
{
44-
if (contentTypeService == null) throw new ArgumentNullException(nameof(contentTypeService));
45-
if (valueConnectors == null) throw new ArgumentNullException(nameof(valueConnectors));
46-
if (logger == null) throw new ArgumentNullException(nameof(logger));
47-
_contentTypeService = contentTypeService;
48-
_valueConnectorsLazy = valueConnectors;
49-
_logger = logger;
44+
_contentTypeService = contentTypeService ?? throw new ArgumentNullException(nameof(contentTypeService));
45+
_valueConnectorsLazy = valueConnectors ?? throw new ArgumentNullException(nameof(valueConnectors));
46+
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
5047
}
5148

5249
public sealed override string ToArtifact(object value, PropertyType propertyType, ICollection<ArtifactDependency> dependencies, IContextCache contextCache)

0 commit comments

Comments
 (0)