Move extension method classes into separate files
This commit is contained in:
@@ -63,10 +63,4 @@ namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
[DataMember(Name = "properties")]
|
||||
public IEnumerable<TPropertyType> Properties { get; set; }
|
||||
}
|
||||
|
||||
internal static class PropertyGroupBasicExtensions
|
||||
{
|
||||
public static string GetParentAlias(this PropertyGroupBasic propertyGroup)
|
||||
=> PropertyGroupExtensions.GetParentAlias(propertyGroup.Alias);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Umbraco.Cms.Core.Models.ContentEditing
|
||||
{
|
||||
internal static class PropertyGroupBasicExtensions
|
||||
{
|
||||
public static string GetParentAlias(this PropertyGroupBasic propertyGroup)
|
||||
=> PropertyGroupExtensions.GetParentAlias(propertyGroup.Alias);
|
||||
}
|
||||
}
|
||||
@@ -147,85 +147,4 @@ namespace Umbraco.Cms.Core.Models
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static class PropertyGroupExtensions
|
||||
{
|
||||
private const char aliasSeparator = '/';
|
||||
|
||||
internal static string GetLocalAlias(string alias)
|
||||
{
|
||||
var lastIndex = alias?.LastIndexOf(aliasSeparator) ?? -1;
|
||||
if (lastIndex != -1)
|
||||
{
|
||||
return alias.Substring(lastIndex + 1);
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
|
||||
internal static string GetParentAlias(string alias)
|
||||
{
|
||||
var lastIndex = alias?.LastIndexOf(aliasSeparator) ?? -1;
|
||||
if (lastIndex == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return alias.Substring(0, lastIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the local alias.
|
||||
/// </summary>
|
||||
/// <param name="propertyGroup">The property group.</param>
|
||||
/// <returns>
|
||||
/// The local alias.
|
||||
/// </returns>
|
||||
public static string GetLocalAlias(this PropertyGroup propertyGroup) => GetLocalAlias(propertyGroup.Alias);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the local alias.
|
||||
/// </summary>
|
||||
/// <param name="propertyGroup">The property group.</param>
|
||||
/// <param name="localAlias">The local alias.</param>
|
||||
public static void UpdateLocalAlias(this PropertyGroup propertyGroup, string localAlias)
|
||||
{
|
||||
var parentAlias = propertyGroup.GetParentAlias();
|
||||
if (string.IsNullOrEmpty(parentAlias))
|
||||
{
|
||||
propertyGroup.Alias = localAlias;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyGroup.Alias = parentAlias + aliasSeparator + localAlias;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent alias.
|
||||
/// </summary>
|
||||
/// <param name="propertyGroup">The property group.</param>
|
||||
/// <returns>
|
||||
/// The parent alias.
|
||||
/// </returns>
|
||||
public static string GetParentAlias(this PropertyGroup propertyGroup) => GetParentAlias(propertyGroup.Alias);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the parent alias.
|
||||
/// </summary>
|
||||
/// <param name="propertyGroup">The property group.</param>
|
||||
/// <param name="parentAlias">The parent alias.</param>
|
||||
public static void UpdateParentAlias(this PropertyGroup propertyGroup, string parentAlias)
|
||||
{
|
||||
var localAlias = propertyGroup.GetLocalAlias();
|
||||
if (string.IsNullOrEmpty(parentAlias))
|
||||
{
|
||||
propertyGroup.Alias = localAlias;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyGroup.Alias = parentAlias + aliasSeparator + localAlias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
83
src/Umbraco.Core/Models/PropertyGroupExtensions.cs
Normal file
83
src/Umbraco.Core/Models/PropertyGroupExtensions.cs
Normal file
@@ -0,0 +1,83 @@
|
||||
namespace Umbraco.Cms.Core.Models
|
||||
{
|
||||
public static class PropertyGroupExtensions
|
||||
{
|
||||
private const char AliasSeparator = '/';
|
||||
|
||||
internal static string GetLocalAlias(string alias)
|
||||
{
|
||||
var lastIndex = alias?.LastIndexOf(AliasSeparator) ?? -1;
|
||||
if (lastIndex != -1)
|
||||
{
|
||||
return alias.Substring(lastIndex + 1);
|
||||
}
|
||||
|
||||
return alias;
|
||||
}
|
||||
|
||||
internal static string GetParentAlias(string alias)
|
||||
{
|
||||
var lastIndex = alias?.LastIndexOf(AliasSeparator) ?? -1;
|
||||
if (lastIndex == -1)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return alias.Substring(0, lastIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the local alias.
|
||||
/// </summary>
|
||||
/// <param name="propertyGroup">The property group.</param>
|
||||
/// <returns>
|
||||
/// The local alias.
|
||||
/// </returns>
|
||||
public static string GetLocalAlias(this PropertyGroup propertyGroup) => GetLocalAlias(propertyGroup.Alias);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the local alias.
|
||||
/// </summary>
|
||||
/// <param name="propertyGroup">The property group.</param>
|
||||
/// <param name="localAlias">The local alias.</param>
|
||||
public static void UpdateLocalAlias(this PropertyGroup propertyGroup, string localAlias)
|
||||
{
|
||||
var parentAlias = propertyGroup.GetParentAlias();
|
||||
if (string.IsNullOrEmpty(parentAlias))
|
||||
{
|
||||
propertyGroup.Alias = localAlias;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyGroup.Alias = parentAlias + AliasSeparator + localAlias;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent alias.
|
||||
/// </summary>
|
||||
/// <param name="propertyGroup">The property group.</param>
|
||||
/// <returns>
|
||||
/// The parent alias.
|
||||
/// </returns>
|
||||
public static string GetParentAlias(this PropertyGroup propertyGroup) => GetParentAlias(propertyGroup.Alias);
|
||||
|
||||
/// <summary>
|
||||
/// Updates the parent alias.
|
||||
/// </summary>
|
||||
/// <param name="propertyGroup">The property group.</param>
|
||||
/// <param name="parentAlias">The parent alias.</param>
|
||||
public static void UpdateParentAlias(this PropertyGroup propertyGroup, string parentAlias)
|
||||
{
|
||||
var localAlias = propertyGroup.GetLocalAlias();
|
||||
if (string.IsNullOrEmpty(parentAlias))
|
||||
{
|
||||
propertyGroup.Alias = localAlias;
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyGroup.Alias = parentAlias + AliasSeparator + localAlias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user