PortProducerFactory.cs 708 B

12345678910111213141516171819202122232425
  1. using SHJX.Service.Control.PortProduction.PortProducerImpl;
  2. namespace SHJX.Service.Control.PortProduction
  3. {
  4. public class PortProducerFactory
  5. {
  6. private static OptCommand _command;
  7. public PortProducerFactory(OptCommand command)
  8. {
  9. _command = command;
  10. }
  11. public static IPortProducer Factory(WriteWay way)
  12. {
  13. IPortProducer operate = way switch
  14. {
  15. WriteWay.Read => new ReadPortProducer(_command),
  16. WriteWay.Write => new WritePortProducer(_command),
  17. _ => throw new ArgumentException("未找到对应的枚举!")
  18. };
  19. return operate;
  20. }
  21. }
  22. }