BuiltinVersionListSerializer.UpdatableVersionListTryGetValueCallback.cs 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //------------------------------------------------------------
  2. // Game Framework
  3. // Copyright © 2013-2021 loyalsoft. All rights reserved.
  4. // Homepage: http://www.game7000.com/
  5. // Feedback: http://www.game7000.com/
  6. //------------------------------------------------------------
  7. using System.IO;
  8. using System.Text;
  9. namespace UnityGameFramework.Runtime
  10. {
  11. /// <summary>
  12. /// 内置版本资源列表序列化器。
  13. /// </summary>
  14. public static partial class BuiltinVersionListSerializer
  15. {
  16. /// <summary>
  17. /// 尝试从可更新模式版本资源列表(版本 0)获取指定键的值回调函数。
  18. /// </summary>
  19. /// <param name="stream">指定流。</param>
  20. /// <param name="key">指定键。</param>
  21. /// <param name="value">指定键的值。</param>
  22. /// <returns>从可更新模式版本资源列表(版本 0)获取指定键的值是否成功。</returns>
  23. public static bool UpdatableVersionListTryGetValueCallback_V0(Stream stream, string key, out object value)
  24. {
  25. value = null;
  26. if (key != "InternalResourceVersion")
  27. {
  28. return false;
  29. }
  30. using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
  31. {
  32. binaryReader.BaseStream.Position += CachedHashBytesLength;
  33. byte stringLength = binaryReader.ReadByte();
  34. binaryReader.BaseStream.Position += stringLength;
  35. value = binaryReader.ReadInt32();
  36. }
  37. return true;
  38. }
  39. /// <summary>
  40. /// 尝试从可更新模式版本资源列表(版本 1 或版本 2)获取指定键的值回调函数。
  41. /// </summary>
  42. /// <param name="stream">指定流。</param>
  43. /// <param name="key">指定键。</param>
  44. /// <param name="value">指定键的值。</param>
  45. /// <returns>从可更新模式版本资源列表(版本 1 或版本 2)获取指定键的值是否成功。</returns>
  46. public static bool UpdatableVersionListTryGetValueCallback_V1_V2(Stream stream, string key, out object value)
  47. {
  48. value = null;
  49. if (key != "InternalResourceVersion")
  50. {
  51. return false;
  52. }
  53. using (BinaryReader binaryReader = new BinaryReader(stream, Encoding.UTF8))
  54. {
  55. binaryReader.BaseStream.Position += CachedHashBytesLength;
  56. byte stringLength = binaryReader.ReadByte();
  57. binaryReader.BaseStream.Position += stringLength;
  58. value = binaryReader.Read7BitEncodedInt32();
  59. }
  60. return true;
  61. }
  62. }
  63. }