public IFluentSequenceBuilder RunCount(int runCount) { CodeContract.PreCondition <ArgumentException>(_runCount == 1); _runCount = runCount; return(this); }
public IFluentSequenceBuilder Queue(IRunnable task) { CodeContract.PreCondition <ArgumentException>(!_tasksSet); _tasks.Add(task); return(this); }
public IFluentSequenceBuilder Recovery(Func <SequenceResultEnum> recoveryFunc) { CodeContract.PreCondition <ArgumentException>(!_sequenceRecoverySet); _recoveryFunc = recoveryFunc; _sequenceRecoverySet = true; return(this); }
public IFluentSequenceBuilder Fail(Action failAction) { CodeContract.PreCondition <ArgumentException>(!_sequenceFailActionSet); _failAction = failAction; _sequenceFailActionSet = true; return(this); }
public IFluentSequenceBuilder Parrelell() { EndQueue(); CodeContract.PreCondition <ArgumentException>(!_sequenceTypeSet); _sequenceType = ISequenceFactory.Parelell; _sequenceTypeSet = true; return(this); }
public ISequence Build() { CodeContract.PreCondition <ArgumentException>(_sequenceTypeSet); CodeContract.PreCondition <ArgumentException>(_tasksSet); CodeContract.PreCondition <ArgumentException>(_sequenceFailActionSet); var recovery = _sequenceRecoverySet ? new RecoveryOptionsDto(true, _recoveryFunc) : new RecoveryOptionsDto(); return(_sequenceFactory.CreateSequence( _sequenceType, _tasks, recovery, _failAction, _runCount )); }
/// <exception cref="ArgumentException"></exception> /// > /// <exception cref="SocketException"></exception> /// > public OperationResponseDto SendOperation(OperationDto operationDto) { //PRE-CONDITION //TODO LOGGING operationDto.Params.ToList() .ForEach(x => CodeContract.PreCondition <ArgumentException>(x >= 0 && x <= 65535)); var paramBytes = new List <byte>(); foreach (var param in operationDto.Params) { paramBytes.Add(GetDataType(param)); paramBytes.AddRange(ValueToBytes(param)); } var payload = new List <byte> { operationDto.Operation, operationDto.Device }.Concat(paramBytes).ToArray(); try { _socketClient.Connect(); _socketClient.Send(payload); var response = _socketClient.Recieve(); //POST-CONDITIONS //TODO LOGGING CodeContract.PostCondition <SocketException>( !response.SequenceEqual(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 })); CodeContract.PostCondition <ArgumentException>(response[1] > 0 && response[1] < 4); CodeContract.PostCondition <ArgumentException>(response[0] > 0); CodeContract.PostCondition <ArgumentException>(response.Length == 8); return(new OperationResponseDto { Status = response[0], Returns = BytesToValue(response.Skip(1).ToArray()) }); } finally { _socketClient.Close(); } }
/// <exception cref="ArgumentException"></exception> public OperationResultEnum Validate(byte errorCode) { //PRECONDITION CodeContract.PreCondition <ArgumentException>(() => { switch (errorCode) { case 1: case 2: case 3: case 4: return(true); default: return(false); } }); //TODO LOGGING BASED ON ERROR CODE return(errorCode == 1 ? OperationResultEnum.Succeess : OperationResultEnum.Failiure); }
private void EndQueue() { CodeContract.PreCondition <ArgumentException>(!_tasksSet); _tasksSet = true; }