/// <summary> /// Add a new list to the list of lists and initialize it /// </summary> /// <typeparam name="T"></typeparam> /// <param name="jsonList"></param> /// <param name="action"></param> /// <returns></returns> public static T AddNewList <T>(this IJsonList <T> jsonList, Action <T> action) where T : IJsonList { var result = ((JsonArrayListWrapper <T>)jsonList).AddNew(); action(result); return(result); }
/// <summary> /// Add set of items to list /// </summary> /// <typeparam name="T"></typeparam> /// <param name="jsonList"></param> /// <param name="items"></param> public static void AddRange <T>(this IJsonList <T> jsonList, IEnumerable <T> items) { foreach (var item in items) { jsonList.Add(item); } }
public void FromJson(JsonValue json, JsonSerializer serializer) { if (json.Type != JsonValueType.Object) { return; } var obj = json.Object; ShowSidebar = obj.TryGetBoolean("showSidebar"); ShowSidebarMembers = obj.TryGetBoolean("showSidebarMembers"); ShowSidebarBoardActions = obj.TryGetBoolean("showSidebarBoardActions"); ShowSidebarActivity = obj.TryGetBoolean("showSidebarActivity"); ShowListGuide = obj.TryGetBoolean("showListGuide"); EmailPosition = obj.Deserialize <IJsonPosition>(serializer, "emailPosition"); EmailList = obj.Deserialize <IJsonList>(serializer, "idEmailList"); }
public int GetHashCode(IJsonList obj) { if (obj == null) { return(0); } unchecked { var hashCode = obj.Id?.GetHashCode() ?? 0; hashCode = (hashCode * 397) ^ (obj.Name?.GetHashCode() ?? 0); hashCode = (hashCode * 397) ^ obj.Closed.GetHashCode(); hashCode = (hashCode * 397) ^ Instance.GetHashCode(obj.Board); hashCode = (hashCode * 397) ^ Instance.GetHashCode(obj.Pos); hashCode = (hashCode * 397) ^ obj.Subscribed.GetHashCode(); return(hashCode); } }
protected List <double> GetElements(IJsonDict source, int numElements = 0) { EnsureValueIsType <IJsonList>(source); IJsonList value = (IJsonList)source["data"]; if (numElements != 0 && value.Count != numElements) { throw new SerializationException( string.Format( "{0} object: Expected data field to contain {1} elements, but it contained {2} instead.", this.info.Name, numElements, value.Count ) ); } try { return(value.Cast <double>().ToList()); } catch (InvalidCastException) { throw new SerializationException(string.Format("{0} object: All elements of data must be numeric values.", info.Name)); } }
public bool Equals(IJsonList x, IJsonList y) { if (x == null && y != null) { return(false); } if (x != null && y == null) { return(false); } if (x == null) { return(true); } return(x.Id == y.Id && x.Name == y.Name && x.Closed == y.Closed && Instance.Equals(x.Board, y.Board) && Instance.Equals(x.Pos, y.Pos) && x.Subscribed == y.Subscribed); }
internal List(IJsonList json, TrelloAuthorization auth) : this(json.Id, auth) { _context.Merge(json); }
/// <summary> /// Add a new list to the list of lists /// </summary> /// <typeparam name="T"></typeparam> /// <param name="jsonList"></param> /// <returns></returns> public static T AddNewList <T>(this IJsonList <T> jsonList) where T : IJsonList => ((JsonArrayListWrapper <T>)jsonList).AddNew();