百度360必应搜狗淘宝本站头条
当前位置:网站首页 > 技术文章 > 正文

ASP.NET原创框架八-应用模块常用重要类库介绍

ccwgpt 2024-10-30 01:42 19 浏览 0 评论

ASP.NET原创框架八-应用模块常用重要类库介绍

汉字转拼音类

public class ChineseToPinyin

汉字转拼音

一、static public string convertAllPinyin(string Chstr)

Chstr:要转的汉字字符串

返回转换后的拼音


压缩zip类

public class iZip

一、内存数据压缩

static public byte[] Compress(byte[] data, int offset, int length, int level)

data:要压缩的数据

offset:数据偏移位置

length:数据长度

level:压缩等级(1-9)

返回压缩的数据


二、内存数据解压

static public byte[] Decompress(byte[] data)

data:要解压的数据

返回解压后的数据


三、压缩串

static public byte[] CompressString(string str, Encoding enc/*=null*/, int level/*= 9*/)

str:压缩的串

enc:串编码格式

level:压缩等级

返回压缩后的数据


四、解压获得串

static public string DecompressString(byte[] data, Encoding enc)

data:压缩的数据

enc:串编码格式

返回解压后的串


五、快速压缩

static public void FastCreateZip(string zipPath, string folderPath, string fileFilter, string password)

zipPath:压缩文件

folderPath:要压缩的目录

fileFilter:要压缩的文件后缀

password:密码


六、快速解压

static public void FastExtractZip(string zipPath, string folderPath, string fileFilter, string password)

zipPath:压缩文件

folderPath:解压后释放的目录

fileFilter:要解压的文件后缀

password:密码


七、压缩文件夹

public static void CompressDirectory(string dirPath, string GzipFileName, int CompressionLevel, bool deleteDir)

dirPath:要打包的文件夹

GzipFileName:目标文件名

CompressionLeve:压缩品质级别(0~9)

deleteDir:是否删除原文件夹


八、解压缩文件

public static void Decompress(string GzipFile, string targetPath)

GzipFile:压缩包文件名

targetPath:解压缩目标路径


WebService调用类

WebServiceHelper

一、 动态调用WebService

public static object InvokeWebService(string url, string classname, string methodname, params object[] args)

url:WebService地址

classname:类名

methodname:方法名(模块名)

args:参数列表


Http客户端通用访问类

public partial class XNWindowHttpClient

一、清除post的header

public void ClearPostHeader()


二、添加一个header

public void AddHeader(string name,string value)

name:header名称

value:header值


三、清除状态

public void ClearSession()


四、设置自动跳转

public void SetAutoRedirect()


五、设置不自动跳转

public void SetNoAutoRedirect()


六、设置为手机端方式访问

public void SetIphone()


七、设置PC端访问方式

public void SetPC()


八、设置文本GB编码格式

public void SetGBCharset()


九、设置文本UTF8编码格式

public void SetUT8Charset()


十、添加一个cookie

public void AddCookie(string Name, string Value)

Name:要添加的cookie名称

Value:添加的cookie值


十一、添加一批cookie

public void AddCookies(List<Cookie> m_TCookieList)

m_TCookieList:cookie列表


十二、获得cookie串

public string GetCookie()


十三、获得header

public List<Hashtable> GetHeader()


十四、获得一个文件

public bool GetFile(string url, string Referer, string PathFile, string IP = null, int port = 0, string username = null, string pwd = null)

url:文件地址

Referer:访问前一个地址

PathFile:下载保存文件名

IP:代理IP地址(可不用代理)

username:代理用户名

pwd:代理用户密码


十五、获得一个文件

public bool GetFile(string url, string PathFile, string IP = null, int port = 0, string username = null, string pwd = null)

url:文件地址

PathFile:下载保存文件名

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


十六、一个Get请求

