Skip to content
Browse files

Adding links support

  • Loading branch information...
1 parent 0313805 commit 3e099595f2995feecddeca9fe292f173e8e0dcb0 @hhariri hhariri committed
View
13 src/YouTrackSharp/Issues/Issue.cs
@@ -29,8 +29,10 @@
//
#endregion
+using System;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Globalization;
using JsonFx.Json;
namespace YouTrackSharp.Issues
@@ -50,15 +52,6 @@ public class Issue
public string Description { get; set; }
public string State { get; set; }
public int Votes { get; set; }
- // TODO: not supported
- //public IEnumerable<Link> Links {get;set;}
- }
-
- public class Link
- {
- public string Type { get; set; }
- public string Role { get; set; }
- [JsonName("$")]
- public string Value { get; set; }
+ public IList<Link> Links {get;set;}
}
}
View
22 src/YouTrackSharp/Issues/IssueTypeConverter.cs
@@ -32,6 +32,7 @@
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
+using System.Dynamic;
using System.Globalization;
using System.Reflection;
@@ -70,20 +71,27 @@ Issue ConvertFromFields(Hashtable fields)
foreach (PropertyInfo property in properties)
{
- property.SetValue(issue, Convert.ChangeType(fields[property.Name], property.PropertyType), null);
- if (String.Compare(property.Name, "Links", true) == 0)
+ if (String.Compare(property.Name, "Links") == 0)
{
+ issue.Links = ConvertLinks(fields["Links"]);
+
+ } else
+ {
+ property.SetValue(issue, Convert.ChangeType(fields[property.Name], property.PropertyType), null);
}
}
-
-
return issue;
}
- void ProcessLinkValues(PropertyInfo property, string source)
+ IList<Link> ConvertLinks(dynamic values)
{
-
+ var links = new List<Link>();
+ for (int i = 0; i < values.Length; i++)
+ {
+ var link = new Link() {Type = values[i].type, Role = values[i].role, Value = values[i].value};
+ links.Add(link);
+ }
+ return links;
}
-
}
}
View
9 src/YouTrackSharp/Issues/Link.cs
@@ -0,0 +1,9 @@
+namespace YouTrackSharp.Issues
+{
+ public class Link
+ {
+ public string Type { get; set; }
+ public string Role { get; set; }
+ public string Value { get; set; }
+ }
+}
View
1 src/YouTrackSharp/YouTrackSharp.csproj
@@ -78,6 +78,7 @@
<Compile Include="Infrastructure\IConnection.cs" />
<Compile Include="Infrastructure\ISearchEngine.cs" />
<Compile Include="Infrastructure\LuceneIssuePatternMatching.cs" />
+ <Compile Include="Issues\Link.cs" />
<Compile Include="Issues\SingleIssueWrapperTemporaryHackUntilYouTrackServerIsFixed.cs" />
<Compile Include="Infrastructure\SubValues.cs" />
<Compile Include="Infrastructure\SubValuesArray.cs" />
View
2 test.json
@@ -1,7 +1,7 @@
{"@id":"SB-12","field":[{"@name":"Priority","value":"Normal"},{"@name":"Type","value":"Bug"},{"@name":"State","value":"Submitted"},{"@name":"Assignee","value":"hhariri"},{"@name":"Subsystem","value":"No subsystem"},
-{"@name":"links","value":[{"@type":"Relates","@role":"relates to","$":"SB-10"},{"@type":"Relates","@role":"relates to","$":"SB-8"}]},
+ {"@name":"links","value":[{"@type":"Relates","@role":"relates to","$":"SB-10"},{"@type":"Relates","@role":"relates to","$":"SB-8"}]},

0 comments on commit 3e09959

Please sign in to comment.
Something went wrong with that request. Please try again.