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


C# Web.HttpBrowserCapabilities类代码示例

本文整理汇总了C#中System.Web.HttpBrowserCapabilities的典型用法代码示例。如果您正苦于以下问题:C# HttpBrowserCapabilities类的具体用法?C# HttpBrowserCapabilities怎么用?C# HttpBrowserCapabilities使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


HttpBrowserCapabilities类属于System.Web命名空间,在下文中一共展示了HttpBrowserCapabilities类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HttpBrowserCapabilitiesWrapper

 public HttpBrowserCapabilitiesWrapper(HttpBrowserCapabilities httpBrowserCapabilities)
 {
     if (httpBrowserCapabilities == null) {
         throw new ArgumentNullException("httpBrowserCapabilities");
     }
     _browser = httpBrowserCapabilities;
 }
开发者ID:frenzypeng,项目名称:securityswitch,代码行数:7,代码来源:HttpBrowserCapabilitiesWrapper.cs

示例2: TestWebContext

        public TestWebContext(string virtualPath, string page)
        {
            _out = new StringWriter();
            HttpWorkerRequest wr;
            AppDomain domain = Thread.GetDomain();

            // are we running within a valid AspNet AppDomain?
            string appPath = (string) domain.GetData(".appPath");
            if (appPath != null)
            {
                wr = new SimpleWorkerRequest(page, string.Empty, _out);
            }
            else
            {
                appPath = domain.BaseDirectory + "\\";
                wr = new SimpleWorkerRequest(virtualPath, appPath, page, string.Empty, _out);
            }
            HttpContext ctx = new HttpContext(wr);
            HttpContext.Current = ctx;
            HttpBrowserCapabilities browser = new HttpBrowserCapabilities();
            browser.Capabilities = new CaseInsensitiveHashtable(); //CollectionsUtil.CreateCaseInsensitiveHashtable();
            browser.Capabilities[string.Empty] = "Test User Agent"; // string.Empty is the key for "user agent"

            // avoids NullReferenceException when accessing HttpRequest.FilePath
            object virtualPathObject = ExpressionEvaluator.GetValue(null, "T(System.Web.VirtualPath).Create('/')");
            object cachedPathData = ExpressionEvaluator.GetValue(null, "T(System.Web.CachedPathData).GetRootWebPathData()");
            ExpressionEvaluator.SetValue(cachedPathData, "_virtualPath", virtualPathObject);
            ExpressionEvaluator.SetValue(cachedPathData, "_physicalPath", appPath);

            ctx.Request.Browser = browser;
            string filePath = ctx.Request.FilePath;
            _wr = wr;
        }
开发者ID:spring-projects,项目名称:spring-net,代码行数:33,代码来源:TestWebContext.cs

示例3: FiftyOneBrowserCapabilities

 /// <summary>
 /// Constructs an instance of <cref see="FiftyOneBrowserCapabilities"/>
 /// </summary>
 public FiftyOneBrowserCapabilities(HttpBrowserCapabilities defaultBrowserCapabilities, HttpRequest request, Match match)
     : base()
 {
     _defaultBrowserCapabilities = defaultBrowserCapabilities;
     _request = request;
     _match = match;
 }
开发者ID:axle-h,项目名称:.NET-Device-Detection,代码行数:10,代码来源:FiftyOneBrowserCapabilities.cs

示例4: CreateHttpContext

        public static HttpContext CreateHttpContext()
        {
            HttpRequest request = new HttpRequest("", "http://localhost:19175/domain/", "p=1&n&=k");
            Hashtable browserCapabilities = new Hashtable { { "cookies", "true" } };
            HttpBrowserCapabilities browser = new HttpBrowserCapabilities();
            HttpResponse response = new HttpResponse(new StringWriter());
            HttpContext httpContext = new HttpContext(request, response);
            browser.Capabilities = browserCapabilities;
            request.Browser = browser;

            RouteValueDictionary routeValues = request.RequestContext.RouteData.Values;
            routeValues["area"] = "administration";
            routeValues["controller"] = "accounts";
            routeValues["action"] = "details";
            routeValues["language"] = "en";
            MapRoutes();

            IIdentity identity = Substitute.For<IIdentity>();
            identity.IsAuthenticated.Returns(true);
            identity.Name.Returns("1");

            httpContext.User = Substitute.For<IPrincipal>();
            httpContext.User.Identity.Returns(identity);

            return httpContext;
        }
