public static void ParseEpcListInto(this XElement element, EpcType type, EpcisEvent destination) { foreach (var epc in element.Elements("epc")) { destination.Epcs.Add(new Epc { Type = type, Id = epc.Value }); } }
private static XElement CreateEpcList(EpcisEvent evt, EpcType type, string elementName) { var epcs = evt.Epcs.Where(x => x.Type == type); var list = new XElement(elementName); list.AddIfNotNull(epcs.Select(x => new XElement("epc", x.Id))); return(list); }
private void ParseEpcs(EpcisEvent epcisEvent, IList <string> epcs, EpcType type) { if (epcs == null || !epcs.Any()) { return; } epcs.ForEach(e => epcisEvent.Epcs.Add(new Epc { Id = e, Type = type })); }
private static void ParseEpcList(XElement element, EpcisEvent epcisEvent, EpcType type) { if (element == null || element.IsEmpty) { return; } epcisEvent.Epcs.AddRange(element.Elements("epc").Select(x => new Epc { Id = x.Value, Type = type })); }
private static XElement CreateQuantityList(EpcisEvent evt, EpcType type, string elementName) { var epcs = evt.Epcs.Where(x => x.Type == type); var list = new XElement(elementName); list.AddIfNotNull(epcs.Select(x => { var element = new XElement("quantityElement", new XElement("epcClass", x.Id)); element.AddIfNotNull(new[] { new XElement("quantity", x.Quantity), new XElement("uom", x.UnitOfMeasure) }); return(element); })); return(list); }
private static void ParseEpcQuantityList(XElement element, EpcisEvent epcisEvent, EpcType type) { if (element == null || element.IsEmpty) { return; } epcisEvent.Epcs.AddRange(element.Elements("quantityElement").Select(x => new Epc { Id = x.Element("epcClass").Value, IsQuantity = true, Quantity = float.TryParse(x.Element("quantity")?.Value, NumberStyles.AllowDecimalPoint, new CultureInfo("en-GB"), out float quantity) ? quantity : default(float?), UnitOfMeasure = x.Element("uom")?.Value, Type = type }));
private void ParceQuantityList(EpcisEvent epcisEvent, IList <JToken> list, EpcType type) { if (list == null || !list.Any()) { return; } list.Select(x => x.ToObject <IDictionary <string, JObject> >()).ForEach(qty => epcisEvent.Epcs.Add(new Epc { Id = qty["epcClass"].ToString(), IsQuantity = true, Type = type, UnitOfMeasure = qty.ContainsKey("uom") ? qty["uom"].ToString() : null, Quantity = int.Parse(qty["quantity"].ToString()) })); }
internal static IEnumerable <XElement> FormatEpcList(EpcisEvent evt, EpcType epcType) { return(evt.Epcs.Where(x => x.Type == epcType).Select(e => new XElement("epc", e.Id))); }
internal static IEnumerable <XElement> FormatEpcQuantity(EpcisEvent evt, EpcType epcType) { return(evt.Epcs.Where(x => x.Type == epcType).Select(FormatQuantity)); }
public static void ParseQuantityListInto(this XElement element, EpcisEvent destination, EpcType type) { foreach (var epc in element.Elements("quantityElement")) { destination.Epcs.Add(new Epc { Type = type, Id = epc.Element("epcClass").Value, IsQuantity = true, Quantity = float.Parse(epc.Element("quantity").Value, CultureInfo.InvariantCulture), UnitOfMeasure = epc.Element("uom")?.Value }); } }