internal object DirectoryToJsonModel(Site site, string path, Fields fields = null, bool full = true)
        {
            if (string.IsNullOrEmpty(path))
            {
                throw new ArgumentNullException(nameof(path));
            }

            if (fields == null)
            {
                fields = Fields.All;
            }

            var directory = _fileProvider.GetDirectory(GetPhysicalPath(site, path));

            path = path.Replace('\\', '/');

            dynamic obj    = new ExpandoObject();
            var     FileId = new FileId(site.Id, path);

            //
            // name
            if (fields.Exists("name"))
            {
                obj.name = directory.Name;
            }

            //
            // id
            if (fields.Exists("id"))
            {
                obj.id = FileId.Uuid;
            }

            //
            // type
            if (fields.Exists("type"))
            {
                obj.type = Enum.GetName(typeof(FileType), FileType.Directory).ToLower();
            }

            //
            // path
            if (fields.Exists("path"))
            {
                obj.path = path;
            }

            //
            // parent
            if (fields.Exists("parent"))
            {
                obj.parent = GetParentJsonModelRef(site, path, fields.Filter("parent"));
            }

            //
            // website
            if (fields.Exists("website"))
            {
                obj.website = SiteHelper.ToJsonModelRef(site, fields.Filter("website"));
            }

            //
            // file_info
            if (fields.Exists("file_info"))
            {
                obj.file_info = _filesHelper.ToJsonModelRef(directory, fields.Filter("file_info"));
            }

            return(Core.Environment.Hal.Apply(Defines.DirectoriesResource.Guid, obj, full));
        }
        internal object VdirToJsonModel(Vdir vdir, Fields fields = null, bool full = true)
        {
            if (vdir == null)
            {
                return(null);
            }

            if (fields == null)
            {
                fields = Fields.All;
            }

            var directory = _fileProvider.GetDirectory(GetPhysicalPath(vdir.Site, vdir.Path));

            dynamic obj    = new ExpandoObject();
            var     FileId = new FileId(vdir.Site.Id, vdir.Path);

            //
            // name
            if (fields.Exists("name"))
            {
                obj.name = vdir.Path.TrimStart('/');
            }

            //
            // id
            if (fields.Exists("id"))
            {
                obj.id = FileId.Uuid;
            }

            //
            // type
            if (fields.Exists("type"))
            {
                obj.type = Enum.GetName(typeof(FileType), Vdir.GetVdirType(vdir.VirtualDirectory)).ToLower();
            }

            //
            // path
            if (fields.Exists("path"))
            {
                obj.path = vdir.Path.Replace('\\', '/');
            }

            //
            // parent
            if (fields.Exists("parent"))
            {
                obj.parent = GetParentVdirJsonModelRef(vdir, fields.Filter("parent"));
            }

            //
            // website
            if (fields.Exists("website"))
            {
                obj.website = SiteHelper.ToJsonModelRef(vdir.Site, fields.Filter("website"));
            }

            //
            // file_info
            if (fields.Exists("file_info"))
            {
                obj.file_info = _filesHelper.ToJsonModelRef(directory, fields.Filter("file_info"));
            }

            return(Core.Environment.Hal.Apply(Defines.DirectoriesResource.Guid, obj, full));
        }