示例#1
0
        public IFileInfo GetFileInfo(string subpath)
        {
            if (subpath is null)
            {
                throw new ArgumentNullException(nameof(subpath));
            }

            string PathToCheck = CleanPath(subpath);

            RazorFileInfo fileInfo = new RazorFileInfo();

            RazorCompiledItemAttribute rca = RazorViews.FirstOrDefault(rcal => rcal.Identifier == PathToCheck);

            fileInfo.Exists = rca != null;

            if (rca != null)
            {
                string LocalPath = rca.Identifier.From(PathToCheck);
                bool   Directory = LocalPath.Contains("/");
                string Name      = LocalPath.To("/");

                fileInfo.IsDirectory  = Directory;
                fileInfo.LastModified = DateTime.MinValue;
                fileInfo.Name         = Name;
                fileInfo.PhysicalPath = "";
            }

            return(fileInfo);
        }
示例#2
0
        public IDirectoryContents GetDirectoryContents(string subpath)
        {
            if (subpath is null)
            {
                throw new ArgumentNullException(nameof(subpath));
            }

            string PathToCheck = CleanPath(subpath, true);

            RazorDirectoryContents directoryContents = new RazorDirectoryContents();

            if (RazorViews.Any(r => r.Identifier.StartsWith(PathToCheck)))
            {
                directoryContents.Exists = true;

                foreach (RazorCompiledItemAttribute a in RazorViews.Where(rca => rca.Identifier.StartsWith(PathToCheck)))
                {
                    string LocalPath = a.Identifier.From(PathToCheck);
                    bool   Directory = LocalPath.Contains("/");
                    string Name      = LocalPath.To("/");

                    if (!directoryContents.Any(r => r.Name == Name))
                    {
                        RazorFileInfo fileInfo = new RazorFileInfo
                        {
                            Exists       = true,
                            IsDirectory  = Directory,
                            LastModified = DateTime.MinValue,
                            Name         = Name,
                            PhysicalPath = ""
                        };

                        directoryContents.RazorFileInfo.Add(fileInfo);
                    }
                }
            }

            return(directoryContents);
        }