Global_Relation_Defination.cs 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /* ==============================================================================
  2. * 功能描述:Global_Relation_Defination
  3. * 创 建 者:Garrett
  4. * 创建日期:2019/1/21 10:04:23
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.ComponentModel;
  9. using System.Linq;
  10. using System.Reflection;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using Newtonsoft.Json.Linq;
  14. using SAGA.DotNetUtils.Extend;
  15. using SAGA.MBI.RequestData;
  16. namespace SAGA.MBI.Model
  17. {
  18. /// <summary>
  19. /// Global_Relation_Defination
  20. /// </summary>
  21. public class Global_Relation_Defination
  22. {
  23. private static Global_Relation_Defination m_Instance;
  24. public static Global_Relation_Defination Instance
  25. {
  26. get
  27. {
  28. if (m_Instance == null)
  29. {
  30. string json = RelationRequest.GetGlobalRelationDefination();
  31. JObject jObject = JObject.Parse(json);
  32. m_Instance =
  33. jObject.ConvertToInstance(typeof(Global_Relation_Defination)) as Global_Relation_Defination;
  34. }
  35. return m_Instance;
  36. }
  37. }
  38. [Description("Content")]
  39. public List<Relation_Graph_Defination> Content { get; set; }
  40. /// <summary>
  41. /// 查找图类型的定义
  42. /// </summary>
  43. /// <param name="graph_Type"></param>
  44. /// <returns></returns>
  45. public Relation_Graph_Defination FindGraphDefination(string graph_Type)
  46. {
  47. return Content?.FirstOrDefault(t => t.Graph_Type == graph_Type);
  48. }
  49. /// <summary>
  50. /// 查找关系类型的定义
  51. /// </summary>
  52. /// <param name="graph_Type"></param>
  53. /// <param name="descrption"></param>
  54. /// <returns></returns>
  55. public Relation_Type_Defination FindTypeDefination(string graph_Type, string descrption)
  56. {
  57. var graphModel = FindGraphDefination(graph_Type);
  58. return graphModel?.Content?.FirstOrDefault(t=>t.Description== descrption);
  59. }
  60. }
  61. /// <summary>
  62. /// 图类型的定义
  63. /// </summary>
  64. public class Relation_Graph_Defination
  65. {
  66. public Relation_Graph_Defination()
  67. {
  68. Content=new List<Relation_Type_Defination>();
  69. }
  70. [Description("graph_type")]
  71. public string Graph_Type { get; set; }
  72. [Description("graph_name")]
  73. public string Graph_Name { get; set; }
  74. [Description("Content")]
  75. public List<Relation_Type_Defination> Content { get; set; }
  76. }
  77. /// <summary>
  78. /// 关系类型的定义
  79. /// </summary>
  80. public class Relation_Type_Defination
  81. {
  82. [Description("rel_name")]
  83. public string Rel_Name { get; set; }
  84. [Description("directional")]
  85. public string Directional { get; set; }
  86. [Description("target_objs")]
  87. public string Target_Objs { get; set; }
  88. [Description("rel_type")]
  89. public string Rel_Type { get; set; }
  90. [Description("description")]
  91. public string Description { get; set; }
  92. }
  93. }