开发者ID:vmpay,项目名称:VisualStudio,代码行数:26,代码来源:HttpContextFactory.cs

示例5: FiftyOneClientCapability

 /// <summary>
 /// Constructs a new instance of ClientCapability.
 /// See http://51degrees.mobi/Products/DeviceData/PropertyDictionary.aspx
 /// for a full list of available properties.
 /// All the properties used are non-lists and therefore the first
 /// item contained in the values list contains the only available value.
 /// </summary>
 public FiftyOneClientCapability(HttpBrowserCapabilities browserCaps)
 {
     if (browserCaps != null)
     {
         Initialise(browserCaps.Capabilities[Constants.FiftyOneDegreesProperties] as SortedList<string, string[]>);
     }
 }
开发者ID:revellado,项目名称:privateSocialGroups,代码行数:14,代码来源:FiftyOneClientCapability.cs

示例6: CreateSimulatedRequest

        private void CreateSimulatedRequest(Uri url)
        {
            var simulator = new Instance.Utilities.HttpSimulator.HttpSimulator();
            simulator.SimulateRequest(url);

            var browserCaps = new HttpBrowserCapabilities { Capabilities = new Hashtable() };
            HttpContext.Current.Request.Browser = browserCaps;
        }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:8,代码来源:UrlRewriteTests.cs

示例7: FiftyOneClientCapability

 /// <summary>
 /// Constructs a new instance of ClientCapability.
 /// See http://51degrees.mobi/Products/DeviceData/PropertyDictionary.aspx
 /// for a full list of available properties.
 /// All the properties used are non-lists and therefore the first
 /// item contained in the values list contains the only available value.
 /// </summary>
 public FiftyOneClientCapability(HttpBrowserCapabilities browserCaps)
 {
     if (browserCaps != null)
     {
         Initialise(
             browserCaps.Capabilities[FiftyOne.Foundation.Mobile.Detection.Constants.FiftyOneDegreesProperties] 
                 as SortedList<string, List<string>>);
     }
 }
开发者ID:hungnt-me,项目名称:Dnn.Platform,代码行数:16,代码来源:FiftyOneClientCapability.cs

