VB.net 2010 视频教程 VB.net 2010 视频教程 python基础视频教程
SQL Server 2008 视频教程 c#入门经典教程 Visual Basic从门到精通视频教程
当前位置:
首页 > temp > C#教程 >
  • .NET中大型项目开发必备(6)–IUtility工具介绍

相关下载:

DeveloperSharp.dll组件

http://www.365ey.net/article/DeveloperSharp.dll

DeveloperSharp.dll组件

https://files-cdn.cnblogs.com/files/blogs/721296/(2022)DeveloperSharp.rar

在DeveloperSharp框架中,存在两个非常强大的工具接口,一个是IUtility工具接口(提供一系列有用的功能),一个是IDataAccess工具接口(提供数据访问功能)。

本文将具体介绍IUtility。

 

IUtility所在的命名空间是:DeveloperSharp.Framework.CoreUtility。

它主要提供了如下一系列功能:

application/session/cookie变量设置、路径转换、编码/解码、图片切割、图片缩略、图片加文字水印、图片加图像水印、json序列化、Web服务的远程调用、http调用(get/post)、生成UUID、等。

它初始化的代码如下:

using DeveloperSharp.Framework.CoreUtility;
--------------------------

IUtility IU = new Utility();

 

IUtility内拥有的详细功能方法说明如下:

复制代码
SetApplicationVar
声明:void SetApplicationVar(string Name, object Value);
用途:设置Application变量
参数:(1) string Name             --  变量名
     (2) object Value             --  变量值
返回:(无)

SetSessionVar
声明:void SetSessionVar(string Name, object Value)
用途:设置Session变量
参数:(1)string Name   --  变量名
	 (2) object Value             --  变量值
返回:(无)

SetCookieVar
声明:void SetCookieVar(System.Web.HttpCookie HC)
用途:设置Cookie变量
参数:(1)System.Web.HttpCookie HC  --  Cookie变量
返回:(无)

GetApplicationVar
声明:object GetApplicationVar(string Name)
用途:获取Application变量
参数:(1)string Name   --  变量名
返回:object   --  变量值

GetSessionVar
声明:object GetSessionVar(string Name)
用途:获取Session变量
参数:(1)string Name   --  变量名
返回:object   --  Session变量值

GetCookieVar
声明:System.Web.HttpCookie GetCookieVar(string Name)
用途:获取Cookie变量
参数:(1)string Name   --  变量名
返回:String   --  Cookie变量

Request
声明:string Request(string Name)
用途:获取传送变量的值
参数:(1)string Name  --  变量名
返回:String   --  变量值

RequestServerVariables
声明:string RequestServerVariables(string ServerVarName)
用途:获取服务器变量的值
参数:(1)string ServerVarName   --  服务器变量名
返回:String   --  服务器变量的值

RequestPhysicalPath
声明:string RequestPhysicalPath(string Path)
用途:获取物理路径
参数:string Path   --  虚拟路径或者相对路径
返回:String   --  物理路径

RedirectToURL
声明:void RedirectToURL(string Url)
用途:重新定向URL地址
参数:(1)string Url   --  要转向的URL地址
返回:(无)

DecodeHtml
声明:string DecodeHtml(string Content)
用途:Html解码
参数:(1)string Content   --  需要解码的字符串
返回:String   --  解码后的字符串

DecodeUrl
声明:string DecodeUrl(string Content)
用途:Url解码
参数:(1)string Content   --  需要解码的Url字符串
返回:String   --  解码后的Url字符串

EncodeHtml
声明:string EncodeHtml(string Content)
用途:Html编码
参数:(1)string Content   --  需要编码的字符串
返回:String   --  编码后的字符串

EncodeUrl
声明:string EncodeUrl(string Content)
用途:Url编码
参数:(1)string Content   --  需要编码的Url字符串
返回:String   --  编码后的Url字符串

PictureCut
声明:void PictureCut(string SourceFile, int CutStartPointX, int CutStartPointY, int CutWidth, int CutHeight, string TargetFile)
用途:图片裁剪
参数:(1)string SourceFile   --  原始图片文件路径
	 (2)int CutStartPointX	  --起始裁剪点X坐标
	 (3)int CutStartPointY	--起始裁剪点Y坐标
	 (4)int CutWidth		--裁剪宽度
	 (5)int CutHeight	  --裁剪高度
	 (6)string TargetFile	--新生成的目标图片文件路径
返回:(无)

