Beispiel #1
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure.</param>
        /// <param name="CustomRemotePartySerializer">A delegate to serialize custom remote party JSON objects.</param>
        /// <param name="CustomBusinessDetailsSerializer">A delegate to serialize custom business details JSON objects.</param>
        /// <param name="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded,
                              CustomJObjectSerializerDelegate <RemoteParty> CustomRemotePartySerializer         = null,
                              CustomJObjectSerializerDelegate <BusinessDetails> CustomBusinessDetailsSerializer = null,
                              Boolean IncludeCryptoHash = false)
        {
            var JSON = JSONObject.Create(

                Id.ToJSON("@id"),

                Embedded
                               ? new JProperty("@context", DefaultJSONLDContext.ToString())
                               : null,

                new JProperty("countryCode", CountryCode.ToString()),
                new JProperty("partyId", PartyId.ToString()),
                new JProperty("role", Role.ToString()),
                new JProperty("partyStatus", Status.ToString()),

                BusinessDetails != null
                               ? new JProperty("businessDetails", BusinessDetails.ToJSON(CustomBusinessDetailsSerializer))
                               : null,

                _AccessInfo.SafeAny()
                               ? new JProperty("accessInfos", new JArray(_AccessInfo.SafeSelect(accessInfo => accessInfo.ToJSON())))
                               : null,

                _RemoteAccessInfos.SafeAny()
                               ? new JProperty("remoteAccessInfos", new JArray(_RemoteAccessInfos.SafeSelect(remoteAccessInfo => remoteAccessInfo.ToJSON())))
                               : null,

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

                IncludeCryptoHash
                               ? new JProperty("sha256Hash", SHA256Hash)
                               : null

                );

            return(CustomRemotePartySerializer != null
                       ? CustomRemotePartySerializer(this, JSON)
                       : JSON);
        }
Beispiel #2
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="CustomCredentialsRoleSerializer">A delegate to serialize custom credentials roles JSON objects.</param>
        /// <param name="CustomBusinessDetailsSerializer">A delegate to serialize custom business details JSON objects.</param>
        public JObject ToJSON(CustomJObjectSerializerDelegate <CredentialsRole> CustomCredentialsRoleSerializer = null,
                              CustomJObjectSerializerDelegate <BusinessDetails> CustomBusinessDetailsSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("country_code", CountryCode.ToString()),
                new JProperty("party_id", PartyId.ToString()),
                new JProperty("role", Role.ToString()),
                new JProperty("business_details", BusinessDetails.ToJSON(CustomBusinessDetailsSerializer))

                //AllowDowngrades.HasValue
                //    ? new JProperty("allow_downgrades",  AllowDowngrades.Value)
                //    : null

                );

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