示例8: CreateAsync

        public async Task CreateAsync(AuthenticationTokenCreateContext context)
        {
            try
            {
                var clientid = context.Ticket.Properties.Dictionary["as:client_id"];

                if (string.IsNullOrEmpty(clientid))
                    return;

                // Gera um ID unico para o RefreshToken
                var refreshTokenId = Guid.NewGuid().ToString("n");

                // Pega o tempo de expiração (em minuto) do token do contexto do Owin
                var refreshTokenLifeTime = context.OwinContext.Get<string>("as:clientRefreshTokenLifeTime");

                // Identifica o Browser
                var userAgent = HttpContext.Current.Request.UserAgent;
                var userBrowser = new HttpBrowserCapabilities { Capabilities = new Hashtable { { string.Empty, userAgent } } };
                var factory = new BrowserCapabilitiesFactory();
                factory.ConfigureBrowserCapabilities(new NameValueCollection(), userBrowser);
                var browser = userBrowser.Browser;

                var issuedUtc = DateTime.UtcNow;
                var expiresUtc = issuedUtc.AddMinutes(3); //issuedUtc.AddMonths(Convert.ToInt32(refreshTokenLifeTime));

                // Define os dados do RefreshToken
                var token = new RefreshToken
                {
                    Id = HashHelper.GetHash(refreshTokenId),
                    ClientId = clientid,
                    Browser = browser,
                    Subject = context.Ticket.Identity.Name,
                    IssuedUtc = issuedUtc,
                    ExpiresUtc = expiresUtc
                };

                // Define o IssuedUtc e o ExpiresUtc do ticket para determinar o quanto tempo o token vai ser válido
                context.Ticket.Properties.IssuedUtc = token.IssuedUtc;
                context.Ticket.Properties.ExpiresUtc = token.ExpiresUtc;

                // Serializa o ticket para ser gravado na base de dados
                var ticketSerializer = new TicketSerializer();
                token.ProtectedTicket = ticketSerializer.Serialize(context.Ticket);

                // Grava o ticket na base de dados
                var refreshTokenDomain = DependecyConfig.Container.GetInstance<IRefreshTokenDomain>();
                var result = await refreshTokenDomain.CreateAsync(token);

                if (result)
                    context.SetToken(refreshTokenId);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
开发者ID:TaigoSantos,项目名称:Visual-Studio,代码行数:56,代码来源:SimpleRefreshTokenProvider.cs

示例9: ShowInput

        /// <summary>
        /// Show list of input
        /// </summary>
        /// <param name="inputPlace1"> div of clolumn 1 </param>
        /// <param name="inputPlace2"> div of clolumn 2 </param>
        /// <param name="inputParam"> list of Parameter Object </param>
        /// <param name="browser"> Detect Browser </param>
        public static void ShowInput(PlaceHolder inputPlace1, PlaceHolder inputPlace2, List<AMLParam> inputParam, HttpBrowserCapabilities browser)
        {
            if (inputParam == null || inputParam.Count == 0)
            {
                inputPlace1.Controls.Add(new LiteralControl("<h3>No web service input</h3>"));
                return;
            }
            int count = 0;
            for (int i = 0; i < inputParam.Count; i++) //MLParameter param in inputParam)
            {
                Literal lcssFormGroup = new Literal();
                lcssFormGroup.Text = "<div class=\"form-group\">";
                Literal ldiv = new Literal();
                ldiv.Text = "</div>";

                AMLParam param = inputParam[i];
                Label lbl = new Label();
                if(string.IsNullOrEmpty(param.Alias))
                    lbl.Text = textInfo.ToTitleCase(param.Name);
                else lbl.Text = textInfo.ToTitleCase(param.Alias);
                lbl.ID = "lbl" + param + count++;
                lbl.Attributes.Add("Class", "fieldname");

                int numberOnPlace1 = inputParam.Count / 2;
                if(inputPlace2 == null)
                {
                    numberOnPlace1 = inputParam.Count;
                }

                if (i <= numberOnPlace1)
                {
                    inputPlace1.Controls.Add(lcssFormGroup);
                    inputPlace1.Controls.Add(lbl);

                    foreach (var control in GenerateInputControl(param, browser))
                    {
                        inputPlace1.Controls.Add(control);
                    }

                    if (!string.IsNullOrEmpty(param.Description)) inputPlace1.Controls.Add(new LiteralControl(string.Format("<div style=\"width=:100%\"><samp>{0}</samp></div>", param.Description)));
                    inputPlace1.Controls.Add(ldiv);

                }
                else
                {
                    inputPlace2.Controls.Add(lcssFormGroup);
                    inputPlace2.Controls.Add(lbl);
                    foreach (var control in GenerateInputControl(param, browser))
                    {
                        inputPlace2.Controls.Add(control);
                    }
                    if (!string.IsNullOrEmpty(param.Description)) inputPlace2.Controls.Add(new LiteralControl(string.Format("<div style=\"width=:100%\"><samp>{0}</samp></div>", param.Description)));
                    inputPlace2.Controls.Add(ldiv);
                }
            }
        }
开发者ID:raymondlaghaeian,项目名称:AzureML_BES_App_Template,代码行数:63,代码来源:GenerateControl+(KadenD1's+conflicted+copy+2015-08-07).cs

示例10: BrowserCap

 /// <summary>
 /// Returns a HttpBrowserCapabilities object from a UserAgent string
 /// </summary>
 /// <param name="userAgent">UserAgent from Browser</param>
 public BrowserCap(string userAgent)
 {
     var browser = new HttpBrowserCapabilities
     {
         Capabilities = new Hashtable { { string.Empty, userAgent } }
     };
     var factory = new BrowserCapabilitiesFactory();
     factory.ConfigureBrowserCapabilities(new NameValueCollection(), browser);
     Browser = browser;
 }
开发者ID:stwehrli,项目名称:IOnEx,代码行数:14,代码来源:BrowserCap.cs

示例11: GetClientBrowser

        public static HttpBrowserCapabilities GetClientBrowser(this string useragent)
        {
            var browser = new HttpBrowserCapabilities
            {
                Capabilities = new Hashtable { { string.Empty, useragent } }
            };
            var factory = new BrowserCapabilitiesFactory();
            factory.ConfigureBrowserCapabilities(new NameValueCollection(), browser);

            return browser;
        }
开发者ID:jsouthron,项目名称:nosql,代码行数:11,代码来源:StateDictionary.cs

示例12: GetBrowserCapabilities

        /// <summary>
        /// Gets the browser capabilities.
        /// </summary>
        /// <param name="userAgent">The user agent.</param>
        /// <param name="headers">The headers.</param>
        /// <returns></returns>
        public HttpBrowserCapabilities GetBrowserCapabilities(string userAgent, NameValueCollection headers)
        {
            HttpBrowserCapabilities browserCaps = new HttpBrowserCapabilities();
            Hashtable hashtable = new Hashtable(180, StringComparer.OrdinalIgnoreCase);
            hashtable[string.Empty] = userAgent; // The actual method uses client target
            browserCaps.Capabilities = hashtable;

            var capsFactory = new System.Web.Configuration.BrowserCapabilitiesFactory();
            capsFactory.ConfigureBrowserCapabilities(headers, browserCaps);
            capsFactory.ConfigureCustomCapabilities(headers, browserCaps);
            return browserCaps;
        }
开发者ID:NoCodeMonkey,项目名称:BrowserCompatibility,代码行数:18,代码来源:Default.aspx.cs

示例13: GetConfigCapabilities

		public static HttpCapabilitiesBase GetConfigCapabilities (string configKey, HttpRequest request)
		{
			string ua = request.ClientTarget;
			if (ua == null)
				ua = request.UserAgent;

			HttpBrowserCapabilities bcap = new HttpBrowserCapabilities ();
			bcap.useragent = ua;
			bcap.capabilities = CapabilitiesLoader.GetCapabilities (ua);
			bcap.Init ();
			return bcap;
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:12,代码来源:HttpCapabilitiesBase.cs

示例14: EnhancedCapabilities

        /// <summary>
        /// Creates a dictionary of capabilites for the requesting device based on both the 
        /// current capabilities assigned by Microsoft, and the results from 51Degrees.
        /// </summary>
        /// <param name="results">The detection results.</param>
        /// <param name="currentCapabilities">The current capabilities assigned by .NET.</param>
        /// <returns>A dictionary of capabilities for the request.</returns>
        internal static IDictionary EnhancedCapabilities(SortedList<string, string[]> results, HttpBrowserCapabilities currentCapabilities)
        {
            // Use the base class to create the initial list of capabilities.
            IDictionary capabilities = new Hashtable();

            // Add the capabilities for the device.
            EnhancedCapabilities(results, capabilities, currentCapabilities);

            // Initialise any capability values that rely on the settings
            // from the device data source.
            Init(capabilities);

            return capabilities;
        }
开发者ID:51Degrees,项目名称:dotNET-Device-Detection,代码行数:21,代码来源:MobileCapabilitiesOverride.cs

示例15: GetHttpBrowserCapabilitiesPropertyValue

        /// <summary>
        /// Checks the properties of the HttpBrowserCapabilities instance passed
        /// into the method for the property name contained in the property parameters
        /// string value.
        /// </summary>
        /// <param name="property">Property name to be found.</param>
        /// <param name="capabilities">Capabilities collection to be used.</param>
        /// <returns>If the property exists then return the associated value, otherwise null.</returns>
        private static string GetHttpBrowserCapabilitiesPropertyValue(string property, HttpBrowserCapabilities capabilities)
        {
            Type controlType = capabilities.GetType();
            System.Reflection.PropertyInfo propertyInfo = controlType.GetProperty(property);
            if (propertyInfo != null && propertyInfo.CanRead)
                return propertyInfo.GetValue(capabilities, null).ToString();

            // Try browser capabilities next.
            string value = capabilities[property];
            if (value != null)
                return value;

            return null;
        }
开发者ID:51Degrees,项目名称:dotNET-Device-Detection,代码行数:22,代码来源:Filter.cs


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