public static Embed ToEntity(this API.EmbedJson model) { return(new Embed(model.Type, model.Title, model.Description, model.Url, model.Timestamp, model.Color.HasValue ? new Color(model.Color.Value) : (Color?)null, model.Image.IsSpecified ? model.Image.Value.ToEntity() : (EmbedImage?)null, model.Video.IsSpecified ? model.Video.Value.ToEntity() : (EmbedVideo?)null, model.Author.IsSpecified ? model.Author.Value.ToEntity() : (EmbedAuthor?)null, model.Footer.IsSpecified ? model.Footer.Value.ToEntity() : (EmbedFooter?)null, model.Provider.IsSpecified ? model.Provider.Value.ToEntity() : (EmbedProvider?)null, model.Thumbnail.IsSpecified ? model.Thumbnail.Value.ToEntity() : (EmbedThumbnail?)null, model.Fields.IsSpecified ? model.Fields.Value.Select(x => x.ToEntity()).ToImmutableArray() : ImmutableArray.Create <EmbedField>())); }
public static API.EmbedJson ToModel(this Embed entity) { if (entity == null) { return(null); } API.EmbedJson model = new API.EmbedJson { Type = entity.Type, Title = entity.Title, Description = entity.Description, Url = entity.Url, Timestamp = entity.Timestamp, Color = entity.Color?.RawValue }; if (entity.Author != null) { model.Author = entity.Author.Value.ToModel(); } model.Fields = entity.Fields.Select(x => x.ToModel()).ToArray(); if (entity.Footer != null) { model.Footer = entity.Footer.Value.ToModel(); } if (entity.Image != null) { model.Image = entity.Image.Value.ToModel(); } if (entity.Provider != null) { model.Provider = entity.Provider.Value.ToModel(); } if (entity.Thumbnail != null) { model.Thumbnail = entity.Thumbnail.Value.ToModel(); } if (entity.Video != null) { model.Video = entity.Video.Value.ToModel(); } return(model); }