Пример #1
0
        /// <summary>
        /// Parses the links.
        /// </summary>
        /// <param name="jsonWorkItem">The json work item.</param>
        /// <returns>JsonLinkCollection.</returns>
        private static JsonLinkCollection ParseLinks(JsonWorkItem jsonWorkItem)
        {
            JArray             value = (JArray)((JObject)jsonWorkItem.JsonValue).Properties().FirstOrDefault(p => p.Name == "relations").Value <Object>();
            JsonLinkCollection links = JsonLinkCollection.FromToken(value);

            return(links);
        }
Пример #2
0
        /// <summary>
        /// Froms the token.
        /// </summary>
        /// <param name="json">The json.</param>
        /// <returns>JsonWorkItem.</returns>
        public static JsonWorkItem FromToken(JToken json)
        {
            var initializer = DefaultInitializer(json);
            var workItem    = new JsonWorkItem(json, initializer);

            return(workItem);
        }
Пример #3
0
        /// <summary>
        /// Parses the fields.
        /// </summary>
        /// <param name="jsonWorkItem">The json work item.</param>
        /// <returns>JsonFieldCollection.</returns>
        private static JsonFieldCollection ParseFields(JsonWorkItem jsonWorkItem)
        {
            JProperty           property = ((JObject)jsonWorkItem.JsonValue).Properties().FirstOrDefault(p => p.Name == "fields");
            JsonFieldCollection fields   = JsonFieldCollection.FromToken(property.Value);

            return(fields);
        }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="JsonBackedObjectBase" /> class.
 /// </summary>
 /// <param name="json">The json.</param>
 public JsonWorkItemLink(JToken json)
     : base(json)
 {
     r_OtherItem = new Lazy <JsonWorkItem>(() =>
     {
         JsonWorkItem retVal = JsonWorkItem.APIFactory().GetWorkItem(new Uri(sr_Url.Eval(this)));
         return(retVal);
     });
 }
Пример #5
0
 /// <summary>
 /// Initializes static members of the <see cref="JsonLink" /> class.
 /// </summary>
 static JsonLink()
 {
     sr_RelationTypes = new Lazy <Dictionary <string, JsonRelationType> >(() =>
     {
         if (PreLoadedTypes != null)
         {
             return(PreLoadedTypes);
         }
         IReadOnlyList <JsonRelationType> knownTypes = JsonWorkItem.APIFactory().GetRelationTypes().Result;
         return(knownTypes.ToDictionary(knownType => knownType.ReferenceName));
     });
 }
Пример #6
0
        /// <summary>
        /// Froms the token.
        /// </summary>
        /// <param name="json">The json.</param>
        /// <returns>JsonRelatedLink.</returns>
        public static new JsonRelatedLink FromToken(JToken json)
        {
            var initializer = new JsonWorkItemInitializer
            {
                OtherItemInitializer = new ParameterizedLazyWithReset <JsonRelatedLink, JsonWorkItem>(o =>
                {
                    var retVal = JsonWorkItem.APIFactory().GetWorkItem(new Uri(sr_Url.Eval(o)));
                    return(retVal);
                }),
                LinkTypeEndInitializer = new ParameterizedLazyWithReset <JsonRelatedLink, JsonLinkTypeEnd>(o =>
                {
                    JProperty property = ((JObject)o.JsonValue).Properties().FirstOrDefault(p => p.Name == "rel");
                    var retVal         = new JsonLinkTypeEnd(property.Value);
                    return(retVal);
                })
            };

            return(new JsonRelatedLink(json, initializer));
        }
Пример #7
0
        /// <summary>
        /// Fieldses to j array.
        /// </summary>
        /// <param name="workItem">The work item.</param>
        /// <returns>JArray.</returns>
        public static JArray FieldsToJArray(JsonWorkItem workItem)
        {
            var elements = new JArray();

            foreach (JsonField field in workItem.Fields)
            {
                var fullDefinition = JsonFieldDefinitionCollection.GetDefinition(field.FieldDefinition.ReferenceName);
                if ((field.Value != null) && !sr_ExcludedFields.Contains(field.FieldDefinition.ReferenceName) && !fullDefinition.ReadOnly)
                {
                    var element = new JObject
                    {
                        new JProperty("op", "add"),
                        new JProperty("path", "/fields/" + field.ReferenceName),
                        new JProperty("value", field.Value)
                    };
                    elements.Add(element);
                }
            }
            return(elements);
        }
Пример #8
0
 /// <summary>
 /// Deferreds the load links.
 /// </summary>
 /// <param name="jsonWorkItem">The json work item.</param>
 /// <returns>JsonLinkCollection.</returns>
 private static JsonLinkCollection DeferredLoadLinks(JsonWorkItem jsonWorkItem)
 {
     return(APIFactory().GetLinksForWorkItemRevision(jsonWorkItem).Result);
 }
Пример #9
0
 /// <summary>
 /// Deferreds the load fields.
 /// </summary>
 /// <param name="jsonWorkItem">The json work item.</param>
 /// <returns>JsonFieldCollection.</returns>
 /// <exception cref="NoReStAPIEquivilantException"></exception>
 /// <exception cref="DynCon.OSI.VSO.ReSTClient.Objects.Base.NoReStAPIEquivilantException"></exception>
 private static JsonFieldCollection DeferredLoadFields(JsonWorkItem jsonWorkItem)
 {
     throw new NoReStAPIEquivilantException();
 }