/// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomPublishTokenTypeSerializer">A delegate to serialize custom publish token type JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <PublishTokenType> CustomPublishTokenTypeSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("uid", Id.ToString()),

                Type.HasValue
                               ? new JProperty("type", Type.ToString())
                               : null,

                VisualNumber.IsNotNullOrEmpty()
                               ? new JProperty("visual_number", VisualNumber)
                               : null,

                Issuer.IsNotNullOrEmpty()
                               ? new JProperty("issuer", Issuer)
                               : null,

                GroupId.HasValue
                               ? new JProperty("group_id", GroupId.ToString())
                               : null

                );

            return(CustomPublishTokenTypeSerializer != null
                       ? CustomPublishTokenTypeSerializer(this, JSON)
                       : JSON);
        }
示例#2
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomTokenSerializer">A delegate to serialize custom token JSON objects.</param>
        /// <param name="CustomEnergyContractSerializer">A delegate to serialize custom energy contract JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <Token> CustomTokenSerializer = null,
                              CustomJObjectSerializerDelegate <EnergyContract> CustomEnergyContractSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("country_code", CountryCode.ToString()),
                new JProperty("party_id", PartyId.ToString()),
                new JProperty("uid", Id.ToString()),
                new JProperty("type", Type.ToString()),
                new JProperty("contract_id", ContractId.ToString()),

                VisualNumber.IsNotNullOrEmpty()
                               ? new JProperty("visual_number", VisualNumber)
                               : null,

                new JProperty("issuer", Issuer),

                GroupId.HasValue
                               ? new JProperty("group_id", GroupId.ToString())
                               : null,

                new JProperty("valid", IsValid),
                new JProperty("whitelist", WhitelistType.ToString()),

                UILanguage.HasValue
                               ? new JProperty("language", UILanguage.ToString())
                               : null,

                DefaultProfile.HasValue
                               ? new JProperty("default_profile_type", DefaultProfile.ToString())
                               : null,

                EnergyContract.HasValue
                               ? new JProperty("energy_contract", EnergyContract.Value.ToJSON(CustomEnergyContractSerializer))
                               : null,

                new JProperty("last_updated", LastUpdated.ToIso8601())

                );

            return(CustomTokenSerializer != null
                       ? CustomTokenSerializer(this, JSON)
                       : JSON);
        }