public static bool IsPathCard(string value) { string[] valArray = value.Trim().Split('\\'); if (valArray.Length != 2) { return(false); } if (!PathTree.IsPathTree(valArray[0])) { return(false); } int val; if (!int.TryParse(valArray[1], out val)) { return(false); } if (val <= 0) { return(false); } return(true); }
public static IDAOFilter CreateICardDatFilter <T>(IDataAccess accessor, ArrayList args) where T : BaseDat <T>//, new() { IDAOFilter filter = accessor.NewFilter(); if (args.Count == 1) { if (args[0] is int) { return(CreateIDatFilter <T>(accessor, args)); } else if (args[0] is PathCard) { filter.AddWhere(new FilterAND(new FilterString(BaseDat <T> .GetFieldName("Parent_FP"), ((PathCard)args[0]).Parent.ToString()), new FilterID(BaseDat <T> .GetFieldName("Code"), ((PathCard)args[0]).Code))); return(filter); } else if (args[0] is string) { string argVal = args[0].ToString(); if (PathCard.IsPathCard(argVal)) { filter.AddWhere(new FilterAND(new FilterString(BaseDat <T> .GetFieldName("Parent_FP"), new PathCard(argVal).Parent.ToString()), new FilterID(BaseDat <T> .GetFieldName("Code"), new PathCard(argVal).Code))); return(filter); } } } else if (args.Count == 2) { //if (args[0] is PathTree && args[1] is int) if (PathTree.IsPathTree(args[0].ToString()) && args[1] is int) { filter.AddWhere(new FilterAND(new FilterString(BaseDat <T> .GetFieldName("Parent_FP"), ((PathTree)args[0]).ToString()), new FilterID(BaseDat <T> .GetFieldName("Code"), (int)args[0]))); return(filter); } else if (args[0] is string && args[1] is int) { filter.AddWhere(new FilterAND(new FilterString(BaseDat <T> .GetFieldName("Parent_FP"), (string)args[0]), new FilterID(BaseDat <T> .GetFieldName("Code"), (int)args[0]))); return(filter); } } throw new ArgumentException("ќшибка формировани¤ ICardDatFilter по заданным аргументам", args2string(args)); }
public int CompareTo(PathTreeN other) { if ((object)other == null) { return(1); } for (int i = 0; i < Math.Max(other._list.Count, _list.Count); i++) { if (i >= other._list.Count) { return(1); } if (i >= _list.Count) { return(-1); } //if () int cmp = 0; if (PathTree.IsPathTree(_list[i]) && PathTree.IsPathTree(other._list[i])) { PathTree l1 = new PathTree(_list[i]); PathTree l2 = new PathTree(other._list[i]); cmp = l1.CompareTo(l2); } else { cmp = string.Compare(_list[i], other._list[i], true); } if (cmp != 0) { return(cmp); } //if (_list[i] > other._list[i]) return 1; //if (_list[i] < other._list[i]) return -1; } return(0); }