static internal PathDecomposeur FromName(string Name) { if (Name == null) return null; string[] res = Name.ToLower().Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); IDictionary<string, PathDecomposeur> Finder = null;// Roots; PathDecomposeur MyPD = null; bool newi = false; foreach (string r in res) { if (Finder == null) Finder = Roots; else { if (MyPD == null) throw new Exception("Algo error"); Finder = MyPD.Childs; } PathDecomposeur old = MyPD; if (newi || !Finder.TryGetValue(r, out MyPD)) { MyPD = new PathDecomposeur(old, r); newi = true; } } return MyPD; }
private PathDecomposeur(PathDecomposeur iFather, String Name) { _Rank = _Count++; LocalPath = Name; Father = iFather; if (Father != null) Father.Register(this); else Roots.Add(Name, this); }
private void Register(PathDecomposeur Child) { if (Child == null) throw new ArgumentNullException(); Childs.Add(Child.LocalPath, Child); }