-
Couldn't load subscription status.
- Fork 489
Fix SIPParameters.ToString() #1470
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -14,6 +14,7 @@ | |||||
| //----------------------------------------------------------------------------- | ||||||
|
|
||||||
| using System; | ||||||
| using System.Collections.Concurrent; | ||||||
| using System.Collections.Generic; | ||||||
| using System.Linq; | ||||||
| using System.Net; | ||||||
|
|
@@ -55,7 +56,7 @@ public class SIPParameters | |||||
| public char TagDelimiter = DEFAULT_PARAMETER_DELIMITER; | ||||||
|
|
||||||
| //[DataMember] | ||||||
| private Dictionary<string, string> m_dictionary; | ||||||
| private ConcurrentDictionary<string, string> m_dictionary; | ||||||
|
|
||||||
| [IgnoreDataMember] | ||||||
| public int Count | ||||||
|
|
@@ -65,7 +66,7 @@ public int Count | |||||
|
|
||||||
| internal SIPParameters() | ||||||
| { | ||||||
| m_dictionary = new Dictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); | ||||||
| m_dictionary = new ConcurrentDictionary<string, string>(StringComparer.InvariantCultureIgnoreCase); | ||||||
| } | ||||||
|
|
||||||
| /// <summary> | ||||||
|
|
@@ -186,7 +187,7 @@ public static string[] GetKeyValuePairsFromQuoted(string quotedString, char deli | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| private void AddKeyValuePair(string keyValuePair, Dictionary<string, string> dictionary) | ||||||
| private void AddKeyValuePair(string keyValuePair, ConcurrentDictionary<string, string> dictionary) | ||||||
| { | ||||||
| if (keyValuePair != null && keyValuePair.Trim().Length > 0) | ||||||
| { | ||||||
|
|
@@ -198,15 +199,15 @@ private void AddKeyValuePair(string keyValuePair, Dictionary<string, string> dic | |||||
| // If this is not the parameter that is being removed put it back on. | ||||||
| if (!dictionary.ContainsKey(keyName)) | ||||||
| { | ||||||
| dictionary.Add(keyName, keyValuePair.Substring(seperatorPosn + 1).Trim()); | ||||||
| dictionary.TryAdd(keyName, keyValuePair.Substring(seperatorPosn + 1).Trim()); | ||||||
| } | ||||||
| } | ||||||
| else | ||||||
| { | ||||||
| // Keys with no values are valid in SIP so they get added to the collection with a null value. | ||||||
| if (!dictionary.ContainsKey(keyValuePair)) | ||||||
| { | ||||||
| dictionary.Add(keyValuePair, null); | ||||||
| dictionary.TryAdd(keyValuePair, null); | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -220,7 +221,7 @@ public void Set(string name, string value) | |||||
| } | ||||||
| else | ||||||
| { | ||||||
| m_dictionary.Add(name, value); | ||||||
| m_dictionary.TryAdd(name, value); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
|
|
@@ -259,13 +260,13 @@ public void Remove(string name) | |||||
| { | ||||||
| if (name != null) | ||||||
| { | ||||||
| m_dictionary.Remove(name); | ||||||
| m_dictionary.TryRemove(name, out string ignore); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| public void RemoveAll() | ||||||
| { | ||||||
| m_dictionary = new Dictionary<string, string>(); | ||||||
| m_dictionary = new ConcurrentDictionary<string, string>(); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of instantiating a new instance keep the existing one and clear it:
Suggested change
|
||||||
| } | ||||||
|
|
||||||
| public string[] GetKeys() | ||||||
|
|
@@ -318,7 +319,7 @@ public SIPParameters CopyOf() | |||||
| { | ||||||
| SIPParameters copy = new SIPParameters(); | ||||||
| copy.TagDelimiter = this.TagDelimiter; | ||||||
| copy.m_dictionary = (this.m_dictionary != null) ? new Dictionary<string, string>(this.m_dictionary) : new Dictionary<string, string>(); | ||||||
| copy.m_dictionary = (this.m_dictionary != null) ? new ConcurrentDictionary<string, string>(this.m_dictionary) : new ConcurrentDictionary<string, string>(); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| return copy; | ||||||
| } | ||||||
|
|
||||||
|
|
||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the other comments,
m_dictionarycan be read-only: