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

Conversation

NaorisKong
Copy link

fix #775
Trying to fix the Topic import bug.
Added const string of correlation filter name.
Added CorrelationFilter initialization logic in CreateFilter function.

trying to fix the Topic import bug
ruleFilter = new CorrelationFilter(propertyValue[CorrelationId] as string);
ruleFilter = new CorrelationFilter()
{
ContentType = !string.IsNullOrWhiteSpace(propertyValue[ContentType] as string) ? propertyValue[ContentType] as string : null,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Question: is it necessary to use ternary condition if it's either a value or a null? Could this (one example) be it?

ContentType = propertyValue[ContentType] as string,

Copy link
Author

@NaorisKong NaorisKong Nov 8, 2024

Choose a reason for hiding this comment

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

If use the code
ContentType = propertyValue[ContentType] as string
May cause the exception "Exception: The argument contentType is null or white space."
Because when the xml be like this <ContentType></ContentType>, use propertyValue[ContentType] will get a empty string and I guess the construction function of CorrelationFilter can`t accept a empty string.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Indeed. This is to avoid empty string. Thank you for elaboration. In that case, could you make it a local function and pass the property name? On the local function you could put XML documentation or a comment elaborating the rationale. Thank you.

Copy link
Author

Choose a reason for hiding this comment

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

Ok, I will try to create a function to deal with it and add some comments.

Copy link
Author

Choose a reason for hiding this comment

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

Added a extension method on Dictionary<string, object>.Think it`s cleaner.

Copy link
Collaborator

@SeanFeldman SeanFeldman left a comment

Choose a reason for hiding this comment

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

Let's sort out that summary. Otherwise, looks good and can be merged 👍

Comment on lines +11 to +17
/// <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>
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>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Export/Import of topic
2 participants