I am trying to save a collection of objects based on their URI:
public class ConceptCollection : KeyedCollection<Uri, Concept> {
protected override Uri GetKeyForItem(Concept item) {
return item.Uri;
}
}
However, the URI is regularly differentiated only based on the Uri fragment. Thus, the following causes the error:
ConceptCollection wines = new ConceptCollection();
Concept red = new Concept("http://www.w3.org/2002/07/owl#RedWine");
Concept white = new Concept("http://www.w3.org/2002/07/owl#WhiteWine");
wines.Add(red);
wines.Add(white);
Per http://msdn.microsoft.com/en-us/library/f83xtf15.aspx :
The Equals method compares two instances without user information (UserInfo) and the fragment (Fragments) that they might contain. For example, given the URI http://www.contoso.com/index.htm#search as well as http: // user: password@www.contoso.com /index.htm , the Equals method will return true.
I put up with the need to crack it. But why does he act like that? I see the logic for user-info, but not for the fragment.