PictureThumbnail
声明:void PictureThumbnail(string SourceFile, int FrameWidth, int FrameHeight, string TargetFile)
用途:图片缩略
参数:(1)string SourceFile   --  原始图片文件路径
	 (2)int FrameWidth	  --缩略框的宽度
	 (3)int FrameHeight	--缩略框的高度
	 (4)string TargetFile		--新生成的目标图片文件路径
返回:(无)

PictureImageWatermark
声明:void PictureImageWatermark(string SourceFile, string WatermarkFile, string TargetFile)
用途:图片加“图像”水印
参数:(1)string SourceFile   --  原始图片文件路径
	 (2)string WatermarkFile  --水印图像文件路径
	 (3)string TargetFile	--新生成的目标图片文件路径
返回:(无)

PictureImageWatermark
声明:void PictureImageWatermark(string SourceFile, string WatermarkFile, int x, int y, string TargetFile)
用途:图片加“图像”水印
参数:(1)string SourceFile   --  原始图片文件路径
	 (2)string WatermarkFile  --水印图像文件路径
	 (3)int x	--水印图像的起始X坐标
(4)int x	--水印图像的起始Y坐标
	 (5)string TargetFile		--新生成的目标图片文件路径
返回:(无)


PictureTextWatermark
声明:void PictureTextWatermark(string SourceFile, string WaterText, string TargetFile)
用途:图片加“文字”水印
参数:(1)string SourceFile   --  要加水印的图片物理路径
	 (2)string WaterText	  --文字内容
	 (3)string TargetFile	--文字字体
返回:(无)

PictureTextWatermark
声明:void PictureTextWatermark(string SourceFile, string WaterText, System.Drawing.Font WaterTextFont, System.Drawing.Brush WaterTextBrush, int x, int y, string TargetFile)
用途:图片加“文字”水印
参数:(1)string SourceFile   --  原始图片文件路径
	 (2)string WaterText  --水印文字
	 (3)System.Drawing.Font WaterTextFont	--水印文字字体
(4)System.Drawing.Brush WaterTextBrush	--水印文字笔触
(5)int x	--水印图像的起始X坐标
(6)int y	--水印图像的起始Y坐标
	 (7)string TargetFile		--新生成的目标图片文件路径
返回:(无)

PagePartition
声明:PagePiece PagePartition(DataTable Table, int PageSize, int PageIndex)
用途:分页功能
参数:(1)DataTable Table   --  需要分页的DataTable
	 (2)int PageSize  --  页面大小
	 (3)int PageIndex	--  当前页码(最小值为1)
返回:PagePiece   --  页片实体

JsonSerialize
声明:string JsonSerialize(object Obj)
用途:对象转化为JSON
参数:(1)object Obj   --  被转化的对象
返回:string  --  JSON字符串

JsonDeserialize
声明:T JsonDeserialize<T>(string jsonText)
用途:JSON转化为对象
参数:(1)string jsonText   --  JSON字符串
返回:T  --  对象

GetService(可参考“Web服务的负载均衡”这篇文章)
声明:T GetService<T>()
用途:获取远程/本地服务
参数:(无)
返回:T  --  服务实例

GetService
声明:T GetService<T>(string svcBindType, string svcURL)
用途:获取WCF远程服务
参数:(1)string svcBindType   --  服务调用类型
	 (2)string svcURL       --  服务地址
返回:T  --  服务实例

HttpGet
声明:string HttpGet(string Url)
用途:调用Http-Get请求
参数:(1)string Url  --  调用请求的url地址
返回:String   --  请求结果

HttpPost
声明:string HttpPost(string Url, string ParamData = "", Dictionary<string, string> HeaderDic = null, string ContentType = "application/x-www-form-urlencoded");
用途:调用Http-Post请求
参数:(1)string Url             --  调用请求的url地址
     (2)string ParamData      --  提交的参数
     (3)Dictionary<string, string> HeaderDic  --  存放http头的键值对
     (4)string ContentType   --  请求的编码格式,通常有application/x-www-form-urlencoded(默认设置)、multipart/form-data、application/json三种形式
返回:String   --  请求结果(-107开头表示出错)

GenerateId(可参考“UUID全球通用唯一识别码”这篇文章)
声明:string GenerateId(string Prefix)
用途:生成主键Id (此处生成的是一种UUID)
参数:(1)string Prefix  --  前缀词
返回:String   --  主键Id
复制代码

出  处:https://www.cnblogs.com/DeveloperSharp/p/15824826.html


相关教程