Skip to content

Commit

Permalink
Misc optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Sep 28, 2024
1 parent 77f30dd commit 35e6604
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static class TypedGridExtensionMethods {

/// <summary>
/// Returns a <see cref="GridDataModel"/> instance representing the value of the property with the specified
/// <paramref name="propertyAlias"/>. If the property doesn't exist or it's value doesn't match a
/// <paramref name="propertyAlias"/>. If the property doesn't exist, or it's value doesn't match a
/// <see cref="GridDataModel"/> instance, a <see cref="GridDataModel"/> instance representing an empty grid
/// model is returned instead.
/// </summary>
Expand All @@ -34,7 +34,7 @@ public static GridDataModel GetGridModel(this IPublishedContent? content, string

/// <summary>
/// Returns a <see cref="GridDataModel"/> instance representing the value of the property with the specified
/// <paramref name="propertyAlias"/>. If the property doesn't exist or it's value doesn't match a
/// <paramref name="propertyAlias"/>. If the property doesn't exist, or it's value doesn't match a
/// <see cref="GridDataModel"/> instance, <see langword="null"/> is returned instead.
/// </summary>
/// <param name="content">The parent content item.</param>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class GridManifestFilter : IManifestFilter {
public void Filter(List<PackageManifest> manifests) {
manifests.Add(new PackageManifest {
AllowPackageTelemetry = true,
PackageId = GridPackage.Alias,
PackageName = GridPackage.Name,
Version = GridPackage.InformationalVersion
});
Expand Down
2 changes: 1 addition & 1 deletion src/Skybrud.Umbraco.GridData/Models/GridArea.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public GridArea(JObject json, GridRow row, IGridFactory factory) : base(json) {
Grid = json.GetInt32("grid");
AllowAll = json.GetBoolean("allowAll");
Allowed = json.GetStringArray("allowed");
Controls = json.GetArray("controls", x => factory.CreateGridControl(x, this)) ?? Array.Empty<GridControl>();
Controls = json.GetArray("controls", x => factory.CreateGridControl(x, this)) ?? [];

// Update "PreviousControl" and "NextControl" properties
for (int i = 1; i < Controls.Count; i++) {
Expand Down
4 changes: 2 additions & 2 deletions src/Skybrud.Umbraco.GridData/Models/GridControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ internal GridControl(GridControl control) : base(control.JObject) {
#region Member methods

/// <summary>
/// Returns the value of the control casted to the type of <typeparamref name="T"/>.
/// Returns the value of the control cast to the type of <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of the value to be returned.</typeparam>
public T? GetValue<T>() where T : IGridControlValue {
Expand All @@ -111,7 +111,7 @@ public void WriteSearchableText(GridContext context, TextWriter writer) {
}

/// <summary>
/// Returns the value of the control as a searchable text - eg. to be used in Examine.
/// Returns the value of the control as a searchable text - e.g. to be used in Examine.
/// </summary>
/// <param name="context">The current grid context.</param>
/// <returns>An instance of <see cref="string"/> with the value as a searchable text.</returns>
Expand Down
6 changes: 3 additions & 3 deletions src/Skybrud.Umbraco.GridData/Models/GridDataModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ public bool IsValid {
Name = json.GetString("name")!;

if (factory is null) {
Sections = Array.Empty<GridSection>();
Sections = [];
} else {
Sections = json.GetArray("sections", x => factory.CreateGridSection(x, this)) ?? Array.Empty<GridSection>();
Sections = json.GetArray("sections", x => factory.CreateGridSection(x, this)) ?? [];
}

}
Expand Down Expand Up @@ -138,7 +138,7 @@ public void WriteSearchableText(GridContext context, TextWriter writer) {
}

/// <summary>
/// Returns a textual representation of the grid model - eg. to be used in Examine.
/// Returns a textual representation of the grid model - e.g. to be used in Examine.
/// </summary>
/// <param name="context">The current grid context.</param>
/// <returns>An instance of <see cref="string"/> representing the value of the element.</returns>
Expand Down
4 changes: 2 additions & 2 deletions src/Skybrud.Umbraco.GridData/Models/GridDictionary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ public class GridDictionary : GridJsonObject, IEnumerable<GridDictionaryItem> {
/// Gets the keys of the underlying dictionary.
/// </summary>
[JsonIgnore]
public string[] Keys => _dictionary.Keys.ToArray();
public string[] Keys => [.. _dictionary.Keys];

/// <summary>
/// Gets the keys of the underlying dictionary.
/// </summary>
[JsonIgnore]
public string[] Values => _dictionary.Keys.ToArray();
public string[] Values => [.. _dictionary.Keys];

/// <summary>
/// Gets the amount of items in the dictionary.
Expand Down
2 changes: 1 addition & 1 deletion src/Skybrud.Umbraco.GridData/Models/GridEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public GridEditor(GridEditor editor) : base(editor.JObject) {
#region Member methods

/// <summary>
/// Returns the config of the editor casted to the type of <typeparamref name="T"/>.
/// Returns the config of the editor cast to the type of <typeparamref name="T"/>.
/// </summary>
/// <typeparam name="T">The type of the config to be returned.</typeparam>
public T? GetConfig<T>() where T : IGridEditorConfig {
Expand Down
2 changes: 1 addition & 1 deletion src/Skybrud.Umbraco.GridData/Models/GridElement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ protected GridElement(JObject json) : base(json) {
public abstract void WriteSearchableText(GridContext context, TextWriter writer);

/// <summary>
/// Gets a textual representation of the element - eg. to be used in Examine.
/// Gets a textual representation of the element - e.g. to be used in Examine.
/// </summary>
/// <param name="context">The current grid context.</param>
/// <returns>An instance of <see cref="string"/> representing the value of the element.</returns>
Expand Down
2 changes: 1 addition & 1 deletion src/Skybrud.Umbraco.GridData/Models/GridRow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public GridRow(JObject json, GridSection section, IGridFactory factory) : base(j
Label = json.GetString("label");
Name = json.GetString("name")!;

Areas = json.GetArray("areas", x => factory.CreateGridArea(x, this)) ?? Array.Empty<GridArea>();
Areas = json.GetArray("areas", x => factory.CreateGridArea(x, this)) ?? [];

// Update "PreviousArea" and "NextArea" properties
for (int i = 1; i < Areas.Count; i++) {
Expand Down
7 changes: 3 additions & 4 deletions src/Skybrud.Umbraco.GridData/Models/GridSection.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
Expand Down Expand Up @@ -66,7 +65,7 @@ public GridSection(JObject json, GridDataModel grid, IGridFactory factory) : bas
Model = grid;
Grid = json.GetInt32("grid");
Name = grid.Name;
Rows = json.GetArray("rows", x => factory.CreateGridRow(x, this)) ?? Array.Empty<GridRow>();
Rows = json.GetArray("rows", x => factory.CreateGridRow(x, this)) ?? [];

// Update "PreviousRow" and "NextRow" properties
for (int i = 1; i < Rows.Count; i++) {
Expand All @@ -90,7 +89,7 @@ public void WriteSearchableText(GridContext context, TextWriter writer) {
}

/// <summary>
/// Returns a textual representation of the section - eg. to be used in Examine.
/// Returns a textual representation of the section - e.g. to be used in Examine.
/// </summary>
/// <param name="context">The current grid context.</param>
/// <returns>An instance of <see cref="string"/> representing the value of the element.</returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public override string ToString() {
}

/// <summary>
/// Gets a HTML representing the value of the control.
/// Gets an HTML representing the value of the control.
/// </summary>
/// <returns>An instance of <see cref="string"/>.</returns>
public string ToHtmlString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class GridControlMediaFocalPoint : GridJsonObject {
/// <summary>
/// Initializes a new instance based on the specified <paramref name="json"/>.
/// </summary>
/// <param name="json">An instance of <see cref="JObject"/> representing the the focal point.</param>
/// <param name="json">An instance of <see cref="JObject"/> representing the focal point.</param>
protected GridControlMediaFocalPoint(JObject json) : base(json) {
Left = json.GetFloat("left");
Top = json.GetFloat("top");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public abstract class GridControlValueBase : IGridControlValue {
public GridControl Control { get; }

/// <summary>
/// Gets whether the control is valid (eg. whether it has a value).
/// Gets whether the control is valid (e.g. whether it has a value).
/// </summary>
[JsonIgnore]
public virtual bool IsValid => true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public interface IGridControlValue {
void WriteSearchableText(GridContext context, TextWriter writer);

/// <summary>
/// Gets the value of the control as a searchable text - eg. to be used in Examine.
/// Gets the value of the control as a searchable text - e.g. to be used in Examine.
/// </summary>
/// <param name="context">The current grid context.</param>
/// <returns>An instance of <see cref="string"/> with the value as a searchable text.</returns>
Expand Down

0 comments on commit 35e6604

Please sign in to comment.