Пример #1
0
        public void ProcessInputData(IntentsDataFlowData data)
        {
            //Very important!!!
            //using foreach here instead of linq to reduce iterator allocations
            if (data.Value?.Count > 0)
            {
                //We can use a reuable list here because we are going to be first in the controlled update
                //cycle of the filter chain.
                _states.Clear();
                foreach (var intentState in data.Value)
                {
                    var state = _filter.Filter(intentState);
                    if (state != null)
                    {
                        _states.Add(state);
                    }
                }

                _intentData.Value = _states;
            }
            else
            {
                _intentData.Value = null;
            }

            InternalData = _intentData;
        }
Пример #2
0
        public void ProcessInputData(IntentsDataFlowData data)
        {
            //Very important!!!
            //using foreach here instead of linq to reduce iterator allocations
            //If we had better control over our update cycle, we could possibly eliminate the new list.
            if (data.Value.Count > 0)
            {
                var states = new List <IIntentState>(data.Value.Count);
                foreach (var intentState in data.Value)
                {
                    states.Add(_filter.Filter(intentState));
                }

                Data.Value = states;
            }
            else
            {
                Data.Value = EmptyState;
            }
        }