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

Trying to fix Issue #775 #808

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
23 changes: 23 additions & 0 deletions src/Common/Helpers/ExtensionMethods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ServiceBusExplorer.Common.Helpers
{
public static class ExtensionMethods
{
/// <summary>
/// this exthension method is used to get the string value from the dictionary
/// if the value is null or empty then it will return null
/// </summary>
/// <param name="propertyValue"></param>
/// <param name="propertyName"></param>
/// <returns></returns>
Comment on lines +11 to +17
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// <summary>
/// this exthension method is used to get the string value from the dictionary
/// if the value is null or empty then it will return null
/// </summary>
/// <param name="propertyValue"></param>
/// <param name="propertyName"></param>
/// <returns></returns>
/// <summary>
/// Get the string value from the dictionary. Return null when the value is null or empty.
/// </summary>

public static string? GetNullableStringValue(this Dictionary<string, object> propertyValue, string propertyName)
{
return !string.IsNullOrWhiteSpace(propertyValue[propertyName] as string) ? propertyValue[propertyName] as string : null;
}
}
}
17 changes: 9 additions & 8 deletions src/Common/Helpers/ImportExportHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
using ServiceBusExplorer.Utilities.Helpers;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using ServiceBusExplorer.Common.Helpers;

#endregion

Expand Down Expand Up @@ -1357,14 +1358,14 @@ private Filter CreateFilter(XElement filter)
{
ruleFilter = new CorrelationFilter()
{
ContentType = !string.IsNullOrWhiteSpace(propertyValue[ContentType] as string) ? propertyValue[ContentType] as string : null,
CorrelationId = !string.IsNullOrWhiteSpace(propertyValue[CorrelationId] as string) ? propertyValue[CorrelationId] as string : null,
Label = !string.IsNullOrWhiteSpace(propertyValue[Label] as string) ? propertyValue[Label] as string : null,
MessageId = !string.IsNullOrWhiteSpace(propertyValue[MessageId] as string) ? propertyValue[MessageId] as string : null,
To = !string.IsNullOrWhiteSpace(propertyValue[To] as string) ? propertyValue[To] as string : null,
ReplyTo = !string.IsNullOrWhiteSpace(propertyValue[ReplyTo] as string) ? propertyValue[ReplyTo] as string : null,
ReplyToSessionId = !string.IsNullOrWhiteSpace(propertyValue[ReplyToSessionId] as string) ? propertyValue[ReplyToSessionId] as string : null,
SessionId = !string.IsNullOrWhiteSpace(propertyValue[SessionId] as string) ? propertyValue[SessionId] as string : null,
ContentType = propertyValue.GetNullableStringValue(ContentType),
CorrelationId = propertyValue.GetNullableStringValue(CorrelationId),
Label = propertyValue.GetNullableStringValue(Label),
MessageId = propertyValue.GetNullableStringValue(MessageId),
To = propertyValue.GetNullableStringValue(To),
ReplyTo = propertyValue.GetNullableStringValue(ReplyTo),
ReplyToSessionId = propertyValue.GetNullableStringValue(ReplyToSessionId),
SessionId = propertyValue.GetNullableStringValue(SessionId),
};
}
if (ruleFilter != null)
Expand Down