private static List <BaseEvent> ParseEvents(string fileName)
        {
            var baseEvents = new List <BaseEvent>();
            var lines      = File.ReadAllLines(fileName).ToList();

            foreach (var line in lines)
            {
                var       jsonEvent = JsonConvert.DeserializeObject <JsonEvent>(line);
                BaseEvent newEvent;
                switch (jsonEvent.EventType)
                {
                case "Rank":
                    newEvent = new RankEvent(jsonEvent);
                    baseEvents.Add(newEvent);
                    break;

                case "Progress":
                    newEvent = new ProgressEvent(jsonEvent);
                    baseEvents.Add(newEvent);
                    break;

                case "Reputation":
                    newEvent = new ReputationEvent(jsonEvent);
                    baseEvents.Add(newEvent);
                    break;

                case "Music":
                    newEvent = new MusicEvent(jsonEvent);
                    baseEvents.Add(newEvent);
                    break;

                default:
                    break;
                }
            }

            return(baseEvents);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var baseEvents = new List <BaseEvent>();
            var lines      = File.ReadAllLines(@"X:\Log Files\01.log").ToList();

            foreach (var line in lines)
            {
                var       eventType = JsonConvert.DeserializeObject <EventType>(line);
                BaseEvent newEvent;
                switch (eventType.@event)
                {
                case "Rank":
                    newEvent = new RankEvent(eventType);
                    baseEvents.Add(newEvent);
                    break;

                case "Progress":
                    newEvent = new ProgressEvent(eventType);
                    baseEvents.Add(newEvent);
                    break;

                case "Reputation":
                    newEvent = new ReputationEvent(eventType);
                    baseEvents.Add(newEvent);
                    break;

                case "Music":
                    newEvent = new MusicEvent(eventType);
                    baseEvents.Add(newEvent);
                    break;

                default:
                    break;
                }
            }
            Console.WriteLine(baseEvents);
        }