示例#1
0
        public CompositeFileSystem(IList <Tuple <string, IFileSystem> > fss)
        {
            var ixs = fss.OrderBy(fs => fs.Item1, StringComparer.OrdinalIgnoreCase)
                      .Select((fs, ix) => ix);

            _fslist = fss.OrderByDescending(fs => fs.Item1, StringComparer.OrdinalIgnoreCase).Select(fs =>
                                                                                                     Tuple.Create(Util.CombinePath(fs.Item1, ""), fs.Item2)
                                                                                                     );

            foreach (var ix in ixs)
            {
                var fs = fss[ix];
                var k  = fs.Item1;
                var n  = Util.CombinePath(k, "");
                ProcessPath(fs.Item2, "/", n);
            }

            foreach (var p in _fs.Keys.ToArray())
            {
                foreach (var s in NewSegments(p))
                {
                    if (s.Equals("/"))
                    {
                        continue;
                    }

                    var name = s.Substring(s.TrimEnd('/').LastIndexOf('/')).Trim('/');
                    _fs[s] = new CompositePlaceHolderDir()
                    {
                        Name = name
                    };
                }
            }

            var dirs = from nv in _fs
                       let k                   = nv.Key.TrimEnd('/')
                                        let gk = k.Length > 0 ? k.Substring(0, k.LastIndexOf('/')) : ""
                                                 group nv by gk.ToLowerInvariant();

            foreach (var g in dirs)
            {
                var k = g.Key.Length > 0 ? Util.CombinePath(g.Key, "") : "/";
                _dir[k] = g.Select(v => v.Value).ToList();
            }
            return;
        }
示例#2
0
        public CompositeFileSystem(IList<Tuple<string, IFileSystem>> fss)
        {
            var ixs = fss.OrderBy(fs => fs.Item1, StringComparer.OrdinalIgnoreCase)
                .Select((fs, ix) => ix);

            _fslist = fss.OrderByDescending(fs => fs.Item1, StringComparer.OrdinalIgnoreCase).Select(fs =>
                Tuple.Create(Util.CombinePath(fs.Item1,""),fs.Item2)
            );

              foreach (var ix in ixs) {
                var fs = fss[ix];
                var k = fs.Item1;
                var n = Util.CombinePath(k, "");
                ProcessPath(fs.Item2, "/", n);
            }

            foreach (var p in _fs.Keys.ToArray()) {
                foreach (var s in NewSegments(p)) {
                    if (s.Equals("/"))
                        continue;

                    var name = s.Substring(s.TrimEnd('/').LastIndexOf('/')).Trim('/');
                    _fs[s] = new CompositePlaceHolderDir() { Name = name };
                }
            }

            var dirs = from nv in _fs
                                 let k = nv.Key.TrimEnd('/')
                                 let gk = k.Length > 0 ? k.Substring(0, k.LastIndexOf('/')) : ""
                                 group nv by gk.ToLowerInvariant();

            foreach (var g in dirs) {
                var k = g.Key.Length > 0 ? Util.CombinePath(g.Key, "") : "/";
                _dir[k] = g.Select(v => v.Value).ToList();
            }
            return;
        }