public string GetUrl(String url, string Referer, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

Referer:访问前一个地址

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Get请求的串


十七、一个Get请求

public string GetUrl(String url, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Get请求的串


十八、一个Form提交

public bool PostForm(String url, String sData, out string strResult, out string goUrl, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sData:Post的数据

strResult:Post返回的数据

goUrl:请求后跳转的页面

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


十九、Post数据

public string PostData(String url, String sData, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sData:Post的数据

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Post数据


二十、调用WCF

public string PostWCF(String url, String json, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

json:Post的json数据

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Post数据



二十一、PostJson

public string PostJson(String url, String sData, out bool bOK, string Referer = null, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sData:Post的json数据

bOK:返回执行是否成功

Referer:前一个访问地址

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码

返回Post数据



二十二、PostJson二

public bool PostReturnJson(String url, String sData, out string strResult, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sData:Post的json数据

strResult:返回Post数据

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


二十三、带证书的Post请求

public string HttpsPostUrl(string url, string sFormString, string sKeyFile, string sKeyPWD, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

sFormString:Post的数据

sKeyFile:证书文件

sKeyPWD:证书密码

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


二十四、下载文件

public bool DownFile(string sUrl, string FilePath, string IP = null, int port = 0, string username = null, string pwd = null)

url:访问地址

FilePath:下载保存的文件

IP:代理IP地址(可不用代理)

port:代理端口

username:代理用户名

pwd:代理用户密码


二十五、设置不使用全局代理

public void SetNoUseGlobalProxy()


二十六、设置使用全局代理

public void SetUseGlobalProxy()


二十七、设置不使用系统代理

static public void SetNoUseSysDefaultProxy()


二十八、设置使用系统代理

static public void SetUseSysDefaultProxy()


各语言互通的加密类

public class PublicDES

一、加密串

public static string Encode(string source, string _DESKey)

source:要加密的串

_DESKey:秘钥

返回加密后的串


二、解密串

public static string Decode(string source, string sKey)

source:要解密的串

sKey:秘钥

返回解密后的串


和Java互通的加密类

public class RESJavaHelper


一、用私钥给数据进行RSA加密

public static string PrivateKeyEncrypt(string xmlPrivateKey, string strEncryptString)

xmlPrivateKey:私钥(XML格式字符串)

strEncryptString:要加密的数据

返回加密的数据



二、用公钥给数据进行RSA解密

public static string PublicKeyDecrypt(string xmlPublicKey, string strDecryptString)

xmlPublicKey:公钥(XML格式字符串)

strDecryptString:要解密数据

返回解密的数据



三、 使用公钥加密,分段加密

public static string EncrytByPublic(string publicKeyPath, string strEncryptString)

publicKeyPath:公钥

strEncryptString:要加密的数据

返回加密后的串


四、通过私钥解密,分段解密

public static string DecryptByPrivate(string privateKeyPath, string strDecryptString)

privateKeyPath:私钥

strDecryptString:要解密的数据

返回解密的数据


Json操作类

public static partial class JsonHelper

一、将一个对象转为指定类型

static public T OBJToType<T>(Object m_JsonObj)//将json的OBJ对象转为指定类型

T:要转换的类型

m_JsonObj:要转换的对象

返回转换后的对象


二、对象转为json串

static public string OBJToJsonStr(Object O)

O:要转换的对象

返回对象的json串


三、json串转为指定对象

static public T JsonStrToOBJ<T>(string jsonStr)

T:要转换的类型

jsonStr:要转换的json串

返回转换后的对象


四、DataRow转换为对象数组

static public Object DataRow2Object(DataRow[] m_Rows)

m_Rows:要转换的DataRow数组

返回对象数组 ArrayList


五、DataRow转hashtable

static public Hashtable DataRow2Hashtable(DataRow m_Row)


六、DataRow转指定类型

static public T DataRow2Object<T>(DataRow m_Row)


七、Object转Hashtable

public static void OBJToHashTable(object O, Hashtable h);

O:要转换的Object

h:转换后的Hashtable


八、Json串转hashtable

static public void JsonToHashtable(string jsonData, Hashtable h)

jsonData:要转换的json串

h:转换后的Hashtable


九、XML转json串

static public string XMLToJSON(string sXML)

sXML:XML串

返回json串


十、XML转Hashtable

static public bool XMLToHashtable(string sXML,Hashtable m_HH)

sXML:XML串

m_HH:转换后的Hashtable

相关推荐

MFC、Qt、WPF?该用哪个?(mfc和wpf区别)

MFC、Qt和WPF都是流行的框架和工具,用于开发图形用户界面(GUI)应用程序。选择哪个框架取决于你的具体需求和偏好。MFC(MicrosoftFoundationClass)是微软提供的框架,...

一款WPF开发的通讯调试神器(支持Modbus RTU、MQTT调试)

我们致力于探索、分享和推荐最新的实用技术栈、开源项目、框架和实用工具。每天都有新鲜的开源资讯等待你的发现!项目介绍Wu.CommTool是一个基于C#、WPF、Prism、MaterialDesign...

关于面试资深C#、WPF开发工程师的面试流程和问题

一、开场(2-3分钟)1.欢迎应聘者,简单介绍公司和面试流程。2.询问应聘者是否对公司或岗位有初步的问题。二、项目经验与技术应用(10-20分钟)1.让应聘者详细介绍几个他参与过的C#、...

C# WPF MVVM模式Prism框架下事件发布与订阅

01—前言处理同模块不同窗体之间的通信和不同模块之间不同窗体的通信,Prism提供了一种事件机制,可以在应用程序中低耦合的模块之间进行通信,该机制基于事件聚合器服务,允许发布者和订阅者之间通过事件进行...

WPF 机械类组件动画制作流程简述(wps上怎么画机械结构简图)

WPF机械类组件动画制作流程简述独立观察员2025年3月4日一、创建组件创建组件用户控件,将组件的各部分“零件”(图片)拼装在一起,形成组件的默认状态:二、给运动部分加上Rend...

C#上位机WinForm和WPF选哪个?工控老油条的&quot;血泪史&quot;

作为一个从互联网卷进工控坑的"跨界难民",在这会摸鱼的时间咱就扯一下上位机开发选框架这档子破事。当年我抱着WPF的酷炫动画一头扎进车间,结果被产线老师傅一句"你这花里胡哨的玩意...

【一文扫盲】WPF、Winform、Electron有什么区别?

近年来,随着软件开发的不断发展,开发人员面临着选择适合他们项目的各种框架和工具的挑战。在桌面应用程序开发领域,WPF、Winform和Electron是三个备受关注的技术。本文将介绍这三者的区别,帮助...

一个开源、免费、强大且美观的WPF控件库

我们致力于探索、分享和推荐最新的实用技术栈、开源项目、框架和实用工具。每天都有新鲜的开源资讯等待你的发现!项目介绍HandyControl是一套基于WPF(WindowsPresentationF...

WPF 根据系统主题自动切换浅色与深色模式

WPF根据系统主题自动切换浅色与深色模式控件名:Resources作者:WPFDevelopersOrg-驚鏵原文链接[1]:https://github.com/WPFDevelopers...

WPF与WinForm的本质区别(wpf与maui)

在Windows应用程序开发中,WinForm和WPF是两种主要的技术框架。它们各自有不同的设计理念、渲染机制和开发模式。本文将详细探讨WPF与WinForm的本质区别,并通过示例进行说明。渲染机制W...

Win10/Win11效率神器再进化:微软发布PowerToys 0.90.0版本

IT之家4月1日消息,微软今天(4月1日)更新PowerToys,在最新发布的0.90.0版本中,修复多个BUG之外,引入多项功能更新,为Windows10、Windows...

一款非常漂亮的WPF管理系统(wpf架构及特性)

我们致力于探索、分享和推荐最新的实用技术栈、开源项目、框架和实用工具。每天都有新鲜的开源资讯等待你的发现!WPFManager项目介绍该项目是一款WPF开发的管理系统,数据库采用的MSSqlserv...

WPF 实现描点导航(wpf按钮的点击事件)

WPF实现描点导航控件名:NavScrollPanel作者:WPFDevelopersOrg-驚鏵原文链接[1]:https://github.com/WPFDevelopersOrg/WPF...

微软更新基于Win11的Validation OS 2504:增强 .NET与WPF

IT之家5月1日消息,科技媒体NeoWin今天(5月1日)发布博文,报道称微软公司更新基于Windows11的ValidationOS,增强支持.NET和WPF,并优...

WPF的技术架构与优势(wpf的前景)

WindowsPresentationFoundation(WPF)是一个现代化的用户界面框架,专为构建Windows应用程序而设计。它通过分层的技术架构和丰富的功能集,提供了全面的应用程...

取消回复欢迎 发表评论: