public override IPartialView Get(string id)
        {
            // get the relative path within the filesystem
            // (though... id should be relative already)
            var path = FileSystem.GetRelativePath(id);

            if (FileSystem.FileExists(path) == false)
            {
                return(null);
            }

            // content will be lazy-loaded when required
            var created = FileSystem.GetCreated(path).UtcDateTime;
            var updated = FileSystem.GetLastModified(path).UtcDateTime;
            //var content = GetFileContent(path);

            var view = new PartialView(ViewType, path, file => GetFileContent(file.OriginalPath))
            {
                //id can be the hash
                Id  = path.GetHashCode(),
                Key = path.EncodeAsGuid(),
                //Content = content,
                CreateDate  = created,
                UpdateDate  = updated,
                VirtualPath = FileSystem.GetUrl(id)
            };

            //on initial construction we don't want to have dirty properties tracked
            // http://issues.umbraco.org/issue/U4-1946
            view.ResetDirtyProperties(false);

            return(view);
        }
Esempio n. 2
0
    public override IPartialView?Get(string?id)
    {
        if (FileSystem is null)
        {
            return(null);
        }

        // get the relative path within the filesystem
        // (though... id should be relative already)
        var path = FileSystem.GetRelativePath(id !);

        if (FileSystem.FileExists(path) == false)
        {
            return(null);
        }

        // content will be lazy-loaded when required
        DateTime created = FileSystem.GetCreated(path).UtcDateTime;
        DateTime updated = FileSystem.GetLastModified(path).UtcDateTime;

        // var content = GetFileContent(path);
        var view = new PartialView(ViewType, path, file => GetFileContent(file.OriginalPath))
        {
            // id can be the hash
            Id  = path.GetHashCode(),
            Key = path.EncodeAsGuid(),

            // Content = content,
            CreateDate  = created,
            UpdateDate  = updated,
            VirtualPath = FileSystem.GetUrl(id),
        };

        // reset dirty initial properties (U4-1946)
        view.ResetDirtyProperties(false);

        return(view);
    }