summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenId/Yadis/UriElement.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenId/Yadis/UriElement.cs')
-rw-r--r--src/DotNetOpenId/Yadis/UriElement.cs33
1 files changed, 29 insertions, 4 deletions
diff --git a/src/DotNetOpenId/Yadis/UriElement.cs b/src/DotNetOpenId/Yadis/UriElement.cs
index 20f8fc4..27d965a 100644
--- a/src/DotNetOpenId/Yadis/UriElement.cs
+++ b/src/DotNetOpenId/Yadis/UriElement.cs
@@ -9,12 +9,24 @@ namespace DotNetOpenId.Yadis {
base(uriElement, service) {
}
- public int Priority {
- get { return Node.SelectSingleNode("@priority", XmlNamespaceResolver).ValueAsInt; }
+ public int? Priority {
+ get {
+ XPathNavigator n = Node.SelectSingleNode("@priority", XmlNamespaceResolver);
+ return n != null ? n.ValueAsInt : (int?)null;
+ }
}
public Uri Uri {
- get { return new Uri(Node.Value); }
+ get {
+ if (Node.Value != null) {
+ string value = Node.Value.Trim();
+ if (value.Length > 0) {
+ return new Uri(value);
+ }
+ }
+
+ return null;
+ }
}
public ServiceElement Service {
@@ -24,8 +36,21 @@ namespace DotNetOpenId.Yadis {
#region IComparable<UriElement> Members
public int CompareTo(UriElement other) {
+ if (other == null) return -1;
int compare = Service.CompareTo(other.Service);
- return compare != 0 ? compare : Priority.CompareTo(other.Priority);
+ if (compare != 0) return compare;
+
+ if (Priority.HasValue && other.Priority.HasValue) {
+ return Priority.Value.CompareTo(other.Priority.Value);
+ } else {
+ if (Priority.HasValue) {
+ return -1;
+ } else if (other.Priority.HasValue) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
}
#endregion