示例#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="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

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

            Text.IsNeitherNullNorEmpty()
                       ? new JProperty("text", Text.ToJSON())
                       : null,

            new JProperty("publicationDate", PublicationDate.ToIso8601()),

            GeoLocation.HasValue
                       ? new JProperty("geoLocation", GeoLocation.ToJSON())
                       : null,

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            PrivacyLevel.ToJSON(),

            Signatures.Any()
                       ? new JProperty("signatures", new JArray(Signatures.SafeSelect(signature => signature.ToJSON(Embedded: true))))
                       : null

            );
示例#2
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="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

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

            Name.IsNeitherNullNorEmpty()
                       ? new JProperty("name", Name.ToJSON())
                       : null,

            Description.IsNeitherNullNorEmpty()
                       ? new JProperty("description", Description.ToJSON())
                       : null,

            new JProperty("creationDate", CreationDate.ToIso8601()),

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            new JProperty("isDisabled", IsDisabled)

            );
示例#3
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="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandAuthorId = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

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

            new JProperty("headline", Headline.ToJSON()),
            new JProperty("text", Text.ToJSON()),

            new JProperty("author", JSONObject.Create(
                              new JProperty("@id", Author.Id.ToString()),
                              new JProperty("name", Author.Name)
                              )),

            new JProperty("publicationDate", PublicationDate.ToIso8601()),

            Tags.Any()
                       ? new JProperty("tags", Tags.SafeSelect(tag => tag.ToJSON(ExpandTags)))
                       : null,

            Signatures.Any()
                       ? new JProperty("signatures", new JArray(Signatures.SafeSelect(signature => signature.ToJSON(Embedded: true))))
                       : null

            );
示例#4
0
        public JObject ToJSON(Boolean Embedded                  = false,
                              InfoStatus ExpandMembers          = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandParents          = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandSubOrganizations = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandTags             = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash         = true)
        {
            var org = base.ToJSON(Embedded,
                                  ExpandMembers,
                                  ExpandParents,
                                  ExpandSubOrganizations,
                                  ExpandTags,
                                  IncludeCryptoHash);

            org["@context"] = JSONLDContext.ToString();

            org.Add("youAreMember", YouAreMember);
            org.Add("youCanAddMembers", YouCanAddMembers);
            org.Add("youCanCreateChildOrganizations", YouCanCreateChildOrganizations);
            //org.Add("admins",                          JSONArray.Create(Admins. SafeSelect(user => user.ToJSON())));

            //if (YouAreMember)
            //    org.Add("members",                     JSONArray.Create(Members.SafeSelect(user => user.ToJSON())));

            //org.Add("_childs",                         new JArray(Childs.OrderBy(child => child.Id).Select(child => child.ToJSON())));

            return(org);
        }
示例#5
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="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        //public JObject ToJSON(Boolean Embedded           = false,
        //                      Boolean IncludeCryptoHash  = false)

        //    => ToJSON(Embedded:           false,
        //              IncludeSignatures:  InfoStatus.Hidden,
        //              IncludeCryptoHash:  true);



        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="Embedded">Whether this data is embedded into another data structure, e.g. into a AttachedFile.</param>
        /// <param name="IncludeCryptoHash">Whether to include the cryptograhical hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded             = false,
                              InfoStatus IncludeSignatures = InfoStatus.Hidden,
                              Boolean IncludeCryptoHash    = true,
                              CustomJObjectSerializerDelegate <AttachedFile> CustomAttachedFileSerializer = null)
        {
            var JSON = JSONObject.Create(

                new JProperty("@id", Id.ToString()),

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

                Description.IsNeitherNullNorEmpty()
                               ? new JProperty("description", Description.ToJSON())
                               : null,

                Icon.HasValue
                               ? new JProperty("icon", Icon.ToString())
                               : null,

                ContentType != null
                               ? new JProperty("contentType", ContentType.ToString())
                               : null,

                Created.HasValue
                               ? new JProperty("created", Created.Value.ToIso8601())
                               : null,

                LastModified.HasValue
                               ? new JProperty("lastModified", LastModified.Value.ToIso8601())
                               : null,

                Size.HasValue
                               ? new JProperty("size", Size.Value)
                               : null,

                Locations.SafeAny()
                               ? new JProperty("locations", new JArray(Locations.SafeSelect(location => location.ToString())))
                               : null

                //IncludeCryptoHash
                //    ? new JProperty("cryptoHash", CurrentCryptoHash)
                //    : null


                );

            return(CustomAttachedFileSerializer != null
                       ? CustomAttachedFileSerializer(this, JSON)
                       : JSON);
        }
示例#6
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);
        }
示例#7
0
        /// <summary>
        /// Return a JSON representation of this object.
        /// </summary>
        /// <param name="IncludeCryptoHash">Include the hash value of this object.</param>
        public override JObject ToJSON(Boolean Embedded          = true,
                                       Boolean IncludeCryptoHash = true)

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

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

            new JProperty("timestamp", Timestamp.ToIso8601()),
            new JProperty("type", Type.ToString()),
            new JProperty("data", Data),
            new JProperty("ownerIds", new JArray(Owners.Select(orgId => orgId.ToString()))),

            Signatures.SafeAny()
                       ? new JProperty("signatures", new JArray(Signatures))
                       : null

            );
示例#8
0
        public JObject ToJSON()

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

            new JProperty("@context", DefaultJSONLDContext.ToString()),

            new JProperty("title", Title.ToJSON()),

            Description.IsNeitherNullNorEmpty()
                       ? new JProperty("description", Description.ToJSON())
                       : null,

            new JProperty("visibility", Visibility.ToString().ToLower()),

            Notifications.SafeAny()
                       ? new JProperty("notifications", new JArray(Notifications.Select(info => info.ToJSON())))
                       : null

            );
示例#9
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="IncludeCryptoHash">Include the crypto hash value of this object.</param>
        public JObject ToJSON(Boolean Embedded          = false,
                              InfoStatus ExpandTags     = InfoStatus.ShowIdOnly,
                              InfoStatus ExpandAuthorId = InfoStatus.ShowIdOnly,
                              Boolean IncludeCryptoHash = false)

        => JSONObject.Create(

            new JProperty("@id", Id.ToString()),

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

            new JProperty("text", Text.ToJSON()),

            new JProperty("startTimestamp", StartTimestamp.ToIso8601()),
            new JProperty("endTimestamp", EndTimestamp.ToIso8601()),
            new JProperty("author", JSONObject.Create(
                              new JProperty("@id", Author.Id.ToString()),
                              new JProperty("name", Author.Name)
                              ))

            );