public static DepthTickView FromList(List <DepthDetailView> list) { if (list == null || list.Count == 0) { return(null); } DepthTickView first = null; DepthTickView next = null; for (int i = 0; i < list.Count; ++i) { DepthDetailView detail = list[i]; switch (i % 3) { case 0: if (next == null) { next = new DepthTickView(); first = next; } else { next.Next = new DepthTickView(); next = next.Next; } next.BidPrice1 = detail.BidPrice; next.BidSize1 = detail.BidSize; next.BidCount1 = detail.BidCount; next.AskPrice1 = detail.AskPrice; next.AskSize1 = detail.AskSize; next.AskCount1 = detail.AskCount; break; case 1: next.BidPrice2 = detail.BidPrice; next.BidSize2 = detail.BidSize; next.BidCount2 = detail.BidCount; next.AskPrice2 = detail.AskPrice; next.AskSize2 = detail.AskSize; next.AskCount2 = detail.AskCount; break; case 2: next.BidPrice3 = detail.BidPrice; next.BidSize3 = detail.BidSize; next.BidCount3 = detail.BidCount; next.AskPrice3 = detail.AskPrice; next.AskSize3 = detail.AskSize; next.AskCount3 = detail.AskCount; break; } } return(first); }
public static List <DepthDetailView> ToList(DepthTickView deep) { List <DepthDetailView> list = new List <DepthDetailView>(); DepthDetailView detail; DepthTickView last = deep; while (last != null) { if (last.BidSize1 == 0 && last.AskSize1 == 0) { break; } detail = new DepthDetailView(); detail.BidPrice = last.BidPrice1; detail.BidSize = last.BidSize1; detail.BidCount = last.BidCount1; detail.AskPrice = last.AskPrice1; detail.AskSize = last.AskSize1; detail.AskCount = last.AskCount1; list.Add(detail); if (last.BidSize2 == 0 && last.AskSize2 == 0) { break; } detail = new DepthDetailView(); detail.BidPrice = last.BidPrice2; detail.BidSize = last.BidSize2; detail.BidCount = last.BidCount2; detail.AskPrice = last.AskPrice2; detail.AskSize = last.AskSize2; detail.AskCount = last.AskCount2; list.Add(detail); if (last.BidSize3 == 0 && last.AskSize3 == 0) { break; } detail = new DepthDetailView(); detail.BidPrice = last.BidPrice3; detail.BidSize = last.BidSize3; detail.BidCount = last.BidCount3; detail.AskPrice = last.AskPrice3; detail.AskSize = last.AskSize3; detail.AskCount = last.AskCount3; list.Add(detail); last = last.Next; } return(list); }