in src/NMS.AMQP/Util/PropertyUtil.cs [202:287]
public static StringDictionary Merge(
StringDictionary one,
StringDictionary other,
out StringDictionary cross,
string onePrefix = PROPERTY_PREFIX,
string otherPrefix = PROPERTY_PREFIX,
string mergePrefix = PROPERTY_PREFIX
)
{
if (one == null && other != null)
{
cross = null;
return Clone(other);
}
else if (one!=null && other == null)
{
cross = null;
return Clone(one);
}
else if (one == null && other == null)
{
cross = null;
return new StringDictionary();
}
StringDictionary result = new StringDictionary();
StringDictionary dups = new StringDictionary();
Array arr = new string[other.Keys.Count];
other.Keys.CopyTo(arr, 0);
ArrayList otherKeys = new ArrayList(arr);
string mPre = mergePrefix +
(
mergePrefix.Length > 0 && !mergePrefix.EndsWith(PROPERTY_TERM_SEPARATOR)
?
PROPERTY_TERM_SEPARATOR
:
""
);
mergePrefix.ToLower();
string onePre = onePrefix +
(
onePrefix.Length > 0 && !onePrefix.EndsWith(PROPERTY_TERM_SEPARATOR)
?
PROPERTY_TERM_SEPARATOR
:
""
);
onePre.ToLower();
string otherPre = otherPrefix +
(
otherPrefix.Length > 0 && !otherPrefix.EndsWith(PROPERTY_TERM_SEPARATOR)
?
PROPERTY_TERM_SEPARATOR
:
""
);
otherPre.ToLower();
foreach (string rawkey in one.Keys)
{
string key = RemovePrefix(onePre, rawkey);
string otherkey = (otherPre + key).ToLower();
string mergekey = (mPre + key).ToLower();
if (!result.ContainsKey(mergekey))
{
result.Add(mergekey, one[rawkey]);
}
if (other.ContainsKey(otherkey))
{
otherKeys.Remove(otherkey);
dups.Add(mergekey, other[otherkey]);
}
}
foreach (string rawkey in otherKeys)
{
string key = RemovePrefix(otherPre, rawkey);
result.Add(mPre + key, other[rawkey]);
}
cross = dups.Count == 0 ? null : dups;
return result;
}