当前位置: 首页>>代码示例>>C#>>正文


C# SortedList.GetString方法代码示例

本文整理汇总了C#中System.Collections.SortedList.GetString方法的典型用法代码示例。如果您正苦于以下问题:C# SortedList.GetString方法的具体用法?C# SortedList.GetString怎么用?C# SortedList.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Collections.SortedList的用法示例。


在下文中一共展示了SortedList.GetString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Enhance

        /// <summary>
        /// Updates the capabilities used by Microsoft's implementation of the
        /// HttpBrowserCapabilities class to control the property values it
        /// returns. Only properties exposed by FiftyOneBrowserCapabilities are overriden
        /// by this method.
        /// </summary>
        /// <param name="capabilities">Dictionary of capabilities to be enhanced.</param>
        /// <param name="currentCapabilities">Dictionary of existing capabilities for the device.</param>
        /// <param name="results">The match result to use for the enhancement.</param>
        private static void Enhance(
            IDictionary capabilities,
            HttpBrowserCapabilities currentCapabilities,
            SortedList<string, string[]> results)
        {
            // Set base capabilities for all mobile devices.
            SetStaticValues(capabilities);

            SetValue(capabilities, "isMobileDevice", GetIsMobileDevice(results));
            SetValue(capabilities, "crawler", GetIsCrawler(results));
            SetValue(capabilities, "mobileDeviceModel", GetMobileDeviceModel(results));
            SetValue(capabilities, "mobileDeviceManufacturer", GetMobileDeviceManufacturer(results));
            SetValue(capabilities, "platform", GetPlatform(results));
            // property enhancement can be removed with this compiler flag
            #if !REMOVE_OVERRIDE_BROWSER
            SetValue(capabilities, "browser", GetBrowser(results));
            #endif
            SetValue(capabilities, "type", capabilities["mobileDeviceManufacturer"]);
            SetValue(capabilities, "screenPixelsHeight", GetScreenPixelsHeight(results) ??
                GetDefaultValue("screenPixelsHeight", currentCapabilities));
            SetValue(capabilities, "screenPixelsWidth", GetScreenPixelsWidth(results) ??
                GetDefaultValue("screenPixelsWidth", currentCapabilities));
            SetValue(capabilities, "screenBitDepth", GetBitsPerPixel(results));
            SetValue(capabilities, "preferredImageMime", GetPreferredImageMime(results));
            SetValue(capabilities, "isColor", GetIsColor(results));
            SetValue(capabilities, "supportsCallback", GetSupportsCallback(results));
            SetValue(capabilities, "SupportsCallback", GetSupportsCallback(results));
            SetValue(capabilities, "canInitiateVoiceCall", GetIsMobileDevice(results));
            SetValue(capabilities, "jscriptversion", GetJavascriptVersion(results));

            // The following values are set to prevent exceptions being thrown in
            // the standard .NET base classes if the property is accessed.
            SetValue(capabilities, "screenCharactersHeight",
                GetDefaultValue("screenCharactersHeight", currentCapabilities));
            SetValue(capabilities, "screenCharactersWidth",
                GetDefaultValue("screenCharactersWidth", currentCapabilities));

            // Use the Version class to find the version. If this fails use the 1st two
            // decimal segments of the string.
            string versionValue = results.GetString("BrowserVersion");
            if (versionValue != null)
            {
            #if VER4
                Version version = null;
                if (Version.TryParse(versionValue, out version))
                {
                    SetVersion(capabilities, version);
                }
                else
                {
                    SetVersion(capabilities, versionValue.ToString());
                }
            #else
                try
                {
                    SetVersion(capabilities, new Version(versionValue));
                }
                catch (FormatException)
                {
                    SetVersion(capabilities, versionValue.ToString());
                }
                catch (ArgumentException)
                {
                    SetVersion(capabilities, versionValue.ToString());
                }
            #endif
            }
            else
            {
                // Transfer the current version capabilities to the new capabilities.
                SetValue(capabilities, "majorversion", currentCapabilities != null ? currentCapabilities["majorversion"] : null);
                SetValue(capabilities, "minorversion", currentCapabilities != null ? currentCapabilities["minorversion"] : null);
                SetValue(capabilities, "version", currentCapabilities != null ? currentCapabilities["version"] : null);

                // Ensure the version values are not null to prevent null arguement exceptions
                // with some controls.
                var versionString = currentCapabilities != null ? currentCapabilities["version"] as string : "0.0";
                SetVersion(capabilities, versionString);
            }

            // All we can determine from the device database is if javascript is supported as a boolean.
            // If the value is not provided then null is returned and the capabilities won't be altered.
            var javaScript = GetJavascriptSupport(results);
            if (javaScript.HasValue)
            {
                SetJavaScript(capabilities, javaScript.Value);
                SetValue(capabilities, "ecmascriptversion",
                         (bool)javaScript ? "3.0" : "0.0");
            }

            // Sets the W3C DOM version.
//.........这里部分代码省略.........
开发者ID:51Degrees,项目名称:dotNET-Device-Detection,代码行数:101,代码来源:MobileCapabilitiesOverride.cs


注:本文中的System.Collections.SortedList.GetString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。