-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor json serialiation helpers into a new package for developer c…
…onsumption (#30)
- Loading branch information
Showing
9 changed files
with
148 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<RootNamespace>MorganStanley.Fdc3.Json</RootNamespace> | ||
<AssemblyName>MorganStanley.Fdc3.Json</AssemblyName> | ||
<VersionPrefix>2.0.0</VersionPrefix> | ||
<VersionSuffix>alpha.1</VersionSuffix> | ||
<Product>fdc3-dotnet</Product> | ||
<SignAssembly>true</SignAssembly> | ||
<AssemblyOriginatorKeyFile>..\keypair.snk</AssemblyOriginatorKeyFile> | ||
<PackageReadmeFile>README.md</PackageReadmeFile> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>8.0</LangVersion> | ||
<RepositoryUrl>https://github.com/morganstanley/fdc3-dotnet</RepositoryUrl> | ||
<Description>.NET Standard 2.0 declarations to implement concrete FDC3 compatible .NET desktop agents and usage of intents/contexts.</Description> | ||
<Tags>FDC3</Tags> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'"> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<WarningLevel>9999</WarningLevel> | ||
</PropertyGroup> | ||
|
||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'"> | ||
<TreatWarningsAsErrors>True</TreatWarningsAsErrors> | ||
<WarningLevel>9999</WarningLevel> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<None Include="..\..\LICENSE"> | ||
<Pack>True</Pack> | ||
<PackagePath></PackagePath> | ||
</None> | ||
<None Include="..\..\README.md"> | ||
<Pack>True</Pack> | ||
<PackagePath>\</PackagePath> | ||
</None> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
</ItemGroup> | ||
|
||
</Project> |
47 changes: 47 additions & 0 deletions
47
src/Fdc3.Json/Serialization/Fdc3CamelCaseNamingStrategy.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Morgan Stanley makes this available to you under the Apache License, | ||
* Version 2.0 (the "License"). You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. Unless required by applicable law or agreed | ||
* to in writing, software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
using Newtonsoft.Json.Serialization; | ||
|
||
namespace MorganStanley.Fdc3.Json.Serialization | ||
{ | ||
public class Fdc3CamelCaseNamingStrategy : CamelCaseNamingStrategy | ||
{ | ||
public override string GetPropertyName(string name, bool hasSpecifiedName) | ||
{ | ||
switch (name) | ||
{ | ||
case "CURRENCY_ISOCODE": | ||
case "ISOALPHA2": | ||
case "ISOALPHA3": | ||
case "COUNTRY_ISOALPHA2": | ||
case "COUNTRY_ISOALPHA3": | ||
case "FDS_ID": | ||
case "BBG": | ||
case "CUSIP": | ||
case "FIGI": | ||
case "ISIN": | ||
case "PERMID": | ||
case "RIC": | ||
case "SEDOL": | ||
case "LEI": | ||
return name; | ||
|
||
default: | ||
return base.GetPropertyName(name, hasSpecifiedName); | ||
} | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* Morgan Stanley makes this available to you under the Apache License, | ||
* Version 2.0 (the "License"). You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0. | ||
* | ||
* See the NOTICE file distributed with this work for additional information | ||
* regarding copyright ownership. Unless required by applicable law or agreed | ||
* to in writing, software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions | ||
* and limitations under the License. | ||
*/ | ||
|
||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Converters; | ||
using Newtonsoft.Json.Serialization; | ||
|
||
namespace MorganStanley.Fdc3.Json.Serialization | ||
{ | ||
public class Fdc3JsonSerializerSettings : JsonSerializerSettings | ||
{ | ||
public Fdc3JsonSerializerSettings() | ||
{ | ||
this.TypeNameHandling = TypeNameHandling.None; | ||
this.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; | ||
this.DefaultValueHandling = DefaultValueHandling.Populate; | ||
this.NullValueHandling = NullValueHandling.Ignore; | ||
this.ContractResolver = new DefaultContractResolver() | ||
{ | ||
NamingStrategy = new Fdc3CamelCaseNamingStrategy() | ||
}; | ||
this.Converters = new JsonConverter[] { new StringEnumConverter() }; | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.