public static bool IsMappingInDomains <TInput, TOutput, TState>(IMapping <TInput, TOutput, TState> mapping, IDomain <TInput> inputDomain, IDomain <TOutput> outputDomain, IDomain <TState> stateDomain) { //TODO: написать нормальное название для метода foreach (var map in mapping) { if (!inputDomain.Contains(map.InputValue)) { return(false); } if (!stateDomain.Contains(map.InputState)) { return(false); } if (!outputDomain.Contains(map.OutputValue)) { return(false); } if (!stateDomain.Contains(map.OutputState)) { return(false); } } return(true); }
public Information(T value, IDomain <T> domain) { if (!domain.Contains(value)) { throw new ArgumentOutOfRangeException(nameof(value), "Given value is not in given domain"); } Value = value; Domain = domain; }
public AbstractMachine(IDomain <TInput> inputDomain, IDomain <TOutput> outputDomain, IDomain <TState> stateDomain, IMapping <TInput, TOutput, TState> mapping, Information <TState> initialState) { InputDomain = inputDomain; OutputDomain = outputDomain; StateDomain = stateDomain; if (!MappingValidityChecker.IsMappingInDomains(mapping, inputDomain, outputDomain, stateDomain)) { throw new ArgumentOutOfRangeException(nameof(mapping), "Mapping not in domains."); //TODO: написать нормальный message } Mapping = mapping; if (!stateDomain.Contains(initialState)) { throw new ArgumentOutOfRangeException(nameof(initialState), "Given initial state is not in StateDomain."); } CurrentState = initialState; }