コード例 #1
0
 /// <summary>
 /// Build and return versioning information used for telemetry, including:
 /// The Schema version is 3.1, put into the Microsoft-BotFramework header,
 /// Protocol Extension Info,
 /// The Client SDK Version
 ///  https://github.com/Microsoft/botbuilder-dotnet/blob/d342cd66d159a023ac435aec0fdf791f93118f5f/doc/UserAgents.md,
 /// Additional Info.
 /// https://github.com/Microsoft/botbuilder-dotnet/blob/d342cd66d159a023ac435aec0fdf791f93118f5f/doc/UserAgents.md.
 /// </summary>
 /// <returns>A string containing versioning information.</returns>
 private static string GetUserAgent() =>
 string.Format(
     "Microsoft-BotFramework/3.1 Streaming-Extensions/1.0 BotBuilder/{0} ({1}; {2}; {3})",
     ConnectorClient.GetClientVersion(new ConnectorClient(new Uri("http://localhost"))),
     ConnectorClient.GetASPNetVersion(),
     ConnectorClient.GetOsVersion(),
     ConnectorClient.GetArchitecture());
コード例 #2
0
 /// <summary>
 /// Build and return versioning information used for telemetry, including:
 /// The Schema version is 3.1, put into the Microsoft-BotFramework header,
 /// Protocol Extension Info,
 /// The Client SDK Version
 ///  https://github.com/Microsoft/botbuilder-dotnet/blob/d342cd66d159a023ac435aec0fdf791f93118f5f/doc/UserAgents.md,
 /// Additional Info.
 /// https://github.com/Microsoft/botbuilder-dotnet/blob/d342cd66d159a023ac435aec0fdf791f93118f5f/doc/UserAgents.md.
 /// </summary>
 /// <returns>A string containing versioning information.</returns>
 private static string GetUserAgent()
 {
     using (var connectorClient = new ConnectorClient(new Uri("http://localhost")))
     {
         return(string.Format(
                    CultureInfo.InvariantCulture,
                    "Microsoft-BotFramework/3.1 Streaming-Extensions/1.0 BotBuilder/{0} ({1}; {2}; {3})",
                    ConnectorClient.GetClientVersion(connectorClient),
                    ConnectorClient.GetASPNetVersion(),
                    ConnectorClient.GetOsVersion(),
                    ConnectorClient.GetArchitecture()));
     }
 }
コード例 #3
0
        public void StreamingRequestHandler_UserAgent_Matches_Standard_Format()
        {
            var s = new StreamingRequestHandler(null, new MockBot(), null);

            var client          = new HttpClient();
            var userAgentHeader = client.DefaultRequestHeaders.UserAgent;

            // The Schema version is 3.1, put into the Microsoft-BotFramework header
            var botFwkProductInfo = new ProductInfoHeaderValue("Microsoft-BotFramework", "3.1");

            if (!userAgentHeader.Contains(botFwkProductInfo))
            {
                userAgentHeader.Add(botFwkProductInfo);
            }

            // Info on Streaming Extensions Version
            var streamingExtensionsVersion = new ProductInfoHeaderValue("Streaming-Extensions", "1.0");

            if (!userAgentHeader.Contains(streamingExtensionsVersion))
            {
                userAgentHeader.Add(streamingExtensionsVersion);
            }

            // The Client SDK Version
            //  https://github.com/Microsoft/botbuilder-dotnet/blob/d342cd66d159a023ac435aec0fdf791f93118f5f/doc/UserAgents.md
            var botBuilderProductInfo = new ProductInfoHeaderValue("BotBuilder", ConnectorClient.GetClientVersion(new ConnectorClient(new System.Uri("http://localhost"))));

            if (!userAgentHeader.Contains(botBuilderProductInfo))
            {
                userAgentHeader.Add(botBuilderProductInfo);
            }

            // Additional Info.
            // https://github.com/Microsoft/botbuilder-dotnet/blob/d342cd66d159a023ac435aec0fdf791f93118f5f/doc/UserAgents.md
            var userAgent = $"({ConnectorClient.GetASPNetVersion()}; {ConnectorClient.GetOsVersion()}; {ConnectorClient.GetArchitecture()})";

            if (ProductInfoHeaderValue.TryParse(userAgent, out var additionalProductInfo))
            {
                if (!userAgentHeader.Contains(additionalProductInfo))
                {
                    userAgentHeader.Add(additionalProductInfo);
                }
            }

            Assert.AreEqual(s.UserAgent, userAgentHeader.ToString());
        }
コード例 #4
0
 public void AgentStringComponents()
 {
     var aspNet = ConnectorClient.GetASPNetVersion();
     var arch   = ConnectorClient.GetArchitecture();
     var os     = ConnectorClient.GetOsVersion();
 }