String Control
using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//using Microsoft.TeamFoundation.WorkItemTracking.Controls;
//
namespace COMP
{
/// <summary>
/// 字符串操作
/// </summary>
public class StringControl
{ /// <summary>
/// 客户端浏览器
///涂聚文
///2009-08-08
/// </summary>
/// <param name="strClient">客户端环境</param>
/// <param name="ver">浏览器版</param>
/// <returns>返回浏览器名称</returns>
public string getBrowser(string strClient, out string ver)
{
//Camino
string strBrowser = null;
if (strClient.Contains("MSIE") == true)
{
strBrowser = "Internet Explorer";
ver = getIEVer(strClient);
}
else if (strClient.Contains("Opera") == true)
{
strBrowser = "Opera";
ver = getBrowserVer(strClient, "Version");
}
else if (strClient.Contains("Camino") == true)//有待验证
{
strBrowser = "Camino";
ver = getBrowserVer(strClient, "Version");
}
else if ((strClient.Contains("Firefox") == true) && (strClient.Contains("Chrome") == false) && (strClient.Contains("Safari") == false) && (strClient.Contains("Navigator") == false))
{
strBrowser = "FireFox";
ver = getBrowserVer(strClient, "Firefox"); }
else if ((strClient.Contains("AppleWebKit") == true) && (strClient.Contains("Chrome") == true) && (strClient.Contains("Safari") == true) && (strClient.Contains("Flock") == false))
{
strBrowser = "Google Chrome";
ver = getBrowserVer(strClient, "Chrome");
}
else if ((strClient.Contains("Firefox") == true) && (strClient.Contains("Chrome") == false) && (strClient.Contains("Safari") == false) && (strClient.Contains("Navigator") == true))
{
strBrowser = "Netscape Navigator";
ver = getBrowserVer(strClient, "Navigator");
}
else if ((strClient.Contains("AppleWebKit") == true) && (strClient.Contains("Flock") == true) && (strClient.Contains("Chrome") == true) && (strClient.Contains("Safari") == true))
{
strBrowser = "Flock";
ver = getBrowserVer(strClient, "Flock");
}
else if ((strClient.Contains("AppleWebKit") == true) && (strClient.Contains("Chrome") == false) && (strClient.Contains("Safari") == true))
{
strBrowser = "Safari";
ver = getBrowserVer(strClient, "Version");
}
else
{
strBrowser = "NoData";
ver = "NoData";
}
return strBrowser;
}
/// <summary>
/// 客户端操作系统
/// </summary>
/// <param name="strClient">客户端环境</param>
/// <returns>返回操作系统名称</returns>
public string getPlatform(string strClient)
{
string OpertorSystem =String.Empty; if (strClient.Contains("Mac") == true)
{
return OpertorSystem = "Mac";
}
else if (strClient.Contains("Unix") == true)
{
return OpertorSystem = "Unix";
}
else if (strClient.Contains("Linux") == true)
{
return OpertorSystem = "Linux";
}
else if (strClient.Contains("SunOS") == true)
{
return OpertorSystem = "SunOS";
}
else if (strClient.Contains("Windows NT 3.1") == true)
{
return OpertorSystem = "Windows NT 3.1";
} else if (strClient.Contains("Windows NT 3.5") == true)
{
return OpertorSystem = "Windows NT 3.5";
}
else if (strClient.Contains("Windows NT 3.51") == true)
{
return OpertorSystem = "Windows NT 3.51";
}
else if (strClient.Contains("Windows NT 4.0") == true)
{
return OpertorSystem = "Windows NT 4.0";
}
else if (strClient.Contains("95") == true)
{
return OpertorSystem = "Windows 95";
}
else if (strClient.Contains("Me") == true)
{
return OpertorSystem = "Windows Me";
}
else if (strClient.Contains("98") == true)
{
return OpertorSystem = "Windows 98";
}
else if (strClient.Contains("Windows NT 5.0") == true)
{
return OpertorSystem = "Windows 2000";
}
else if (strClient.Contains("Windows NT 5.1") == true)
{
return OpertorSystem = "Windows XP/Windows Fundamentals";
}
else if (strClient.Contains("Windows NT 5.2") == true)
{
return OpertorSystem = "Windows Server 2003/Windows Home Server";
}
else if (strClient.Contains("Windows NT 6.0") == true)
{
return OpertorSystem = "Windows Vista/Windows Server 2008";
} else if (strClient.Contains("Windows NT 6.1") == true)
{
return OpertorSystem = "Windows 7/ Windows Server 2008 R2";
}
else
{
return OpertorSystem = "NoData";
}
//OpertorSystem;
}
/// <summary>
/// IE
/// </summary>
/// <param name="strClient"></param>
/// <returns></returns>
private string getIEVer(string strClient)
{
string ver = string.Empty;
if (strClient.Contains("MSIE 9.0") == true)
{
return ver = "9.0";
}
if (strClient.Contains("MSIE 8.0") == true)
{
return ver = "8.0";
}
else if (strClient.Contains("MSIE 7.0") == true)
{
return ver = "7.0";
}
else if (strClient.Contains("MSIE 6.0") == true)
{
return ver = "6.0";
}
else if (strClient.Contains("MSIE 5.0") == true)
{
return ver = "5.0";
}
else
{
return ver = "1.0";
} }
/// <summary>
/// 得到版本
/// </summary>
/// <param name="strClient">客户端环境</param>
/// <param name="browere">浏览器名称</param>
/// <returns>返回版本号</returns>
private string getBrowserVer(string strClient, string browere)
{
string ver = string.Empty;
string[] words = strClient.Split(' ');
string browsername = string.Empty;
foreach (string word in words)
{
if (word.Contains(browere) == true)
{
browsername = word;
}
//Response.Write(word + "<br/>");
}
//Response.Write("浏览器名称及版本:" + browsername + "<br>");
string strnamd = "";
//string strver = "";
string[] wd = browsername.Split('/');
foreach (string nd in wd)
{
if (nd.Contains(browere) == true)
{
strnamd = nd;
}
else
{
ver = nd;
}
}
return ver;
}
/// <summary>
/// 浏览器语言
/// </summary>
/// <param name="strClicent">客户端环境</param>
/// <returns>返回浏览语言</returns>
public string getBrowserLanguage(string strClicent)
{
//zh-tw Chinese (Taiwan) zh-cn Chinese (PRC)
//zh-hk Chinese (Hong Kong SAR) zh-sg Chinese (Singapore) string BroswerLanguage = string.Empty;
strClicent = strClicent.ToLower();
if (strClicent.Contains("zh-cn") == true)
{
return BroswerLanguage = "zh-cn";
}
if (strClicent.Contains("zh-tw") == true)
{
return BroswerLanguage = "zh-tw";
}
if (strClicent.Contains("zh-hk") == true)
{
return BroswerLanguage = "zh-hk";
}
if (strClicent.Contains("zh-sg") == true)
{
return BroswerLanguage = "zh-sg";
}
else if (strClicent.Contains("en-us") == true)
{
return BroswerLanguage = "en-US";
}
else
{
return BroswerLanguage = "NoData";
} }
}
}
String Control的更多相关文章
- mobileControls与移动控件适配
此配置节的作用在于指定各种控件在不同类型的移动设备显示的适配器,以达到适应各种设备不同的展示形式.例子如下, <mobileControls sessionStateHistorySize=&q ...
- 以小时候玩的贪吃蛇为例,对于Java图像界面的学习感悟
简介 正文 01.JFrame是啥? 02.JPanel 03. KeyListener 04.Runnable 05.游戏Running 06.游戏初始类编写 07.main 简介: 一直以来用代码 ...
- 插件开发-UI插件开发
1.新建类库解决方案,引入命名空间,同时引入要添加UI Form的WebPart(在Portal\UILib目录下) 2.继续UFSoft.UBF.UI.Custom.ExtendedPartBase ...
- UI Automation Test
UI Automation test is based on the windows API. U can find the UI Automation MSDN file from http://m ...
- 大型B2B网站开发手记 2
刚开始做功能的时候,发现有个“面包屑”导航的功能穿插到了所有的页面.这个看似不起眼的小功能以前没有注意过,现在决定来实现一下 所谓面包屑,即页面层级导航,例如 首页>>我的博客>&g ...
- 030医疗项目-模块三:药品供应商目录模块——供货商药品目录查询功能----------Dao层:基本的查询语句的编写
我们安装显示的要求: 我们能看到显示的目录里面有:供货企业的名字(这个数据来自于供货商的表[usergys]),流水号,通用名,剂型(这些都来自药品信息表),供货的状态(这个呢在gysypml_con ...
- ASP.NET MVC 自己实现登陆验证过滤器
1.首先添加一个过滤器类,并实现接口中对应的方法 public class YLFAuthorizeAttribute : FilterAttribute, IAuthorizationFilter ...
- MVC基础知识
1.View中获取Control和View: //获取控制器名称: ViewContext.RouteData.Values["controller"].ToString(); / ...
- angularjs + seajs构建Web Form前端(三) -- 兼容easyui
回顾 在上一章中使用了angular实现了ajax form和树形结构,经过以上两章对于angular的大致使用,对于angular也有了初步的认识,接下来的内容只会对angular的一些用法做简单的 ...
随机推荐
- 关于java中String的用法
在java 中String存在许多的基本函数,接下来了解一下这些函数的基本用法 String.equals用法(这个用法比较难) String类中的equals()方法: public boolean ...
- @functools.wrapes
保证被装饰函数的__name__属性不变
- codeforces1137B kmp(fail的妙用)
题目传送门 题意:给出$s$和$t$两个串,让你构造出一个答案串,使得答案串中的01数量和s一样,并且使$t$在答案串中作为子串出现次数最多. 思路: 要想出现的次数尽可能多,那么就要重复的利用,哪一 ...
- 剑指offer——面试题20:表示数值的字符串
#include"iostream" using namespace std; bool IsInt(const char **str); bool IsUnsignInt(con ...
- R 升级版本
从3.4.1 升级到最新 懒得去官网下载 在R studio 执行一下代码 install.packages("installr") library(installr) updat ...
- IE8 placeholder不支持的兼容性处理
引入 <script type="text/javascript" src="<%=path%>/common/js/jquery/jquery.min ...
- 文献综述十五:基于b/s中小型超市进销存管理系统的研究与设计
一.基本信息 标题:基于b/s中小型超市进销存管理系统的研究与设计 时间:2015 出版源:湘西财经大学 文件分类:对超市管理系统的研究 二.研究背景 在竞争日益激烈的行业中,尽可能降低运营成本,逐步 ...
- ngx_echo_module
https://github.com/openresty/echo-nginx-module echo $echo_request_body
- npm 包管理工具
能注册后看简单的功能 订单加信息 下单之前的判断要配合海潮的迁移数据 运行自定义的脚本 在 package.json 的 scripts 里添加自定义的结点 ( 比如 CSOR-serve ) &qu ...
- ubuntu 16.04 屏幕截图
shift+prtsc 快捷键截取指定区域的图片 类似qq截图