コード例 #1
0
        /// <summary>
        /// Method called just before allowing externals to select a response.
        /// </summary>
        protected override void InternalPreSelectResponse(RecordedDataSourceSelectorEventArgs e)
        {
            if (!AllowMatchingByChannel)
            {
                return;
            }

            var request = ConvertToJSon(e);

            // do nothing:
            if (request == null || !request.IsEnumerable)
            {
                return;
            }

            var channel = RecordedBayeuxDataSourceResponse.GetChannel(request);

            if (string.IsNullOrEmpty(channel))
            {
                return;
            }

            // select matching response by channel:
            foreach (var response in e.Responses)
            {
                var bayeuxResponse = response as RecordedBayeuxDataSourceResponse;
                if (bayeuxResponse != null)
                {
                    if (string.Compare(channel, bayeuxResponse.Channel, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        e.SelectedResponse = bayeuxResponse;

                        DebugLog.WriteBayeuxLine(string.Concat("Selected response for channel: '", channel, "'"));
                        return;
                    }
                }
            }
        }