/// <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 );
/// <summary> /// Create a new user group builder. /// </summary> /// <param name="Id">The unique identification of the group.</param> /// <param name="JSONLDContext">The JSON-LD context of this group.</param> /// /// <param name="Name">A multi-language name of the group.</param> /// <param name="Description">A multi-language description of the group.</param> /// <param name="Members">The members of the group.</param> /// <param name="ParentGroup">An optional parent group.</param> /// <param name="Subgroups">Optional subgroups.</param> /// <param name="CustomData">Custom data to be stored with this group.</param> /// <param name="AttachedFiles">Optional files attached to this group.</param> /// /// <param name="DataSource">The source of all this data, e.g. an automatic importer.</param> /// <param name="LastChange">The timestamp of the last changes within this group. Can e.g. be used as a HTTP ETag.</param> public Builder(TGroupId Id, JSONLDContext JSONLDContext, I18NString Name, I18NString Description = null, IEnumerable <TMembers> Members = null, TGroup ParentGroup = null, IEnumerable <TGroup> Subgroups = null, JObject CustomData = null, IEnumerable <AttachedFile> AttachedFiles = null, String DataSource = null, DateTime?LastChange = null) : base(Id, JSONLDContext, CustomData, DataSource, LastChange) { this.Name = Name; this.Description = Description ?? I18NString.Empty; this.Members = Members.IsNeitherNullNorEmpty() ? new HashSet <TMembers> (Members) : new HashSet <TMembers>(); this.ParentGroup = ParentGroup; this.Subgroups = Subgroups.IsNeitherNullNorEmpty() ? new HashSet <TGroup> (Subgroups) : new HashSet <TGroup>(); this.AttachedFiles = AttachedFiles.IsNeitherNullNorEmpty() ? new HashSet <AttachedFile>(AttachedFiles) : new HashSet <AttachedFile>(); }
/// <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) );
/// <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 );
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); }
/// <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 );
/// <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) )) );