命名风格:对类的对象命名,定义成类名V
2017-08-13 09:17:09 访问(1842) 赞(0) 踩(0)
参考示例:对象名定义
DllInfoItem dllInfoItemV = null;
DllInfoItem类定义
using SlowX.CoreDevManage.CodeSigns;
using System;
namespace SlowX.CoreDevManage.Classes.Items
{
/// <summary>
/// <para>DLL的信息</para>
/// <para>名称</para>
/// <para>大小</para>
/// <para>版本号等等</para>
/// </summary>
[Serializable]
public class DllInfoItem
:
BaseCreateDevCodeItem
{
/// <summary>
/// <para>DLL的信息</para>
/// <para>名称</para>
/// <para>大小</para>
/// <para>版本号等等</para>
/// </summary>
public DllInfoItem()
{
CodeSignContainer.DllInfoItem("定义逻辑类");
}
#region TheName ~ 名称
/// <summary>
/// TheName ~ 名称
/// </summary>
protected string m_TheName = null;
/// <summary>
/// TheName ~ 名称
/// </summary>
public string TheName
{
get
{
return m_TheName;
}
set
{
m_TheName = value;
}
}
#endregion TheName ~ 名称
#region FileVersion ~ 版本号
/// <summary>
/// FileVersion ~ 版本号
/// </summary>
protected string m_FileVersion = null;
/// <summary>
/// FileVersion ~ 版本号
/// </summary>
public string FileVersion
{
get
{
return m_FileVersion;
}
set
{
m_FileVersion = value;
}
}
#endregion FileVersion ~ 版本号
#region Comments ~ 注释
/// <summary>
/// Comments ~ 注释
/// </summary>
protected string m_Comments = null;
/// <summary>
/// Comments ~ 注释
/// </summary>
public string Comments
{
get
{
return m_Comments;
}
set
{
m_Comments = value;
}
}
#endregion Comments ~ 注释
#region ProductName ~ 产品名称
/// <summary>
/// ProductName ~ 产品名称
/// </summary>
protected string m_ProductName = "";
/// <summary>
/// ProductName ~ 产品名称
/// </summary>
public string ProductName
{
get
{
return m_ProductName;
}
set
{
m_ProductName = value;
}
}
#endregion ProductName ~ 产品名称
#region CompanyName ~ 公司名称
/// <summary>
/// CompanyName ~ 公司名称
/// </summary>
protected string m_CompanyName = "";
/// <summary>
/// CompanyName ~ 公司名称
/// </summary>
public string CompanyName
{
get
{
return m_CompanyName;
}
set
{
m_CompanyName = value;
}
}
#endregion CompanyName ~ 公司名称
#region TheSize ~ 大小
/// <summary>
/// TheSize ~ 大小
/// </summary>
protected long m_TheSize = 0;
/// <summary>
/// TheSize ~ 大小
/// </summary>
public long TheSize
{
get
{
return m_TheSize;
}
set
{
m_TheSize = value;
}
}
#endregion TheSize ~ 大小
#region UpdateTime ~ 最后更新时间
/// <summary>
/// UpdateTime ~ 最后更新时间
/// </summary>
protected DateTime m_UpdateTime = DateTime.MinValue;
/// <summary>
/// UpdateTime ~ 最后更新时间
/// </summary>
public DateTime UpdateTime
{
get
{
return m_UpdateTime;
}
set
{
m_UpdateTime = value;
}
}
#endregion UpdateTime ~ 最后更新时间
}
}
完整代码
/// <summary>
/// 通过读取网站的bin目录,获得List-DllInfoItem
/// </summary>
/// <returns></returns>
public List<DllInfoItem> DllInfoItemItemList()
{
// 代码标签 //
CodeSignContainer.DllInfoItem("获得DllInfoItem的list");
HttpContext hc = HttpContext.Current;
if(hc == null)
{
throw new Exception
(
"方法:"
+ MethodBase.GetCurrentMethod().ReflectedType.FullName
+ " "
+ MethodBase.GetCurrentMethod().ToString()
+ " 发生异常:"
+ "HttpContext.Current"
+ "值为null。"
);
}
List<DllInfoItem> theResult = new List<DllInfoItem>();
string binDir = hc.Request.PhysicalApplicationPath + "bin\\";
DirectoryInfo dirInfo = new DirectoryInfo(binDir);
if (!dirInfo.Exists)
return theResult;
FileInfo[] theArray = dirInfo.GetFiles("*.dll");
DllInfoItem dllInfoItemV = null;
if (theArray != null)
{
foreach (FileInfo info in theArray)
{
if (info == null)
continue;
dllInfoItemV = new DllInfoItem();
dllInfoItemV.TheName = info.Name;
dllInfoItemV.TheSize = info.Length;
VersionInfoSet4DllInfoItem(dllInfoItemV, info.FullName);
dllInfoItemV.UpdateTime = info.LastWriteTime;
theResult.Add(dllInfoItemV);
}
}
return theResult;
}
上一条:
下一条:
相关评论
发表评论