Esempio n. 1
0
 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
         });
     }
 }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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
            }));
        }
Esempio n. 4
0
        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
            }));
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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
            }));
Esempio n. 7
0
        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())
            }));
        }
Esempio n. 8
0
 internal static IEnumerable <XElement> FormatEpcList(EpcisEvent evt, EpcType epcType)
 {
     return(evt.Epcs.Where(x => x.Type == epcType).Select(e => new XElement("epc", e.Id)));
 }
Esempio n. 9
0
 internal static IEnumerable <XElement> FormatEpcQuantity(EpcisEvent evt, EpcType epcType)
 {
     return(evt.Epcs.Where(x => x.Type == epcType).Select(FormatQuantity));
 }
Esempio n. 10
0
 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
         });
     }
 }