public static ListItem GetListItem(ERestrictionType type, bool selected) { var item = new ListItem(GetText(type), GetValue(type)); if (selected) { item.Selected = true; } return(item); }
public static bool Equals(ERestrictionType type, string typeStr) { if (string.IsNullOrEmpty(typeStr)) { return(false); } if (string.Equals(GetValue(type).ToLower(), typeStr.ToLower())) { return(true); } return(false); }
public static string GetText(ERestrictionType type) { if (type == ERestrictionType.BlackList) { return("启用黑名单,禁止黑名单中的IP进行访问,其余允许访问"); } if (type == ERestrictionType.WhiteList) { return("启用白名单,允许白名单中的IP进行访问,其余禁止访问"); } return("无访问限制"); }
public static string GetValue(ERestrictionType type) { if (type == ERestrictionType.BlackList) { return("BlackList"); } if (type == ERestrictionType.WhiteList) { return("WhiteList"); } return("None"); }
public static bool IsVisitAllowed(ERestrictionType restrictionType, StringCollection restrictionBlackList, StringCollection restrictionWhiteList) { if (restrictionType == ERestrictionType.NoRestriction) { return(true); } var restrictionList = new StringCollection(); if (restrictionType == ERestrictionType.BlackList) { restrictionList = restrictionBlackList; } else if (restrictionType == ERestrictionType.WhiteList) { restrictionList = restrictionWhiteList; } return(IsVisitAllowed(restrictionType, restrictionList)); }
public static string GetShortText(ERestrictionType type) { if (type == ERestrictionType.NoRestriction) { return("无"); } else if (type == ERestrictionType.BlackList) { return("启用黑名单"); } else if (type == ERestrictionType.WhiteList) { return("启用白名单"); } else { throw new Exception(); } }
public static string GetText(ERestrictionType type) { if (type == ERestrictionType.NoRestriction) { return("无访问限制"); } else if (type == ERestrictionType.BlackList) { return("启用黑名单,禁止黑名单中的IP进行访问,其余允许访问"); } else if (type == ERestrictionType.WhiteList) { return("启用白名单,允许白名单中的IP进行访问,其余禁止访问"); } else { throw new Exception(); } }
public static string GetValue(ERestrictionType type) { if (type == ERestrictionType.NoRestriction) { return("NoRestriction"); } else if (type == ERestrictionType.BlackList) { return("BlackList"); } else if (type == ERestrictionType.WhiteList) { return("WhiteList"); } else { throw new Exception(); } }
private static bool IsVisitAllowed(ERestrictionType restrictionType, StringCollection restrictionList) { var isAllowed = true; if (restrictionType != ERestrictionType.NoRestriction) { var userIP = PageUtils.GetIpAddress(); if (restrictionType == ERestrictionType.BlackList) { var list = new IPList(); foreach (var restriction in restrictionList) { AddRestrictionToIPList(list, restriction); } if (list.CheckNumber(userIP)) { isAllowed = false; } } else if (restrictionType == ERestrictionType.WhiteList) { if (restrictionList.Count > 0) { isAllowed = false; var list = new IPList(); foreach (var restriction in restrictionList) { AddRestrictionToIPList(list, restriction); } if (list.CheckNumber(userIP)) { isAllowed = true; } } } } return(isAllowed); }
public static bool Equals(string typeStr, ERestrictionType type) { return(Equals(type, typeStr)); }