コード例 #1
0
        /// <summary>
        /// Ensures that the request is valid.
        /// </summary>
        /// <param name="botData">Private bot data</param>
        /// <param name="stateData">Data extracted from the state parameter.</param>
        /// <returns><c>true</c> if the request is valid; otherwise <c>false</c>.</returns>
        /// <exception cref="ArgumentNullException">
        /// <paramref name="botData"/> is null.
        /// or
        /// <paramref name="stateData"/> is null.
        /// </exception>
        private static bool Validate(IBotData botData, IDictionary <string, string> stateData)
        {
            string uniqueId;

            botData.AssertNotNull(nameof(botData));
            stateData.AssertNotNull(nameof(stateData));

            if (botData.PrivateConversationData.TryGetValue(BotConstants.UniqueIdentifierKey, out uniqueId))
            {
                if (!uniqueId.Equals(stateData[BotConstants.UniqueIdentifierKey], StringComparison.CurrentCultureIgnoreCase))
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            return(stateData[BotConstants.UniqueIdentifierKey].Equals(uniqueId, StringComparison.CurrentCultureIgnoreCase));
        }