diff --git a/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeViewModel.cs b/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeViewModel.cs index 6df0449c36c..109699a581d 100644 --- a/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeViewModel.cs +++ b/src/OrchardCore/OrchardCore.DisplayManagement/Views/ShapeViewModel.cs @@ -16,24 +16,18 @@ public ShapeViewModel() public ShapeViewModel(string shapeType) { - if (string.IsNullOrEmpty(shapeType)) - { - throw new ArgumentException($"The {nameof(shapeType)} cannot be empty"); - } + ArgumentException.ThrowIfNullOrEmpty(shapeType, nameof(shapeType)); Metadata.Type = shapeType; } private ShapeMetadata _metadata; + public ShapeMetadata Metadata => _metadata ??= new ShapeMetadata(); public string Position { - get - { - return Metadata.Position; - } - + get => Metadata.Position; set { Metadata.Position = value; @@ -41,25 +35,30 @@ public string Position } public string Id { get; set; } + public string TagName { get; set; } private List _classes; - public IList Classes => _classes ??= new List(); + + public IList Classes => _classes ??= []; private Dictionary _attributes; - public IDictionary Attributes => _attributes ??= new Dictionary(); + + public IDictionary Attributes => _attributes ??= []; private Dictionary _properties; - public IDictionary Properties => _properties ??= new Dictionary(); + + public IDictionary Properties => _properties ??= []; private bool _sorted = false; private List _items; + public IReadOnlyList Items { get { - _items ??= new List(); + _items ??= []; if (!_sorted) { @@ -78,8 +77,9 @@ public ValueTask AddAsync(object item, string position) return new ValueTask(this); } - position ??= ""; + position ??= string.Empty; _sorted = false; + _items ??= []; if (item is IHtmlContent) { @@ -91,8 +91,7 @@ public ValueTask AddAsync(object item, string position) } else { - var shape = item as IPositioned; - if (shape != null) + if (item is IPositioned shape) { if (position != null) {