private static string GetFirstRenderingTypeFromWURFL(DeviceInfo device) { // The value returned when checking the capability. bool value; // Look at all the possible markups that could be supported // and returned the 1st one found. if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWiOmaXhtmlmp10)), out value) && value) { return("xhtml-mp"); } if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWiW3Xhtmlbasic)), out value) && value) { return("xhtml-basic"); } if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWiImodeCompactGeneric)), out value) && value) { return("chtml10"); } if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWeb40)), out value) && value) { return("html32"); } if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWeb32)), out value) && value) { return("html32"); } return(null); }
private static string GetMobileDeviceModel(DeviceInfo device) { string value = Strings.Get(device.GetCapability(MarketingName)); if (String.IsNullOrEmpty(value)) { value = Strings.Get(device.GetCapability(ModelName)); } return(value); }
private static string GetPreferredRenderingTypeFromWURFL(DeviceInfo device) { switch (Strings.Get(device.GetCapability(PreferredMarkup))) { case "html_web_3_2": return("html32"); case "html_web_4_0": return("html4"); case "html_wi_oma_xhtmlmp_1_0": return("xhtml-mp"); case "html_wi_w3_xhtmlbasic": return("xhtml-basic"); case "html_wi_imode_htmlx_1": case "html_wi_imode_html_1": case "html_wi_imode_html_2": case "html_wi_imode_html_3": case "html_wi_imode_html_4": case "html_wi_imode_html_5": case "html_wi_imode_html_6": case "html_wi_imode_htmlx_1_1": case "html_wi_imode_compact_generic": return("chtml10"); default: return(GetFirstRenderingTypeFromWURFL(device)); } }
private static string GetIsColor(DeviceInfo device) { long numberOfColors = 0; long.TryParse(Strings.Get(device.GetCapability(Colors)), out numberOfColors); bool isColor = (numberOfColors >= 256); return(isColor.ToString(CultureInfo.InvariantCulture)); }
private static string GetPreferredImageMime(DeviceInfo device, IDictionary capabilities) { // Look at the database and return the 1st one that matches in order // of preference. if (bool.TrueString.Equals(Strings.Get(device.GetCapability(Png)), StringComparison.InvariantCultureIgnoreCase)) { return("image/png"); } if (bool.TrueString.Equals(Strings.Get(device.GetCapability(Jpg)), StringComparison.InvariantCultureIgnoreCase)) { return("image/jpeg"); } if (bool.TrueString.Equals(Strings.Get(device.GetCapability(Gif)), StringComparison.InvariantCultureIgnoreCase)) { return("image/gif"); } return(null); }
private static string GetScreenBitDepth(DeviceInfo device) { long fScreenBitDepth = 1; long numberOfColors = 256; long.TryParse(Strings.Get(device.GetCapability(Colors)), out numberOfColors); fScreenBitDepth = Support.GetBitsPerPixel(numberOfColors); return(fScreenBitDepth.ToString(CultureInfo.InvariantCulture)); }
//The following methods and bindings were suggested by forum member 'fravelgue' private static string GetMaximumSoftKeyLabelLength(DeviceInfo device) { string value = Strings.Get(device.GetCapability(SoftkeySupport)); if (String.IsNullOrEmpty(value) || value.Equals("false", StringComparison.InvariantCultureIgnoreCase)) { return(bool.FalseString.ToLowerInvariant()); } return(bool.TrueString.ToLowerInvariant()); }
private static string GetTables(DeviceInfo device) { string value = Strings.Get(device.GetCapability(XhtmlTableSupport)); if (String.IsNullOrEmpty(value) || value.Equals("false", StringComparison.InvariantCultureIgnoreCase)) { return(bool.FalseString.ToLowerInvariant()); } return(bool.TrueString.ToLowerInvariant()); }
private static string GetRequiresUTF8ContentEncoding(DeviceInfo device) { string value = Strings.Get(device.GetCapability(Utf8Support)); if (String.IsNullOrEmpty(value) || value.Equals("false", StringComparison.InvariantCultureIgnoreCase)) { return(bool.FalseString.ToLowerInvariant()); } return(bool.TrueString.ToLowerInvariant()); }
private static string GetRendersBreaksAfterWmlAnchor(DeviceInfo device) { string value = Strings.Get(device.GetCapability(BreakListOfLinksWithBrElementRecommended)); if (String.IsNullOrEmpty(value) || value.Equals("false", StringComparison.InvariantCultureIgnoreCase)) { return(bool.FalseString.ToLowerInvariant()); } return(bool.TrueString.ToLowerInvariant()); }
/// <summary> /// Returns true if the device supports callbacks from the browser /// using XMLHttpRequest using any type of method. /// </summary> /// <param name="device">The device to be checked.</param> /// <returns>True if XMLHttpRequest is supported.</returns> private static string GetSupportsCallback(DeviceInfo device) { string value = Strings.Get(device.GetCapability(AjaxXhrType)); if (String.IsNullOrEmpty(value) || value.Equals("none", StringComparison.InvariantCultureIgnoreCase)) { return(bool.FalseString.ToLowerInvariant()); } return(bool.TrueString.ToLowerInvariant()); }
/// <summary> /// If the wurfl database indicates javascript support then return true. /// </summary> /// <param name="device">The device to be checked.</param> /// <returns>True if javascript is supported.</returns> private static bool GetJavascriptSupport(DeviceInfo device) { bool java = false; if (bool.TryParse(Strings.Get(device.GetCapability(AjaxSupportJavascript)), out java) && java) { return(true); } return(false); }
private static string GetCookieSupport(DeviceInfo device, string current) { bool value = false; // Return either the capability or the current value as a boolean string. if (bool.TryParse(Strings.Get(device.GetCapability(CookieSupport)), out value) == false) { bool.TryParse(current, out value); } return(value.ToString()); }
private static string GetSupportsImageSubmit(DeviceInfo device) { int value = 0; if (int.TryParse(Strings.Get(device.GetCapability(XhtmlSupportLevel)), out value) && value >= 3) { return(bool.TrueString.ToLowerInvariant()); } return(bool.FalseString.ToLowerInvariant()); }
/// <summary> /// Gets the capability value index in the static Strings collection for this device /// based on the index of the capability name. /// </summary> /// <param name="index">Capability name index.</param> /// <returns>Capability index value in the String collection, or -1 if the capability does not exist.</returns> internal int GetCapability(int index) { if (_deviceCapabilities.ContainsKey(index)) { return(_deviceCapabilities[index]); } if (_fallbackDevice != null) { return(_fallbackDevice.GetCapability(index)); } return(-1); }
private static string GetPreferredRenderingMimeFromWURFL(DeviceInfo device, string renderingType) { switch (renderingType) { case "xhtml-mp": case "xhtml-basic": return(Strings.Get(device.GetCapability(XhtmlmpPreferredMimeType))); case "chtml10": case "html4": case "html32": return("text/html"); default: return(null); } }
private static string GetW3CDOMVersion(DeviceInfo device, string current) { int level = 0; Version version = new Version(0, 0); if (int.TryParse(Strings.Get(device.GetCapability(XhtmlSupportLevel)), out level) && level >= 4) { version = new Version("1.0.0.0"); } else { try { version = new Version(current); } catch (ArgumentException) { // Do nothing and let the default value be returned. } } return(version.ToString(2)); }
/// <summary> /// Creates a SortedList of capability names and values for the device. /// </summary> /// <param name="device"></param> /// <returns></returns> private static SortedList <string, string> CreateWurflCapabilities(DeviceInfo device) { var capabilities = new SortedList <string, string>(); // Get the list of capability names for the device. List <int> names = new List <int>(); AddWurflCapabilityNames(names, device); // Add the device id even thought his is not a capability. It // may be used by some applications. capabilities.Add("deviceid", device.DeviceId); // Add the actualDeviceRoot value as it is needed by some developers. capabilities.Add("actual_device_root", device.IsActualDeviceRoot.ToString()); // Add all the capabilities for the device. foreach (int name in names) { capabilities[Strings.Get(name)] = Strings.Get(device.GetCapability(name)); } return(capabilities); }
//The following methods and bindings were suggested by forum member 'fravelgue' private static string GetMaximumSoftKeyLabelLength(DeviceInfo device) { string value = Strings.Get(device.GetCapability(SoftkeySupport)); if (String.IsNullOrEmpty(value) || value.Equals("false", StringComparison.InvariantCultureIgnoreCase)) return bool.FalseString.ToLowerInvariant(); return bool.TrueString.ToLowerInvariant(); }
/// <summary> /// If the wurfl database indicates javascript support then return true. /// </summary> /// <param name="device">The device to be checked.</param> /// <returns>True if javascript is supported.</returns> private static bool GetJavascriptSupport(DeviceInfo device) { bool java = false; if (bool.TryParse(Strings.Get(device.GetCapability(AjaxSupportJavascript)), out java) && java) { return true; } return false; }
private static string GetSupportsAccesskeyAttribute(DeviceInfo device) { return(Strings.Get(device.GetCapability(AccessKeySupport))); }
private static string GetMobileDeviceManufacturer(DeviceInfo device) { return(Strings.Get(device.GetCapability(BrandName))); }
private static string GetScreenCharactersHeight(DeviceInfo device) { return Strings.Get(device.GetCapability(Rows)); }
private static string GetPlatform(DeviceInfo device) { return Strings.Get(device.GetCapability(DeviceOs)); }
private static string GetSupportsImageSubmit(DeviceInfo device) { int value = 0; if (int.TryParse(Strings.Get(device.GetCapability(XhtmlSupportLevel)), out value) && value >= 3) return bool.TrueString.ToLowerInvariant(); return bool.FalseString.ToLowerInvariant(); }
private static string GetScreenCharactersHeight(DeviceInfo device) { return(Strings.Get(device.GetCapability(Rows))); }
private static string GetSupportsAccesskeyAttribute(DeviceInfo device) { return Strings.Get(device.GetCapability(AccessKeySupport)); }
/// <summary> /// Returns true if the device supports callbacks from the browser /// using XMLHttpRequest using any type of method. /// </summary> /// <param name="device">The device to be checked.</param> /// <returns>True if XMLHttpRequest is supported.</returns> private static string GetSupportsCallback(DeviceInfo device) { string value = Strings.Get(device.GetCapability(AjaxXhrType)); if (String.IsNullOrEmpty(value) || value.Equals("none", StringComparison.InvariantCultureIgnoreCase)) return bool.FalseString.ToLowerInvariant(); return bool.TrueString.ToLowerInvariant(); }
private static string GetScreenPixelsWidth(DeviceInfo device) { return Strings.Get(device.GetCapability(ResolutionWidth)); }
private static string GetScreenPixelsHeight(DeviceInfo device) { return Strings.Get(device.GetCapability(ResolutionHeight)); }
private static string GetScreenCharactersWidth(DeviceInfo device) { return Strings.Get(device.GetCapability(Columns)); }
private static string GetHasBackButton(DeviceInfo device) { return Strings.Get(device.GetCapability(BuiltInBackButtonSupport)); }
private static string GetTables(DeviceInfo device) { string value = Strings.Get(device.GetCapability(XhtmlTableSupport)); if(String.IsNullOrEmpty(value) || value.Equals("false", StringComparison.InvariantCultureIgnoreCase)) return bool.FalseString.ToLowerInvariant(); return bool.TrueString.ToLowerInvariant(); }
private static string GetCookieSupport(DeviceInfo device, string current) { bool value = false; // Return either the capability or the current value as a boolean string. if (bool.TryParse(Strings.Get(device.GetCapability(CookieSupport)), out value) == false) bool.TryParse(current, out value); return value.ToString(); }
private static string GetW3CDOMVersion(DeviceInfo device, string current) { int level = 0; Version version = new Version(0, 0); if (int.TryParse(Strings.Get(device.GetCapability(XhtmlSupportLevel)), out level) && level >= 4) version = new Version("1.0.0.0"); else { try { version = new Version(current); } catch (ArgumentException) { // Do nothing and let the default value be returned. } } return version.ToString(2); }
private static string GetMaximumRenderedPageSize(DeviceInfo device) { return(Strings.Get(device.GetCapability(MaxDeckSize))); }
/// <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="device">Device to use for enhancements.</param> private static void Enhance(IDictionary capabilities, IDictionary currentCapabilities, DeviceInfo device) { // Set base capabilities for all mobile devices. SetStaticValues(capabilities); SetValue(capabilities, "actualDeviceRoot", device.IsActualDeviceRoot.ToString()); SetValue(capabilities, "isMobileDevice", GetIsMobileDevice(device)); SetValue(capabilities, "crawler", GetIsCrawler(device)); SetValue(capabilities, "mobileDeviceModel", GetMobileDeviceModel(device)); SetValue(capabilities, "mobileDeviceManufacturer", GetMobileDeviceManufacturer(device)); SetValue(capabilities, "platform", GetPlatform(device)); SetValue(capabilities, "type", capabilities["mobileDeviceManufacturer"]); SetValue(capabilities, "supportsAccessKeyAttribute", GetSupportsAccesskeyAttribute(device)); SetValue(capabilities, "hasBackButton", GetHasBackButton(device)); SetValue(capabilities, "screenPixelsHeight", GetScreenPixelsHeight(device)); SetValue(capabilities, "screenPixelsWidth", GetScreenPixelsWidth(device)); SetValue(capabilities, "screenBitDepth", GetScreenBitDepth(device)); SetValue(capabilities, "preferredImageMime", GetPreferredImageMime(device, capabilities)); SetValue(capabilities, "isColor", GetIsColor(device)); SetValue(capabilities, "SupportsCallback", GetSupportsCallback(device)); SetValue(capabilities, "maximumRenderedPageSize", GetMaximumRenderedPageSize(device)); SetValue(capabilities, "rendersBreaksAfterWmlAnchor", GetRendersBreaksAfterWmlAnchor(device)); SetValue(capabilities, "rendersBreaksAfterWmlInput", GetRendersBreaksAfterWmlInput(device)); SetValue(capabilities, "screenCharactersHeight", GetScreenCharactersHeight(device)); SetValue(capabilities, "screenCharactersWidth", GetScreenCharactersWidth(device)); SetValue(capabilities, "requiresUTF8ContentEncoding", GetRequiresUTF8ContentEncoding(device)); SetValue(capabilities, "tables", GetTables(device)); SetValue(capabilities, "canInitiateVoiceCall", GetIsMobileDevice(device)); SetValue(capabilities, "javascript", GetJavascriptSupport(device)); SetValue(capabilities, "supportsNoWrapStyle", GetSupportsNoWrapStyle(device)); SetValue(capabilities, "supportsStyleElement", GetPreferredRenderingTypeFromWURFL(device)); SetValue(capabilities, "maximumSoftKeyLabelLength", GetMaximumSoftKeyLabelLength(device)); // Use the Version class to find the version. If this fails use the 1st two // decimal segments of the string. string versionString = Strings.Get(device.GetCapability(MobileBrowserVersion)); if (String.IsNullOrEmpty(versionString) == false) { try { Version version = new Version(versionString); SetValue(capabilities, "majorversion", version.Major.ToString()); SetValue(capabilities, "minorversion", "." + version.Minor.ToString()); SetValue(capabilities, "version", version.ToString()); } catch (FormatException) { SetVersion(capabilities, versionString); } catch (ArgumentException) { SetVersion(capabilities, versionString); } } else { // Ensure the version values are not null to prevent null arguement exceptions // with some controls. versionString = currentCapabilities != null ? currentCapabilities["version"] as string : "0.0"; SetVersion(capabilities, versionString); } SetValue(capabilities, "supportsImageSubmit", GetSupportsImageSubmit(device)); // All we can determine from WURFL is if javascript is supported as a boolean. // Use this value to set a version number that is the same for all devices that // indicate javascript support. bool javaScript = GetJavascriptSupport(device); SetJavaScript(capabilities, javaScript); SetValue(capabilities, "ecmascriptversion", javaScript ? "3.0" : "0.0"); SetValue(capabilities, "jscriptversion", javaScript ? "5.7" : "0.0"); SetValue(capabilities, "w3cdomversion", GetW3CDOMVersion(device, currentCapabilities != null ? (string) currentCapabilities["w3cdomversion"] : String.Empty)); SetValue(capabilities, "cookies", GetCookieSupport(device, currentCapabilities != null ? (string)currentCapabilities["cookies"] : String.Empty)); // Only set these values from WURFL if they've not already been set from // the Http request header. if (capabilities.Contains("preferredRenderingType") == false) { // Set the rendering type for the response. string renderingType = GetPreferredRenderingTypeFromWURFL(device); if (String.IsNullOrEmpty(renderingType) == false) SetValue(capabilities, "preferredRenderingType", renderingType); // Set the Mime type of the response. if (capabilities.Contains("preferredRenderingMime") == false) { string renderingMime = GetPreferredRenderingMimeFromWURFL(device, renderingType); if (String.IsNullOrEmpty(renderingMime) == false) SetValue(capabilities, "preferredRenderingMime", renderingMime); } } }
private static string GetScreenPixelsWidth(DeviceInfo device) { return(Strings.Get(device.GetCapability(ResolutionWidth))); }
/// <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="device">Device to use for enhancements.</param> private static void Enhance(IDictionary capabilities, IDictionary currentCapabilities, DeviceInfo device) { // Set base capabilities for all mobile devices. SetStaticValues(capabilities); SetValue(capabilities, "actualDeviceRoot", device.IsActualDeviceRoot.ToString()); SetValue(capabilities, "isMobileDevice", GetIsMobileDevice(device)); SetValue(capabilities, "crawler", GetIsCrawler(device)); SetValue(capabilities, "mobileDeviceModel", GetMobileDeviceModel(device)); SetValue(capabilities, "mobileDeviceManufacturer", GetMobileDeviceManufacturer(device)); SetValue(capabilities, "platform", GetPlatform(device)); SetValue(capabilities, "type", capabilities["mobileDeviceManufacturer"]); SetValue(capabilities, "supportsAccessKeyAttribute", GetSupportsAccesskeyAttribute(device)); SetValue(capabilities, "hasBackButton", GetHasBackButton(device)); SetValue(capabilities, "screenPixelsHeight", GetScreenPixelsHeight(device)); SetValue(capabilities, "screenPixelsWidth", GetScreenPixelsWidth(device)); SetValue(capabilities, "screenBitDepth", GetScreenBitDepth(device)); SetValue(capabilities, "preferredImageMime", GetPreferredImageMime(device, capabilities)); SetValue(capabilities, "isColor", GetIsColor(device)); SetValue(capabilities, "SupportsCallback", GetSupportsCallback(device)); SetValue(capabilities, "maximumRenderedPageSize", GetMaximumRenderedPageSize(device)); SetValue(capabilities, "rendersBreaksAfterWmlAnchor", GetRendersBreaksAfterWmlAnchor(device)); SetValue(capabilities, "rendersBreaksAfterWmlInput", GetRendersBreaksAfterWmlInput(device)); SetValue(capabilities, "screenCharactersHeight", GetScreenCharactersHeight(device)); SetValue(capabilities, "screenCharactersWidth", GetScreenCharactersWidth(device)); SetValue(capabilities, "requiresUTF8ContentEncoding", GetRequiresUTF8ContentEncoding(device)); SetValue(capabilities, "tables", GetTables(device)); SetValue(capabilities, "canInitiateVoiceCall", GetIsMobileDevice(device)); SetValue(capabilities, "javascript", GetJavascriptSupport(device)); SetValue(capabilities, "supportsNoWrapStyle", GetSupportsNoWrapStyle(device)); SetValue(capabilities, "supportsStyleElement", GetPreferredRenderingTypeFromWURFL(device)); SetValue(capabilities, "maximumSoftKeyLabelLength", GetMaximumSoftKeyLabelLength(device)); // Use the Version class to find the version. If this fails use the 1st two // decimal segments of the string. string versionString = Strings.Get(device.GetCapability(MobileBrowserVersion)); if (String.IsNullOrEmpty(versionString) == false) { try { Version version = new Version(versionString); SetValue(capabilities, "majorversion", version.Major.ToString()); SetValue(capabilities, "minorversion", "." + version.Minor.ToString()); SetValue(capabilities, "version", version.ToString()); } catch (FormatException) { SetVersion(capabilities, versionString); } catch (ArgumentException) { SetVersion(capabilities, versionString); } } else { // Ensure the version values are not null to prevent null arguement exceptions // with some controls. versionString = currentCapabilities != null ? currentCapabilities["version"] as string : "0.0"; SetVersion(capabilities, versionString); } SetValue(capabilities, "supportsImageSubmit", GetSupportsImageSubmit(device)); // All we can determine from WURFL is if javascript is supported as a boolean. // Use this value to set a version number that is the same for all devices that // indicate javascript support. bool javaScript = GetJavascriptSupport(device); SetJavaScript(capabilities, javaScript); SetValue(capabilities, "ecmascriptversion", javaScript ? "3.0" : "0.0"); SetValue(capabilities, "jscriptversion", javaScript ? "5.7" : "0.0"); SetValue(capabilities, "w3cdomversion", GetW3CDOMVersion(device, currentCapabilities != null ? (string)currentCapabilities["w3cdomversion"] : String.Empty)); SetValue(capabilities, "cookies", GetCookieSupport(device, currentCapabilities != null ? (string)currentCapabilities["cookies"] : String.Empty)); // Only set these values from WURFL if they've not already been set from // the Http request header. if (capabilities.Contains("preferredRenderingType") == false) { // Set the rendering type for the response. string renderingType = GetPreferredRenderingTypeFromWURFL(device); if (String.IsNullOrEmpty(renderingType) == false) { SetValue(capabilities, "preferredRenderingType", renderingType); } // Set the Mime type of the response. if (capabilities.Contains("preferredRenderingMime") == false) { string renderingMime = GetPreferredRenderingMimeFromWURFL(device, renderingType); if (String.IsNullOrEmpty(renderingMime) == false) { SetValue(capabilities, "preferredRenderingMime", renderingMime); } } } }
private static string GetHasBackButton(DeviceInfo device) { return(Strings.Get(device.GetCapability(BuiltInBackButtonSupport))); }
private static string GetRequiresUTF8ContentEncoding(DeviceInfo device) { string value = Strings.Get(device.GetCapability(Utf8Support)); if (String.IsNullOrEmpty(value) || value.Equals("false", StringComparison.InvariantCultureIgnoreCase)) return bool.FalseString.ToLowerInvariant(); return bool.TrueString.ToLowerInvariant(); }
private static string GetMobileDeviceModel(DeviceInfo device) { string value = Strings.Get(device.GetCapability(MarketingName)); if (String.IsNullOrEmpty(value)) value = Strings.Get(device.GetCapability(ModelName)); return value; }
private static string GetRendersBreaksAfterWmlInput(DeviceInfo device) { string value = Strings.Get(device.GetCapability(InsertBrElementAfterWidgetRecommended)); if (String.IsNullOrEmpty(value) || value.Equals("false", StringComparison.InvariantCultureIgnoreCase)) return bool.FalseString.ToLowerInvariant(); return bool.TrueString.ToLowerInvariant(); }
private static string GetMobileDeviceManufacturer(DeviceInfo device) { return Strings.Get(device.GetCapability(BrandName)); }
private static string GetPreferredRenderingTypeFromWURFL(DeviceInfo device) { switch (Strings.Get(device.GetCapability(PreferredMarkup))) { case "html_web_3_2": return "html32"; case "html_web_4_0": return "html4"; case "html_wi_oma_xhtmlmp_1_0": return "xhtml-mp"; case "html_wi_w3_xhtmlbasic": return "xhtml-basic"; case "html_wi_imode_htmlx_1": case "html_wi_imode_html_1": case "html_wi_imode_html_2": case "html_wi_imode_html_3": case "html_wi_imode_html_4": case "html_wi_imode_html_5": case "html_wi_imode_html_6": case "html_wi_imode_htmlx_1_1": case "html_wi_imode_compact_generic": return "chtml10"; default: return GetFirstRenderingTypeFromWURFL(device); } }
private static string GetMaximumRenderedPageSize(DeviceInfo device) { return Strings.Get(device.GetCapability(MaxDeckSize)); }
private static string GetPreferredRenderingMimeFromWURFL(DeviceInfo device, string renderingType) { switch (renderingType) { case "xhtml-mp": case "xhtml-basic": return Strings.Get(device.GetCapability(XhtmlmpPreferredMimeType)); case "chtml10": case "html4": case "html32": return "text/html"; default: return null; } }
private static string GetIsColor(DeviceInfo device) { long numberOfColors = 0; long.TryParse(Strings.Get(device.GetCapability(Colors)), out numberOfColors); bool isColor = (numberOfColors >= 256); return isColor.ToString(CultureInfo.InvariantCulture); }
private static string GetPreferredImageMime(DeviceInfo device, IDictionary capabilities) { // Look at the database and return the 1st one that matches in order // of preference. if (bool.TrueString.Equals(Strings.Get(device.GetCapability(Png)), StringComparison.InvariantCultureIgnoreCase)) return "image/png"; if (bool.TrueString.Equals(Strings.Get(device.GetCapability(Jpg)), StringComparison.InvariantCultureIgnoreCase)) return "image/jpeg"; if (bool.TrueString.Equals(Strings.Get(device.GetCapability(Gif)), StringComparison.InvariantCultureIgnoreCase)) return "image/gif"; return null; }
private static string GetFirstRenderingTypeFromWURFL(DeviceInfo device) { // The value returned when checking the capability. bool value; // Look at all the possible markups that could be supported // and returned the 1st one found. if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWiOmaXhtmlmp10)), out value) && value) return "xhtml-mp"; if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWiW3Xhtmlbasic)), out value) && value) return "xhtml-basic"; if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWiImodeCompactGeneric)), out value) && value) return "chtml10"; if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWeb40)), out value) && value) return "html32"; if (bool.TryParse(Strings.Get(device.GetCapability(HtmlWeb32)), out value) && value) return "html32"; return null; }
private static string GetPlatform(DeviceInfo device) { return(Strings.Get(device.GetCapability(DeviceOs))); }
private static string GetScreenCharactersWidth(DeviceInfo device) { return(Strings.Get(device.GetCapability(Columns))); }
private static string GetAdapters(DeviceInfo device) { return(Strings.Get(device.GetCapability(Adapters))); }
private static string GetAdapters(DeviceInfo device) { return Strings.Get(device.GetCapability(Adapters)); }
private static string GetScreenPixelsHeight(DeviceInfo device) { return(Strings.Get(device.GetCapability(ResolutionHeight))); }
/// <summary> /// Creates a SortedList of capability names and values for the device. /// </summary> /// <param name="device"></param> /// <returns></returns> private static SortedList<string, string> CreateWurflCapabilities(DeviceInfo device) { var capabilities = new SortedList<string, string>(); // Get the list of capability names for the device. List<int> names = new List<int>(); AddWurflCapabilityNames(names, device); // Add the device id even thought his is not a capability. It // may be used by some applications. capabilities.Add("deviceid", device.DeviceId); // Add the actualDeviceRoot value as it is needed by some developers. capabilities.Add("actual_device_root", device.IsActualDeviceRoot.ToString()); // Add all the capabilities for the device. foreach (int name in names) capabilities[Strings.Get(name)] = Strings.Get(device.GetCapability(name)); return capabilities; }
private static string GetScreenBitDepth(DeviceInfo device) { long fScreenBitDepth = 1; long numberOfColors = 256; long.TryParse(Strings.Get(device.GetCapability(Colors)), out numberOfColors); fScreenBitDepth = Support.GetBitsPerPixel(numberOfColors); return fScreenBitDepth.ToString(CultureInfo.InvariantCulture); }