SocketData.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace ToolsClassLibrary
  7. {
  8. /// <summary>
  9. /// 传输数据 配置文件管理
  10. /// </summary>
  11. /// <typeparam name="T"></typeparam>
  12. [Serializable]
  13. public class SocketData<T>
  14. {
  15. /// <summary>
  16. /// 文件名
  17. /// </summary>
  18. public string FileKey
  19. {
  20. get;
  21. set;
  22. }
  23. /// <summary>
  24. /// string 测点ID
  25. /// double 测点数据
  26. /// </summary>
  27. public Dictionary<string,T> FileData
  28. {
  29. get;
  30. set;
  31. }
  32. /// <summary>
  33. /// 创建类本身
  34. /// </summary>
  35. /// <param name="fileName">CSV文件名</param>
  36. /// <param name="key">测点ID</param>
  37. /// <param name="val">测点数据</param>
  38. /// <returns></returns>
  39. public static SocketData<T> CreateUpdData(string fileName, string[] key, T[] val)
  40. {
  41. SocketData<T> date = new SocketData<T>();
  42. if (key.Length == val.Length)
  43. {
  44. date.FileKey = fileName;
  45. date.FileData = new Dictionary<string, T>();
  46. for (int i = 0; i < key.Length; i++)
  47. {
  48. date.FileData.Add(key[i], val[i]);
  49. }
  50. }
  51. return date;
  52. }
  53. }
  54. }