Ejemplo n.º 1
0
        private static void ParseEvents(string eventFile, string outputFolder)
        {
            using (StreamReader reader = new StreamReader(eventFile))
            {
                RawEvents       rawEvents       = RawEvents.FromJson(reader.ReadToEnd());
                ProcessedEvents processedEvents = new ProcessedEvents();

                foreach (RawEvent rawEvent in rawEvents.Events)
                {
                    if (int.Parse(rawEvent.Price) < 0)
                    {
                        continue;
                    }

                    if (IsIgnoredEvent(rawEvent.Name))
                    {
                        continue;
                    }

                    if (HasVariablePrice(rawEvent.Name))
                    {
                        rawEvent.Price = "Varies";
                    }

                    ProcessedEvent processedEvent = ProcessedEvent.FromRawEvent(rawEvent);
                    processedEvents.Events.Add(processedEvent);
                }

                string outputFileEvents = Path.Combine(outputFolder, "StoreEvents.json");

                GenerateEventsOutput(processedEvents, outputFileEvents);
            }
        }
Ejemplo n.º 2
0
        public static RawEvents FromJson(string json)
        {
            RawEvents events = JsonConvert.DeserializeObject <RawEvents>(json, Settings);

            events.Events.Sort((item1, item2) =>
            {
                if (item1.KarmaType != item2.KarmaType)
                {
                    return(item1.KarmaType - item2.KarmaType);
                }

                return(string.Compare(item1.Name, item2.Name, StringComparison.OrdinalIgnoreCase));
            });

            return(events);
        }