public virtual FunctionalityInfo this[ClientAPI.ClientFunctionality functionality] { get { FunctionalityInfo _fInfo = null; foreach (FunctionalityInfo fInfo in List) { if (fInfo.Functionality == functionality) { _fInfo = fInfo; break; } } return(_fInfo); } set { bool bFound = false; foreach (FunctionalityInfo fInfo in List) { if (fInfo.Functionality == functionality) { //fInfo = value; bFound = true; break; } } if (!bFound) { throw new Exception("Item Not Found"); } } }
public static BrowserCaps GetBrowserCaps() { BrowserCaps objCaps = (BrowserCaps)(DataCache.GetCache(CLIENTAPI_CACHE_KEY)); FunctionalityInfo objFunc = null; if (objCaps == null) { string strPath = string.Empty; try { strPath = HttpContext.Current.Server.MapPath(ClientAPI.ScriptPath + "/ClientAPICaps.config"); } catch (Exception ex) { //ignore error - worried about people with reverse proxies and such... } if (File.Exists(strPath)) { objCaps = new BrowserCaps(); objCaps.Functionality = new FunctionalityCollection(); //Create a FileStream for the Config file FileStream objReader = new FileStream(strPath, FileMode.Open, FileAccess.Read, FileShare.Read); XPathDocument objDoc = new XPathDocument(objReader); foreach (XPathNavigator objNavFunc in objDoc.CreateNavigator().Select("//functionality")) { objFunc = new FunctionalityInfo(); objFunc.Functionality = (ClientAPI.ClientFunctionality)(Enum.Parse(typeof(ClientAPI.ClientFunctionality), objNavFunc.GetAttribute("nm", ""))); objFunc.Desc = objNavFunc.GetAttribute("desc", ""); objFunc.Supports = new BrowserCollection(); foreach (XPathNavigator objNavSupports in objNavFunc.CreateNavigator().Select("supports/browser")) { objFunc.Supports.Add(GetBrowser(objNavSupports)); } objFunc.Excludes = new BrowserCollection(); foreach (XPathNavigator objNavExcludes in objNavFunc.CreateNavigator().Select("excludes/browser")) { objFunc.Excludes.Add(GetBrowser(objNavExcludes)); } objCaps.Functionality.Add(objFunc); } //Close the Reader objReader.Close(); // Set back into Cache DataCache.SetCache(CLIENTAPI_CACHE_KEY, objCaps, new CacheDependency(strPath)); } } return(objCaps); }
/// <summary> /// Determines of browser currently requesting page adaquately supports passed un client-side functionality /// </summary> /// <param name="eFunctionality">Desired Functionality</param> /// <returns>True when browser supports it</returns> /// <remarks> /// </remarks> /// <history> /// [Jon Henning] 8/3/2004 Created /// </history> public static bool BrowserSupportsFunctionality(ClientFunctionality eFunctionality) { if (HttpContext.Current == null) { return(true); } bool blnSupports = false; if (ClientAPIDisabled() == false) { BrowserCaps objCaps = BrowserCaps.GetBrowserCaps(); if (objCaps != null) { HttpRequest objRequest = HttpContext.Current.Request; string strUserAgent = objRequest.UserAgent; // HACK : Modified to not error if object is null. //if (strUserAgent.Length > 0) if (!String.IsNullOrEmpty(strUserAgent)) { //First check whether we have checked this browser before if (objCaps.FunctionalityDictionary.ContainsKey(strUserAgent) == false) { string strBrowser = objRequest.Browser.Browser; double dblVersion = Convert.ToDouble(objRequest.Browser.MajorVersion + objRequest.Browser.MinorVersion); int iBitValue = 0; FunctionalityInfo objFuncInfo = null; //loop through all functionalities for this UserAgent and determine the bitvalue foreach (ClientFunctionality eFunc in Enum.GetValues(typeof(ClientFunctionality))) { objFuncInfo = objCaps.Functionality[eFunc]; if (objFuncInfo.HasMatch(strUserAgent, strBrowser, dblVersion)) { iBitValue += (int)eFunc; } } objCaps.FunctionalityDictionary[strUserAgent] = iBitValue; } blnSupports = (((int)(objCaps.FunctionalityDictionary[strUserAgent])) & (int)eFunctionality) != 0; } } } return(blnSupports); }
public static BrowserCaps GetBrowserCaps() { BrowserCaps objCaps = (BrowserCaps)(DataCache.GetCache(CLIENTAPI_CACHE_KEY)); FunctionalityInfo objFunc = null; if (objCaps == null) { string strPath = string.Empty; try { strPath = HttpContext.Current.Server.MapPath(ClientAPI.ScriptPath + "/ClientAPICaps.config"); } catch (Exception ex) { //ignore error - worried about people with reverse proxies and such... } if (File.Exists(strPath)) { objCaps = new BrowserCaps(); objCaps.Functionality = new FunctionalityCollection(); //Create a FileStream for the Config file FileStream objReader = new FileStream(strPath, FileMode.Open, FileAccess.Read, FileShare.Read); XPathDocument objDoc = new XPathDocument(objReader); foreach (XPathNavigator objNavFunc in objDoc.CreateNavigator().Select("//functionality")) { objFunc = new FunctionalityInfo(); objFunc.Functionality = (ClientAPI.ClientFunctionality)(Enum.Parse(typeof(ClientAPI.ClientFunctionality), objNavFunc.GetAttribute("nm", ""))); objFunc.Desc = objNavFunc.GetAttribute("desc", ""); objFunc.Supports = new BrowserCollection(); foreach (XPathNavigator objNavSupports in objNavFunc.CreateNavigator().Select("supports/browser")) { objFunc.Supports.Add(GetBrowser(objNavSupports)); } objFunc.Excludes = new BrowserCollection(); foreach (XPathNavigator objNavExcludes in objNavFunc.CreateNavigator().Select("excludes/browser")) { objFunc.Excludes.Add(GetBrowser(objNavExcludes)); } objCaps.Functionality.Add(objFunc); } //Close the Reader objReader.Close(); // Set back into Cache DataCache.SetCache(CLIENTAPI_CACHE_KEY, objCaps, new CacheDependency(strPath)); } } return objCaps; }
public void Add( FunctionalityInfo f ) { InnerList.Add( f ); }
public void Add(FunctionalityInfo f) { InnerList.Add(f); }