BimIdConverter.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:BimIdConverter
  3. * 作者:xulisong
  4. * 创建时间: 2019/6/18 11:16:54
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using JBIM;
  13. using Newtonsoft.Json;
  14. namespace RevitToJBim.JsonConverter
  15. {
  16. public class BimIdConverter : Newtonsoft.Json.JsonConverter
  17. {
  18. public override bool CanConvert(Type objectType)
  19. {
  20. return objectType == typeof(BimId);
  21. }
  22. public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
  23. {
  24. throw new NotImplementedException();
  25. }
  26. public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
  27. {
  28. if (value == null)
  29. {
  30. writer.WriteNull();
  31. return;
  32. }
  33. writer.WriteValue(value.ToString());
  34. }
  35. }
  36. }