-
Notifications
You must be signed in to change notification settings - Fork 319
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
Supporting Multiple TestProperty with the same key value. #328
Changes from 1 commit
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 |
---|---|---|
|
@@ -43,14 +43,29 @@ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo c | |
{ | ||
using (var stream = new MemoryStream(Encoding.Unicode.GetBytes(data))) | ||
{ | ||
var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(Dictionary<string, string>)); | ||
var dict = serializer.ReadObject(stream) as Dictionary<string, string>; | ||
List<KeyValuePair<string, string>> listOfKvps = new List<KeyValuePair<string, string>>(); | ||
|
||
return dict?.ToArray(); | ||
// Converting Json data to array of KeyValuePairs with duplicate keys. | ||
var serializer = new System.Runtime.Serialization.Json.DataContractJsonSerializer(typeof(List<TraitObject>)); | ||
|
||
var listOfTratiObjects = serializer.ReadObject(stream) as List<TraitObject>; | ||
listOfTratiObjects.ForEach(o=>listOfKvps.Add(new KeyValuePair<string, string>(o.Key, o.Value))); | ||
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. Extra allocation and insertion into
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. Yes possible. Changed it. |
||
|
||
return listOfKvps?.ToArray(); | ||
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. Why is null check required for 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. Removed. |
||
} | ||
} | ||
|
||
return base.ConvertFrom(context, culture, value); | ||
} | ||
|
||
[System.Runtime.Serialization.DataContract] | ||
private class TraitObject | ||
{ | ||
[System.Runtime.Serialization.DataMember(Name = "Key")] | ||
public string Key { get; set; } | ||
|
||
[System.Runtime.Serialization.DataMember(Name = "Value")] | ||
public string Value { get; set; } | ||
} | ||
} | ||
} |
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.
s/listOfTratiObjects/listOfTraitObjects
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.
Resolved it.