From aa40eb640b4be6eb778460f02e7a4c39f38cb2fc Mon Sep 17 00:00:00 2001 From: Biroj Nayak Date: Wed, 20 Sep 2023 22:34:31 +0000 Subject: [PATCH] Adding more browser capabilities --- .../Configuration/HttpCapabilitiesBase.cs | 21 +++++++++++++++++++ .../Generated/Ref.Standard.cs | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/Microsoft.AspNetCore.SystemWebAdapters/Configuration/HttpCapabilitiesBase.cs b/src/Microsoft.AspNetCore.SystemWebAdapters/Configuration/HttpCapabilitiesBase.cs index af664ae5e9..e64c63a694 100644 --- a/src/Microsoft.AspNetCore.SystemWebAdapters/Configuration/HttpCapabilitiesBase.cs +++ b/src/Microsoft.AspNetCore.SystemWebAdapters/Configuration/HttpCapabilitiesBase.cs @@ -53,6 +53,14 @@ private IHttpBrowserCapabilityFeature Capability public string? this[string key] => Capability[key]; + public Version EcmaScriptVersion => GetVersion("ecmascriptversion"); + + public Version MSDomVersion => GetVersion("msdomversion"); + + public Version W3CDomVersion => GetVersion("w3cdomversion"); + + public bool SupportsCallback => GetBoolean("supportsCallback"); + public bool IsMobileDevice => GetBoolean("isMobileDevice"); private int GetInt(string key) => int.TryParse(Capability[key], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) ? result : throw new HttpUnhandledException($"Invalid string from browser capabilities '{key}'"); @@ -91,4 +99,17 @@ private double GetDouble(string key) throw new HttpUnhandledException($"Invalid string from browser capabilities '{key}'"); } + + private Version GetVersion(string key) + { + var result = Capability[key]; + if (result is not null) + { + return new Version(result); + } + else + { + throw new ArgumentNullException(nameof(key)); + } + } } diff --git a/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/Ref.Standard.cs b/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/Ref.Standard.cs index eb6fb4ee79..6398019f46 100644 --- a/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/Ref.Standard.cs +++ b/src/Microsoft.AspNetCore.SystemWebAdapters/Generated/Ref.Standard.cs @@ -776,14 +776,18 @@ internal HttpCapabilitiesBase() { } public string Browser { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public bool Cookies { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public bool Crawler { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } + public System.Version EcmaScriptVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public bool IsMobileDevice { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public string this[string key] { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public int MajorVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public double MinorVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } + public System.Version MSDomVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public string Platform { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public string PreferredRequestEncoding { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } + public bool SupportsCallback { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public string Type { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } public string Version { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } + public System.Version W3CDomVersion { get { throw new System.PlatformNotSupportedException("Only supported when running on ASP.NET Core or System.Web");} } } } namespace System.Web.Hosting