IPortProducer.cs 1004 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. namespace SHJX.Service.Control.PortProduction.Interface
  2. {
  3. public abstract class IPortProducer
  4. {
  5. private string _name;
  6. private ArgType _type;
  7. private object _value;
  8. private OptCommand _command;
  9. public IPortProducer(OptCommand command)
  10. {
  11. _command = command;
  12. }
  13. public IPortProducer SetName(string name)
  14. {
  15. _name = name;
  16. return this;
  17. }
  18. public IPortProducer SetType(ArgType type)
  19. {
  20. _type = type;
  21. return this;
  22. }
  23. public IPortProducer SetValue(object value)
  24. {
  25. _value = value;
  26. return this;
  27. }
  28. public object Execute()
  29. {
  30. IPortArg port = GetPortArg(_type);
  31. PortEventArgs arg = port.SetValue(_value).Init(_name);
  32. return _command.Factory(_type).Execute(arg);
  33. }
  34. protected abstract IPortArg GetPortArg(ArgType type);
  35. }
  36. }