Beispiel #1
0
        public Event(string name, JObject data, IGatherlingApi api)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Event Name is null", nameof(name));
            }

            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            Players = new Dictionary <string, Person>(StringComparer.InvariantCultureIgnoreCase);
            foreach (var p in (JArray)data["players"])
            {
                Players.Add(p.Value <string>("name"), p.ToObject <Person>());
            }

            Gatherling = api ?? throw new ArgumentNullException(nameof(api));
            Name       = name;
            Channel    = data.Value <string>("mtgo_room");
            if (Channel != null && !Channel.StartsWith("#"))
            {
                Channel = "#" + Channel;
            }
            Series          = data.Value <string>("series");
            Main            = new SubEvent(data.Value <string>("mainstruct"), data.Value <int>("mainrounds"));
            Finals          = new SubEvent(data.Value <string>("finalstruct"), data.Value <int>("finalrounds"));
            CurrentRoundNum = data.Value <int>("current_round");
            if (data.ContainsKey("unreported"))
            {
                Unreported = ((JArray)data["unreported"]).Values <string>().ToArray();
            }
            try
            {
                if (data.ContainsKey("standings"))
                {
                    var jArray = ((JArray)data["standings"]);
                    Standings = jArray.Select(t => ((JObject)t).ToObject <Standing>()).ToArray();
                }
            }
            catch (Exception c)
            {
                SentrySdk.WithScope(scope =>
                {
                    scope.SetExtra("event", data);
                    SentrySdk.CaptureException(c);
                });
            }
            Round.FromJson((JArray)data["matches"], this);
        }
Beispiel #2
0
        public Event(string name, JObject data, IGatherlingApi api)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("Event Name is null", nameof(name));
            }

            if (data == null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            Gatherling = api ?? throw new ArgumentNullException(nameof(api));
            Name       = name;
            Channel    = data.Value <string>("mtgo_room");
            if (Channel != null && !Channel.StartsWith("#"))
            {
                Channel = "#" + Channel;
            }
            Series = data.Value <string>("series");

            if (data.ContainsKey("unreported"))
            {
                Unreported = ((JArray)data["unreported"]).Values <string>().ToArray();
            }
            try
            {
                if (data.ContainsKey("standings"))
                {
                    var jArray = ((JArray)data["standings"]);
                    Standings = jArray.Select(t => ((JObject)t).ToObject <Standing>()).ToArray();
                }
            }
            catch (Exception c)
            {
                SentrySdk.WithScope(scope =>
                {
                    scope.SetExtra("event", data);
                    SentrySdk.CaptureException(c);
                });
            }
        }
Beispiel #3
0
 public Event(IGatherlingApi api)
 {
     Gatherling = api ?? throw new ArgumentNullException(nameof(api));
 }