Skip to content

Commit

Permalink
Bah
Browse files Browse the repository at this point in the history
  • Loading branch information
abjerner committed Feb 10, 2023
1 parent 76c6b10 commit 5eb7472
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Skybrud.Essentials.Umbraco/PublishedElementExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public static class PublishedElementExtensions {
#region Boolean

/// <summary>
/// Returns the boolean value of the property with the specified <paramref name="alias"/>, or <see langwird="false"/> if a matching property could not be found or it's value converted to a <see cref="bool"/> instance.
/// Returns the boolean value of the property with the specified <paramref name="alias"/>, or <see langword="false"/> if a matching property could not be found or it's value converted to a <see cref="bool"/> instance.
/// </summary>
/// <param name="element">The element holding the property.</param>
/// <param name="alias">The alias of the property.</param>
Expand Down Expand Up @@ -52,12 +52,15 @@ public static bool GetBoolean(this IPublishedElement element, string alias) {
/// <param name="result">When this method returns, holds the <see cref="bool"/> value if successful; otherwise, <see langword="false"/>.</param>
/// <returns><see langword="true"/> if successful; otherwise, <see langword="false"/>.</returns>
public static bool TryGetBoolean(this IPublishedElement? element, string alias, out bool result) {
if (element.TryGetBoolean(alias, out bool? guid)) {
result = guid.Value;

if (element.TryGetBoolean(alias, out bool? temp)) {
result = temp.Value;
return true;
}

result = default;
return false;

}

/// <summary>
Expand Down Expand Up @@ -117,8 +120,8 @@ public static int GetInt32(this IPublishedElement element, string alias) {
/// <returns><see langword="true"/> if successful; otherwise, <see langword="false"/>.</returns>
public static bool TryGetInt32(this IPublishedElement? element, string alias, out int result) {

if (element.TryGetInt32(alias, out int? guid)) {
result = guid.Value;
if (element.TryGetInt32(alias, out int? temp)) {
result = temp.Value;
return true;
}

Expand Down Expand Up @@ -169,7 +172,7 @@ public static long GetInt64(this IPublishedElement element, string alias) {
public static long? GetInt64OrNull(this IPublishedElement? element, string alias) {
return element?.Value(alias) switch {
bool boolean => boolean ? 1 : 0,
int number => number,
long number => number,
string str => StringUtils.ParseInt64OrNull(str),
_ => null
};
Expand All @@ -184,8 +187,8 @@ public static long GetInt64(this IPublishedElement element, string alias) {
/// <returns><see langword="true"/> if successful; otherwise, <see langword="false"/>.</returns>
public static bool TryGetInt64(this IPublishedElement? element, string alias, out long result) {

if (element.TryGetInt64(alias, out long? guid)) {
result = guid.Value;
if (element.TryGetInt64(alias, out long? temp)) {
result = temp.Value;
return true;
}

Expand Down Expand Up @@ -251,8 +254,8 @@ public static float GetFloat(this IPublishedElement element, string alias) {
/// <returns><see langword="true"/> if successful; otherwise, <see langword="false"/>.</returns>
public static bool TryGetFloat(this IPublishedElement? element, string alias, out float result) {

if (element.TryGetFloat(alias, out float? guid)) {
result = guid.Value;
if (element.TryGetFloat(alias, out float? temp)) {
result = temp.Value;
return true;
}

Expand Down Expand Up @@ -318,8 +321,8 @@ public static double GetDouble(this IPublishedElement element, string alias) {
/// <returns><see langword="true"/> if successful; otherwise, <see langword="false"/>.</returns>
public static bool TryGetDouble(this IPublishedElement? element, string alias, out double result) {

if (element.TryGetDouble(alias, out double? guid)) {
result = guid.Value;
if (element.TryGetDouble(alias, out double? temp)) {
result = temp.Value;
return true;
}

Expand Down

0 comments on commit 5eb7472

Please sign in to comment.