/// <summary> /// Sets the field. /// </summary> /// <param name="fieldName">Name of the field.</param> /// <param name="value">The value.</param> public void SetFieldValue(string fieldName, object value) { JsonField field; var jsonFieldCollection = r_Fields.Value(this); if (!jsonFieldCollection.TryGetField(fieldName, out field)) { var definition = JsonFieldDefinitionCollection.GetDefinition(fieldName); } field.Value = value; }
public void GetDefinition_UnitTest() { String referenceName = default(String); JsonFieldDefinition _retVal = default(JsonFieldDefinition); ExecuteMethod( () => { return(GetInstance()); }, instance => { referenceName = default(String); //No Constructor GetDefinition_PreCondition(instance, ref referenceName); }, instance => { return(_retVal = JsonFieldDefinitionCollection.GetDefinition(referenceName)); }, instance => { GetDefinition_PostValidate(instance, referenceName, _retVal); }); }
/// <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); }