private void WriteUser(User user) { if (user is null) { return; } var eu = EventUser.FromUser(user, _config); _jsonWriter.WritePropertyName("user"); _jsonWriter.WriteStartObject(); MaybeWriteString("key", eu.Key); MaybeWriteString("secondary", eu.SecondaryKey); MaybeWriteString("ip", eu.IpAddress); MaybeWriteString("country", eu.Country); MaybeWriteString("firstName", eu.FirstName); MaybeWriteString("lastName", eu.LastName); MaybeWriteString("name", eu.Name); MaybeWriteString("avatar", eu.Avatar); MaybeWriteString("email", eu.Email); if (eu.Anonymous.HasValue) { _jsonWriter.WritePropertyName("anonymous"); _jsonWriter.WriteValue(eu.Anonymous.Value); } if (eu.Custom != null && eu.Custom.Count > 0) { _jsonWriter.WritePropertyName("custom"); _jsonWriter.WriteStartObject(); foreach (var kv in eu.Custom) { _jsonWriter.WritePropertyName(kv.Key); _jsonSerializer.Serialize(_jsonWriter, kv.Value); } _jsonWriter.WriteEndObject(); } if (eu.PrivateAttrs != null) { _jsonWriter.WritePropertyName("privateAttrs"); _jsonWriter.WriteStartArray(); foreach (var a in eu.PrivateAttrs) { _jsonWriter.WriteValue(a); } _jsonWriter.WriteEndArray(); } _jsonWriter.WriteEndObject(); }
internal EventUserBuilder(User user, IBaseConfiguration config) { _user = user; _config = config; _result = new EventUser(); }