代码拉取完成,页面将自动刷新
同步操作将从 Ivan.Lee/vJine.Core 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace vJine.Core {
public class CheckException : CoreException {
public CheckException(string Msg, params object[] Args)
: base(Msg, Args) {
}
}
public class Check {
public static bool IS(object V, Type Target, string Msg, params object[] Args) {
bool Mathch =
V != null && V.GetType() == Target;
return Check.True(Mathch, Msg, Args);
}
public static bool IS(Type V, Type Target, string Msg, params object[] Args) {
bool Mathch = V == Target;
return Check.True(Mathch, Msg, Args);
}
public static bool NULL(bool Is, object V, string Msg, params object[] Args) {
bool Mathch = Is ? V == null : V != null;
return Check.True(Mathch, Msg, Args);
}
public static bool Range<T>(T V, T min, T max, string Msg, params object[] Args) where T : IComparable<T> {
bool Match = V.CompareTo(min) >= 0 && V.CompareTo(max) <= 0;
return Check.True(Match, Msg, Args);
}
public static bool Min<T>(T V, T min, string Msg, params object[] Args) where T : IComparable<T> {
bool Match = V.CompareTo(min) >= 0;
return Check.True(Match, Msg, Args);
}
public static bool Max<T>(T V, T min, T max, string Msg, params object[] Args) where T : IComparable<T> {
bool Match = V.CompareTo(max) <= 0;
return Check.True(Match, Msg, Args);
}
public static bool True(bool Condidion, string Msg, params object[] Args) {
if (!Condidion && !string.IsNullOrEmpty(Msg)) {
throw new CheckException(Msg, Args);
}
return Condidion;
}
public static bool False(bool Condition, string Msg, params object[] Args) {
return Check.True(!Condition, Msg, Args);
}
public static bool Pattern(string V, string Pattern, string Msg, params object[] Args) {
return Check.True(Regex.IsMatch(V, Pattern), Msg, Args);
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = true, Inherited = true)]
public class CheckAttribute : Attribute {
public CheckAttribute() {
this.OnSet = true;
this.OnGet = false;
}
/// <summary>
/// 取值的值,默认为空(仅取值)
/// </summary>
public string Name { get; set; }
public string Message { get; set; }
public bool OnGet { get; set; }
public bool OnSet { get; set; }
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = true, Inherited = true)]
public class CheckRangeAttribute : CheckAttribute {
internal double Min { get; set; }
internal double Max { get; set; }
public CheckRangeAttribute(sbyte min, sbyte max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(byte min, byte max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(short min, short max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(ushort min, ushort max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(int min, int max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(uint min, uint max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(long min, long max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(ulong min, ulong max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(float min, float max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(double min, double max) {
this.Min = min;
this.Max = max;
}
public CheckRangeAttribute(DateTime min, DateTime max) {
this.Min = min.ToBinary();
this.Max = max.ToBinary();
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = true, Inherited = true)]
public class CheckPatternAttribute : CheckAttribute {
string Pattern { get; set; }
public CheckPatternAttribute(string Pattern) {
this.Pattern = Pattern;
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = true, Inherited = true)]
public class CheckListAttribute : CheckAttribute {
public CheckListAttribute(params object[] V) {
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。