ServiceDispatchTable.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233
  1. using Ryujinx.Horizon.Common;
  2. using System;
  3. using System.Collections.Generic;
  4. namespace Ryujinx.Horizon.Sdk.Sf.Cmif
  5. {
  6. class ServiceDispatchTable : ServiceDispatchTableBase
  7. {
  8. private readonly string _objectName;
  9. private readonly IReadOnlyDictionary<int, CommandHandler> _entries;
  10. public ServiceDispatchTable(string objectName, IReadOnlyDictionary<int, CommandHandler> entries)
  11. {
  12. _objectName = objectName;
  13. _entries = entries;
  14. }
  15. public override Result ProcessMessage(ref ServiceDispatchContext context, ReadOnlySpan<byte> inRawData)
  16. {
  17. return ProcessMessageImpl(ref context, inRawData, _entries, _objectName);
  18. }
  19. public static ServiceDispatchTableBase Create(IServiceObject instance)
  20. {
  21. if (instance is DomainServiceObject)
  22. {
  23. return new DomainServiceObjectDispatchTable();
  24. }
  25. return new ServiceDispatchTable(instance.GetType().Name, instance.GetCommandHandlers());
  26. }
  27. }
  28. }