Skip to content

Commit

Permalink
ContentType Serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
emmanuelmathot committed Sep 8, 2021
1 parent e574fe8 commit 919e7b3
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 23 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@

<h3 align="center">

![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=release/1.1.1)
![Build Status](https://github.com/Terradue/DotNetStac/actions/workflows/build.yaml/badge.svg?branch=develop)
[![NuGet](https://img.shields.io/nuget/vpre/DotNetStac)](https://www.nuget.org/packages/DotNetStac/)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/release/1.1.1/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![codecov](https://codecov.io/gh/Terradue/DotNetStac/branch/develop/graph/badge.svg)](https://codecov.io/gh/Terradue/DotNetStac)
[![Gitter](https://img.shields.io/gitter/room/SpatioTemporal-Asset-Catalog/Lobby?color=yellow)](https://gitter.im/SpatioTemporal-Asset-Catalog/Lobby)
[![License](https://img.shields.io/badge/license-AGPL3-blue.svg)](LICENSE)
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/Terradue/DotNetStac/master?filepath=example.ipynb)
Expand Down
36 changes: 18 additions & 18 deletions src/DotNetStac/DotNetStac.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<Description>Terradue .Net library for working with any SpatioTemporal Asset Catalog</Description>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<VersionPrefix>1.1.1</VersionPrefix>
<!-- <VersionSuffix>rc.4</VersionSuffix> -->
<Authors>Emmanuel Mathot</Authors>
<Authors>emmanuelmathot</Authors>
<Company>Terradue</Company>
Expand All @@ -20,31 +19,32 @@
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="2.0.2" />
<PackageReference Include="GeoJSON.Net" Version="1.2.19" />
<PackageReference Include="TimePeriodLibrary.NET" Version="2.1.1" />
<PackageReference Include="MathNet.Numerics" Version="4.12.0" />
<PackageReference Include="ProjNet" Version="2.0.0" />
<PackageReference Include="semver" Version="2.0.6" />
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Runtime.Loader" Version="4.3.0" />
<PackageReference Include="Multiformats.Hash" Version="1.5.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0"/>
<PackageReference Include="Newtonsoft.Json" Version="12.0.3"/>
<PackageReference Include="NetTopologySuite.IO.GeoJSON" Version="2.0.2"/>
<PackageReference Include="GeoJSON.Net" Version="1.2.19"/>
<PackageReference Include="TimePeriodLibrary.NET" Version="2.1.1"/>
<PackageReference Include="MathNet.Numerics" Version="4.12.0"/>
<PackageReference Include="ProjNet" Version="2.0.0"/>
<PackageReference Include="semver" Version="2.0.6"/>
<PackageReference Include="Newtonsoft.Json.Schema" Version="3.0.14"/>
<PackageReference Include="System.Reflection" Version="4.3.0"/>
<PackageReference Include="System.Runtime.Loader" Version="4.3.0"/>
<PackageReference Include="Multiformats.Hash" Version="1.5.0"/>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="All"/>
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0"/>
</ItemGroup>
<ItemGroup>
<None Include="..\..\LICENSE" Pack="true" PackagePath="" />
<None Include="..\..\docs\images\stac_logo_128.png" Pack="true" PackagePath="" />
<None Include="..\..\LICENSE" Pack="true" PackagePath=""/>
<None Include="..\..\docs\images\stac_logo_128.png" Pack="true" PackagePath=""/>
<Content Include="..\proj\SRID.csv" copyToOutput="true">
<IncludeInPackage>true</IncludeInPackage>
<CopyToOutput>true</CopyToOutput>
<BuildAction>Content</BuildAction>
<copyToOutput>true</copyToOutput>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<AdditionalFiles Include="$(ProjectDir)stylecop.json" Link="stylecop.json" />
<AdditionalFiles Include="$(ProjectDir)StyleCop.ruleset" Link="StyleCop.ruleset" />
<AdditionalFiles Include="$(ProjectDir)stylecop.json" Link="stylecop.json"/>
<AdditionalFiles Include="$(ProjectDir)StyleCop.ruleset" Link="StyleCop.ruleset"/>
</ItemGroup>
</Project>
20 changes: 17 additions & 3 deletions src/DotNetStac/StacLink.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.IO;
using System.Net.Mime;
using System.Runtime.Serialization;
using System.Threading.Tasks;
using Newtonsoft.Json;

namespace Stac
{
[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)]
[DataContract]
public class StacLink
{
#region Static members
Expand Down Expand Up @@ -90,16 +94,27 @@ public StacLink(StacLink source)
}

[JsonProperty("type")]
[JsonConverter(typeof(ContentTypeConverter))]
[DataMember(Name = "type")]
public string Type
{
get => ContentType?.ToString();
set => ContentType = value == null ? null : new ContentType(value);
}

[JsonIgnore]
[IgnoreDataMember]
public virtual ContentType ContentType { get; set; }

[JsonProperty("rel")]
[JsonProperty("rel", Required = Required.Always)]
[DataMember(Name = "rel", IsRequired = true)]
public virtual string RelationshipType { get; set; }

[JsonProperty("title")]
[DataMember(Name = "title")]
public virtual string Title { get; set; }

[JsonProperty("href")]
[DataMember(Name = "href", IsRequired = true)]
public virtual Uri Uri { get; set; }

[JsonIgnore]
Expand All @@ -112,6 +127,5 @@ public virtual StacLink Clone()
{
return new StacLink(this);
}

}
}

0 comments on commit 919e7b3

Please sign in to comment.