Custom Provider

2 posts, 0 answers
  1. John
    John avatar
    16 posts
    Member since:
    Jun 2008

    Posted 12 Aug 2010 Link to this post

    I am working with a custom provider and I have added prefixes to my folder names so that they will show up in a specific order.  I have this working except for the first level.  Have I missed something based on by code seen below.

    Public Class CustomFileBrowserProviderWithFilter
        Inherits FileSystemContentProvider
        Public Sub New(ByVal context As HttpContext, ByVal searchPatterns As String(), ByVal viewPaths As String(), ByVal uploadPaths As String(), ByVal deletePaths As String(), ByVal selectedUrl As String, ByVal selectedItemTag As String)
            MyBase.New(context, searchPatterns, viewPaths, uploadPaths, deletePaths, selectedUrl, selectedItemTag)
        End Sub

        Public Overloads Overrides Function ResolveDirectory(ByVal path As String) As DirectoryItem
            Dim originalFolder As DirectoryItem = MyBase.ResolveDirectory(path)
            Dim originalFiles As FileItem() = originalFolder.Files
            Dim filteredFiles As New List(Of FileItem)()

            ' Filter the files
            For Each originalFile As FileItem In originalFiles
                If Not Me.IsFiltered(originalFile.Name) Then
                    filteredFiles.Add(originalFile)
                End If
            Next
            Dim newFolder As New DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, filteredFiles.ToArray(), originalFolder.Directories)

            Return newFolder
        End Function

        Public Overloads Overrides Function ResolveRootDirectoryAsTree(ByVal path As String) As DirectoryItem
            Dim originalFolder As DirectoryItem = MyBase.ResolveRootDirectoryAsTree(path)
            Dim originalDirectories As DirectoryItem() = originalFolder.Directories
            Dim filteredDirectories As New List(Of DirectoryItem)()

            ' Filter the folders
            For Each originalDir As DirectoryItem In originalDirectories
                If Not Me.IsFiltered(originalDir.Name) Then
                    filteredDirectories.Add(originalDir)
                End If
            Next
            For N As Integer = 0 To filteredDirectories.Count - 1
                filteredDirectories(N).Name = filteredDirectories(N).Name.Replace("_", " ").Split("$")(1)
            Next
            Dim newFolder As New DirectoryItem(originalFolder.Name, originalFolder.Location, originalFolder.FullPath, originalFolder.Tag, originalFolder.Permissions, originalFolder.Files, filteredDirectories.ToArray())

            Return newFolder
        End Function

        Private Function IsFiltered(ByVal name As String) As Boolean
            If name.ToLower().EndsWith(".vb") Or name.ToLower().EndsWith(".aspx") Then
                Return True
            End If

            ' else
            Return False
        End Function
    End Class

  2. John
    John avatar
    16 posts
    Member since:
    Jun 2008

    Posted 12 Aug 2010 Link to this post

    Nevermind apparently my computer was cacheing something because it is working now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top