|
@@ -9,6 +9,12 @@ namespace Sharing.Province
|
|
|
[AttributeUsage(AttributeTargets.Property)]
|
|
|
public abstract class AbstractValidateAttribute : Attribute
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="objValue"></param>
|
|
|
+ /// <param name="strError"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public abstract bool Validate(object objValue, out string strError);
|
|
|
}
|
|
|
|
|
@@ -41,11 +47,22 @@ namespace Sharing.Province
|
|
|
|
|
|
private readonly int m_nMax;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="min"></param>
|
|
|
+ /// <param name="max"></param>
|
|
|
public VStringLengthAttribute(int min, int max)
|
|
|
{
|
|
|
m_nMin = min;
|
|
|
m_nMax = max;
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="str"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public static int GetStrLength(string str)
|
|
|
{
|
|
|
if (string.IsNullOrEmpty(str))
|
|
@@ -56,6 +73,12 @@ namespace Sharing.Province
|
|
|
return Encoding.Default.GetBytes(str).Length;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="objValue"></param>
|
|
|
+ /// <param name="strError"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public override bool Validate(object objValue, out string strError)
|
|
|
{
|
|
|
strError = "";
|
|
@@ -88,11 +111,19 @@ namespace Sharing.Province
|
|
|
{
|
|
|
private readonly string m_strRemark;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="strRemark"></param>
|
|
|
public MDisplayNameAttribute(string strRemark)
|
|
|
{
|
|
|
m_strRemark = strRemark;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <returns></returns>
|
|
|
public virtual string GetRemark()
|
|
|
{
|
|
|
return m_strRemark;
|
|
@@ -104,6 +135,12 @@ namespace Sharing.Province
|
|
|
/// </summary>
|
|
|
public static class AOPExtend
|
|
|
{
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <typeparam name="T"></typeparam>
|
|
|
+ /// <param name="t"></param>
|
|
|
+ /// <returns></returns>
|
|
|
public static string Validate<T>(this T t) where T : class, new()
|
|
|
{
|
|
|
PropertyInfo[] properties = t.GetType().GetProperties();
|