Skip to content

Commit

Permalink
Merge pull request #17 from bbonkr/dev
Browse files Browse the repository at this point in the history
Remove JsonService #16
  • Loading branch information
bbonkr authored Jul 16, 2022
2 parents 62e4dcc + fdcf882 commit 8589d8b
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 78 deletions.
48 changes: 26 additions & 22 deletions Abstractions/IJsonService.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
/**
* Remove JsonService #16
*
*/
//using System;
//using System.Collections.Generic;
//using System.Text;

namespace kr.bbon.Xamarin.Forms.Abstractions
{
public interface IJsonService
{
/// <summary>
/// 직렬화 합니다.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
string Serialize(object obj);
//namespace kr.bbon.Xamarin.Forms.Abstractions
//{
// public interface IJsonService
// {
// /// <summary>
// /// 직렬화 합니다.
// /// </summary>
// /// <param name="obj"></param>
// /// <returns></returns>
// string Serialize(object obj);

/// <summary>
/// 역직렬화합니다.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="json"></param>
/// <returns></returns>
T Deserialize<T>(string json);
}
}
// /// <summary>
// /// 역직렬화합니다.
// /// </summary>
// /// <typeparam name="T"></typeparam>
// /// <param name="json"></param>
// /// <returns></returns>
// T Deserialize<T>(string json);
// }
//}
4 changes: 3 additions & 1 deletion AppContainerBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ protected virtual void Register(ContainerBuilder builder)
{
builder.RegisterType<HttpClientFactory>().As<IHttpClientFactory>();
builder.RegisterType<AppCenterDiagnosticsService>().As<IAppCenterDiagnosticsService>();
builder.RegisterType<JsonService>().As<IJsonService>();

// Remove JsonService #16
//builder.RegisterType<JsonService>().As<IJsonService>();
}

private readonly ContainerBuilder containerBuilder;
Expand Down
1 change: 0 additions & 1 deletion ContentPageBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Text;
using System.Threading.Tasks;
using Autofac;
using kr.bbon.Xamarin.Forms.Abstractions;
using Xamarin.Forms;

namespace kr.bbon.Xamarin.Forms
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

## 변경 Changes

### 1.2.0

- JsonService 제거
- Newtonsoft.Json 의존 제거

### 1.1.2

- 패키지 이미지 추가
Expand Down
107 changes: 56 additions & 51 deletions Services/JsonService.cs
Original file line number Diff line number Diff line change
@@ -1,56 +1,61 @@
using kr.bbon.Xamarin.Forms.Abstractions;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Text;
/**
* Remove JsonService #16
*
*/

namespace kr.bbon.Xamarin.Forms.Services
{
public class JsonService: IJsonService
{
/// <summary>
/// 직렬화 합니다.
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public string Serialize(object obj)
{
return JsonConvert.SerializeObject(obj, GetDefaultSettings());
}
//using kr.bbon.Xamarin.Forms.Abstractions;
//using Newtonsoft.Json;
//using Newtonsoft.Json.Serialization;
//using System;
//using System.Collections.Generic;
//using System.Text;

/// <summary>
/// 역직렬화합니다.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="json"></param>
/// <returns></returns>
public T Deserialize<T>(string json)
{
T obj = JsonConvert.DeserializeObject<T>(json, GetDefaultSettings());
//namespace kr.bbon.Xamarin.Forms.Services
//{
// public class JsonService: IJsonService
// {
// /// <summary>
// /// 직렬화 합니다.
// /// </summary>
// /// <param name="obj"></param>
// /// <returns></returns>
// public string Serialize(object obj)
// {
// return JsonConvert.SerializeObject(obj, GetDefaultSettings());
// }

return obj;
}
// /// <summary>
// /// 역직렬화합니다.
// /// </summary>
// /// <typeparam name="T"></typeparam>
// /// <param name="json"></param>
// /// <returns></returns>
// public T Deserialize<T>(string json)
// {
// T obj = JsonConvert.DeserializeObject<T>(json, GetDefaultSettings());

private JsonSerializerSettings GetDefaultSettings()
{
return new JsonSerializerSettings
{
// JSON 객체 속성 이름을 camelCase 형태로 처리합니다.
ContractResolver = new CamelCasePropertyNamesContractResolver(),
// 열거형 값을 문자열로 저장합니다.
//options.Converters.Add(new StringEnumConverter());
// 들여쓰기 형식을 지원합니다.
Formatting = Formatting.Indented,
// null 값을 가진 속성에 대한 직렬화/역직렬화 과정의 에러를 무시합니다.
NullValueHandling = NullValueHandling.Ignore,
// 정의되지 않은 멤버에 대한 직렬화/역직렬화 과정의 에러를 무시합니다.
MissingMemberHandling = MissingMemberHandling.Ignore,
// return obj;
// }

DateParseHandling = DateParseHandling.DateTimeOffset,
DateFormatHandling = DateFormatHandling.IsoDateFormat,
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
};
}
}
}
// private JsonSerializerSettings GetDefaultSettings()
// {
// return new JsonSerializerSettings
// {
// // JSON 객체 속성 이름을 camelCase 형태로 처리합니다.
// ContractResolver = new CamelCasePropertyNamesContractResolver(),
// // 열거형 값을 문자열로 저장합니다.
// //options.Converters.Add(new StringEnumConverter());
// // 들여쓰기 형식을 지원합니다.
// Formatting = Formatting.Indented,
// // null 값을 가진 속성에 대한 직렬화/역직렬화 과정의 에러를 무시합니다.
// NullValueHandling = NullValueHandling.Ignore,
// // 정의되지 않은 멤버에 대한 직렬화/역직렬화 과정의 에러를 무시합니다.
// MissingMemberHandling = MissingMemberHandling.Ignore,

// DateParseHandling = DateParseHandling.DateTimeOffset,
// DateFormatHandling = DateFormatHandling.IsoDateFormat,
// DateTimeZoneHandling = DateTimeZoneHandling.Utc,
// };
// }
// }
//}
1 change: 0 additions & 1 deletion Validations/IsNotNullOrEmptyRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public bool Check(T value)
return false;
}

// TODO ToString() 이 더 좋을 것으로 생각됨
var str = value as string ?? value.ToString();

return !String.IsNullOrWhiteSpace(str);
Expand Down
3 changes: 1 addition & 2 deletions kr.bbon.Xamarin.Forms.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<PackageId>kr.bbon.Xamarin.Forms</PackageId>
<Title>kr.bbon.Xamarin.Forms</Title>
<Version>1.1.2</Version>
<Version>1.2.0</Version>
<Authors>Pon Cheol Ku ([email protected])</Authors>
<Company>bbon.kr</Company>
<Copyright>bbon.kr. All rights reserved.</Copyright>
Expand All @@ -24,7 +24,6 @@
<PackageReference Include="Microsoft.AppCenter" Version="4.*" />
<PackageReference Include="Microsoft.AppCenter.Analytics" Version="4.*" />
<PackageReference Include="Microsoft.AppCenter.Crashes" Version="4.*" />
<PackageReference Include="Newtonsoft.Json" Version="13.*" />
<PackageReference Include="Autofac" Version="6.*" />
</ItemGroup>

Expand Down

0 comments on commit 8589d8b

Please sign in to comment.