/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="Embedded">Whether this data is embedded into another data structure.</param> /// <param name="IncludeLastChange">Whether to include the lastChange timestamp of this object.</param> /// <param name="IncludeCryptoHash">Whether to include the cryptograhical hash value of this object.</param> /// <param name="CustomAPIKeySerializer">A delegate to serialize custom API key JSON objects.</param> public JObject ToJSON(Boolean Embedded, Boolean IncludeLastChange, Boolean IncludeCryptoHash, CustomJObjectSerializerDelegate <APIKey> CustomAPIKeySerializer) { var JSON = base.ToJSON(Embedded, IncludeLastChange, IncludeCryptoHash, null, new JProperty[] { new JProperty("userId", User.Id.ToString()), new JProperty("description", Description.ToJSON()), new JProperty("accessRights", AccessRights.AsText()), new JProperty("created", Created.ToIso8601()), NotBefore.HasValue ? new JProperty("notBefore", NotBefore.Value.ToIso8601()) : null, NotAfter.HasValue ? new JProperty("notAfter", NotAfter.Value.ToIso8601()) : null, ValidRemoteIPAddresses.SafeAny() ? new JProperty("validRemoteIPAddresses", new JArray(ValidRemoteIPAddresses.Select(validRemoteIPAddress => validRemoteIPAddress.ToString()))) : null, IsDisabled ? new JProperty("isDisabled", IsDisabled) : null }); return(CustomAPIKeySerializer != null ? CustomAPIKeySerializer(this, JSON) : JSON); }