Blackboard.cs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections.Generic;
  2. namespace etoy
  3. {
  4. /// <summary>
  5. /// 黑板 (这里用来存放Pileline产生的各种内存信息)
  6. /// </summary>
  7. class Blackboard
  8. {
  9. /// <summary> 配置表版本号 </summary>
  10. public string Version;
  11. /// <summary> 时间戳 </summary>
  12. public long Timestamp;
  13. /// <summary> 解析完后的配置表 </summary>
  14. public List<Table> Tables = new List<Table>();
  15. /// <summary> 解析完后的KeyValue表 </summary>
  16. public List<KeyValueTable> KeyValueTables = new List<KeyValueTable>();
  17. /// <summary> 解析完后的Metadata表 </summary>
  18. public List<MetadataTable> MetadataTables = new List<MetadataTable>();
  19. /// <summary>
  20. /// Metadata是否包含类型
  21. /// </summary>
  22. /// <param name="typeName"></param>
  23. /// <returns></returns>
  24. public bool ContainsMetadataType(string typeName)
  25. {
  26. foreach (var table in MetadataTables)
  27. if (table.Structs.ContainsKey(typeName))
  28. return true;
  29. return false;
  30. }
  31. /// <summary>
  32. /// 尝试获取Metadata
  33. /// </summary>
  34. /// <param name="typeName"></param>
  35. /// <param name="metadata"></param>
  36. /// <returns></returns>
  37. public bool TryGetMetadata(string typeName, out MetadataStruct metadata)
  38. {
  39. metadata = null;
  40. foreach (var table in MetadataTables)
  41. return table.Structs.TryGetValue(typeName, out metadata);
  42. return false;
  43. }
  44. }
  45. }