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

Introduce methods on new service to have alternative to obsoleted methods #17208

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
16 changes: 16 additions & 0 deletions src/Umbraco.Core/Services/EntityTypeContainerService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.Extensions.Logging;

Check notice on line 1 in src/Umbraco.Core/Services/EntityTypeContainerService.cs

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (contrib)

ℹ Getting worse: Primitive Obsession

The ratio of primitive types in function arguments increases from 44.83% to 48.39%, threshold = 30.0%. The functions in this file have too many primitive types (e.g. int, double, float) in their function argument lists. Using many primitive types lead to the code smell Primitive Obsession. Avoid adding more primitive arguments.
using Umbraco.Cms.Core.Events;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.Entities;
Expand Down Expand Up @@ -50,6 +50,22 @@
return await Task.FromResult(_entityContainerRepository.Get(id));
}


/// <inheritdoc />
public async Task<IEnumerable<EntityContainer>> GetAsync(string name, int level)
{
using ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true);
ReadLock(scope);
return await Task.FromResult(_entityContainerRepository.Get(name, level));
}
/// <inheritdoc />
public async Task<IEnumerable<EntityContainer>> GetAllAsync()
{
using ICoreScope scope = ScopeProvider.CreateCoreScope(autoComplete: true);
ReadLock(scope);
return await Task.FromResult(_entityContainerRepository.GetMany());
}

/// <inheritdoc />
public async Task<EntityContainer?> GetParentAsync(EntityContainer container)
=> await Task.FromResult(GetParent(container));
Expand Down
14 changes: 14 additions & 0 deletions src/Umbraco.Core/Services/IEntityTypeContainerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ public interface IEntityTypeContainerService<TTreeEntity>
/// <returns></returns>
Task<EntityContainer?> GetAsync(Guid id);

/// <summary>
/// Gets containers by name and level
/// </summary>
/// <param name="name">The name of the containers to get.</param>
/// <param name="level">The level in the tree of the containers to get.</param>
/// <returns></returns>
Task<IEnumerable<EntityContainer>> GetAsync(string name, int level);

/// <summary>
/// Gets all containers
/// </summary>
/// <returns></returns>
Task<IEnumerable<EntityContainer>> GetAllAsync();

/// <summary>
/// Gets the parent container of a container
/// </summary>
Expand Down
Loading