Пример #1
0
        public MappingData <TOutput, TState> Process(MappingData <TInput, TState> input)
        {
            if (!CanMap(input))
            {
                throw new ArgumentOutOfRangeException(nameof(input), "There are no row in table with such input data.");
            }

            return(table[input]);
        }
Пример #2
0
        public void RemoveRow(MappingData <TInput, TState> input)
        {
            if (!IsRowExist(input))
            {
                throw new InvalidOperationException("This row does not exist in table.");
            }

            rows.Remove(input);
        }
Пример #3
0
        public void AddRow(MappingData <TInput, TState> input, MappingData <TOutput, TState> output)
        {
            if (IsRowExist(input))
            {
                throw new InvalidOperationException("This row already exist in table.");
            }

            rows.Add(input, output);
        }
        public Information <TOutput> Process(Information <TInput> input)
        {
            var mappingInput = new MappingData <TInput, TState>(input.Value, CurrentState.Value);


            if (!Mapping.CanMap(mappingInput))
            {
                throw new Exception("Mapping cannot process given input with current state");//TODO: создать своё исключение для этого случая
            }
            var mappingOutput = Mapping.Process(mappingInput);

            CurrentState = new Information <TState>(mappingOutput.State, StateDomain);

            return(new Information <TOutput>(mappingOutput.Data, OutputDomain));
        }
Пример #5
0
 public bool CanMap(MappingData <TInput, TState> value)
 {
     return(table.ContainsKey(value));
 }
Пример #6
0
 public bool IsRowExist(MappingData <TInput, TState> input)
 {
     return(rows.ContainsKey(input));
 }