public JsonResult Base(WhiteListType type, string name, string value) { if (string.IsNullOrWhiteSpace(name) && string.IsNullOrWhiteSpace(value) && type == WhiteListType.Not) { return(Json(new TrueOrFalse(false))); } // База JsonDB jsonDB = Service.Get <JsonDB>(); // Добавляем значение var md = new WhiteListModel(name, value, type); md.Id = int.Parse(Generate.Passwd(6, true)); jsonDB.WhiteList.Add(md); // Обновляем jsonDB.Save(); WhiteUserList.UpdateCache(); // Trigger.OnChange((0, 0)); // Успех return(Json(new TrueOrFalse(true))); }
public void SetWhiteList(string rawList, WhiteListType whiteListType) { List <string> list = GetBucketList(whiteListType); if (!string.IsNullOrWhiteSpace(rawList)) { list.AddRange((rawList ?? "").Split("|")); } }
private bool Check(string[] strs, WhiteListType whiteListType) { if (!dic.ContainsKey(whiteListType)) { return(false); } string temp = string.Empty; for (int i = 0; i < strs.Length; i++) { temp += strs[i]; } foreach (var item in dic[whiteListType]) { string[] whiteList = item.Split(sperateChar); bool partCheck = true; for (int i = 0; i < whiteList.Length; i++) { if (!(whiteList[i] == strs[i] || (whiteList[i] == nullChar.ToString() /*&& i < whiteList.Length - 1*/))) { partCheck = false; break; } //System.Func<string, bool> func = (str) => //{ // return (strs[0] == str && str == whiteList[0]); //}; //if (whiteListType == WhiteListType.Namespace) //{ // if (func("MalbersAnimations") || func("UnityEngine") || func("Ricimi") || func("XftWeapon")) // { // Debug.Log(i + " " + temp + ":" + item + "--------" + strs[i] + ":" + whiteList[i] + " " + partCheck.ToString()); // } //} } if (partCheck == true) { return(true); } } return(false); }
private void LoadWhiteList(WhiteListType whiteListType, string path) { if (dic.ContainsKey(whiteListType)) { Debug.LogError("Init White List Error: Key Duplicated"); return; } else { string[] lines = File.ReadAllLines(Application.dataPath + path); dic.Add(whiteListType, new List <string>(lines)); } }
private List <string> GetBucketList(WhiteListType bucketType) { if (bucketType == WhiteListType.PDF) { return(PDFBuckets); } else if (bucketType == WhiteListType.Image) { return(ImageBuckets); } else if (bucketType == WhiteListType.Key) { return(KeyBuckets); } return(null); }
public WhiteListModel(string Description, string Value, WhiteListType Type) { this.Description = Description; this.Value = Value; this.Type = Type; }
public bool CanAccess(string bucket, WhiteListType whiteListType) { List <string> list = GetBucketList(whiteListType); return(list.Count == 0 || list.Contains(bucket)); }