-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Устанавливаем отдельный специальный User-Agent при запросах из COM SDK (
#1097) DDCORE-8019 Попутно Заменил netcoreapp2.2 на net5.0 в тестах. Мотивация: netcoreapp2.2 уже нет в образе Visual Studio 2019 в appveyor [0]. [0]: https://www.appveyor.com/docs/windows-images-software/
- Loading branch information
Showing
4 changed files
with
57 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
using System; | ||
using System.Diagnostics; | ||
using JetBrains.Annotations; | ||
|
||
namespace Diadoc.Api.Http | ||
{ | ||
internal static class UserAgentBuilder | ||
{ | ||
private static readonly string SdkVersion; | ||
private static readonly string NetFxVersion; | ||
|
||
static UserAgentBuilder() | ||
{ | ||
SdkVersion = typeof(HttpClient).Assembly.GetName().Version.ToString(); | ||
NetFxVersion = Environment.Version.ToString(); | ||
try | ||
{ | ||
SdkVersion = FileVersionInfo.GetVersionInfo(typeof(HttpClient).Assembly.Location).FileVersion; | ||
} | ||
catch | ||
{ | ||
} | ||
|
||
try | ||
{ | ||
NetFxVersion = FileVersionInfo.GetVersionInfo(typeof(int).Assembly.Location).FileVersion; | ||
} | ||
catch | ||
{ | ||
} | ||
} | ||
|
||
public static string Build([NotNull] string sdkName) | ||
{ | ||
if (sdkName == null) | ||
throw new ArgumentNullException(nameof(sdkName)); | ||
return string.Format("Diadoc {0} SDK={1};OS={2};NETFX={3}", | ||
sdkName, | ||
SdkVersion, | ||
Environment.OSVersion.VersionString, | ||
NetFxVersion); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters