skip navigation
  • Product Bundles

    DevCraft

    All Telerik .NET tools and Kendo UI JavaScript components in one package. Now enhanced with:

    • NEW: Design Kits for Figma
    • Online Training
    • Document Processing Library
    • Embedded Reporting for web and desktop
    Web
    Kendo UI UI for jQuery UI for Angular UI for React UI for Vue UI for Blazor UI for ASP.NET Core UI for ASP.NET MVC UI for ASP.NET AJAX UI for Silverlight UI for PHP UI for JSP
    Mobile
    UI for .NET MAUI UI for Xamarin
    Document Management
    Telerik Document Processing
    Desktop
    UI for .NET MAUI UI for WinUI UI for WinForms UI for WPF UI for UWP
    Reporting & Mocking
    Telerik Reporting Telerik Report Server Telerik JustMock
    Automated Testing
    Test Studio Test Studio Dev Edition
    CMS
    Sitefinity
    UI/UX Tools
    ThemeBuilder Design System Kit
    Debugging
    Fiddler Fiddler Everywhere Fiddler Classic Fiddler Jam FiddlerCap FiddlerCore
    Extended Reality
    UI for Unity XR
    Free Tools
    JustAssembly JustDecompile VB.NET to C# Converter Testing Framework
    View all products
  • Overview
  • Demos
    • What's New
    • Roadmap
    • Release History
  • Docs & Support
  • Pricing
  • Search
  • Shopping cart
    • Account Overview
    • Your Licenses
    • Downloads
    • Support Center
    • Forum Profile
    • Payment Methods
    • Edit Profile
    • Log out
  • Login
  • Contact Us
  • Try now
Search all

Class ResourceStorage

Represents a resource storage to resolve report resources from local directory.

Inheritance
System.Object
ResourceStorageBase
ResourceStorage
FileDefinitionStorageBase
Inherited Members
ResourceStorageBase.defaultFolders
ResourceStorageBase.DefaultFoldersToCreate
ResourceStorageBase.ValidateSavedResourceExtension(String)
ResourceStorageBase.IsExtensionValid(String)
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Telerik.WebReportDesigner.Services
Assembly: Telerik.WebReportDesigner.Services.dll

Syntax

public class ResourceStorage : ResourceStorageBase, IResourceStorage, IAssetsStorage, IHasBaseDir

Constructors

ResourceStorage(String)

Initializes a new instance of the ResourceStorage class. Creates a new storage for report resources.

Declaration
public ResourceStorage(string baseDir)
Parameters
System.String baseDir

The base directory where the report resources are stored.

ResourceStorage(String, Dictionary<String, String>)

Initializes a new instance of the ResourceStorage class. Creates a new storage for report resources.

Declaration
[Obsolete("extensionDirectories is now obsolete. Please use Telerik.WebReportDesigner.Services.ResourceStorage(string)", false)]
public ResourceStorage(string baseDir, Dictionary<string, string> extensionDirectories)
Parameters
System.String baseDir

The base directory where the report resources are stored.

System.Collections.Generic.Dictionary<System.String, System.String> extensionDirectories

Mapping between resources' extensions and their store directories in the file explorer.

ResourceStorage(String, String[])

Initializes a new instance of the ResourceStorage class. Creates a new storage for report resources.

Declaration
public ResourceStorage(string baseDir, string[] excludedFolders)
Parameters
System.String baseDir

The base directory where the report resources are stored.

System.String[] excludedFolders

Relative folder paths to be excluded when retrieving folder contents. Wildcards are not supported.

ResourceStorage(String, CreateFolderModel[], String[])

Initializes a new instance of the ResourceStorage class. Creates a new storage for report resources.

Declaration
public ResourceStorage(string baseDir, CreateFolderModel[] defaultFolders, string[] excludedFolders)
Parameters
System.String baseDir

The base directory where the report resources are stored.

CreateFolderModel[] defaultFolders

The collection of folders that will be created by default

System.String[] excludedFolders

Relative folder paths to be excluded when retrieving folder contents. Wildcards are not supported.

Exceptions
System.ArgumentNullException

Fields

RootFolderName

The constant name of the Resources root folder.

Declaration
public const string RootFolderName = "Resources"
Field Value
System.String

Properties

BaseDir

Gets the base directory used to access the report resources .

Declaration
public string BaseDir { get; }
Property Value
System.String

Methods

CreateDefaultFolder(CreateFolderModel)

Creates a default folder.

Declaration
protected override void CreateDefaultFolder(CreateFolderModel model)
Parameters
CreateFolderModel model

Overrides
ResourceStorageBase.CreateDefaultFolder(CreateFolderModel)

CreateDirectory(String[])

Creates a directory using the provided relativePaths.

Declaration
protected void CreateDirectory(string[] relativePaths)
Parameters
System.String[] relativePaths

CreateFolderAsync(CreateFolderModel)

Creates the given folder (Name) in ParentUri

Declaration
public virtual Task<ResourceFolderModel> CreateFolderAsync(CreateFolderModel model)
Parameters
CreateFolderModel model

The model containing the create operation data

Returns
System.Threading.Tasks.Task<ResourceFolderModel>

The ResourceFolderModel of the newly created folder

Implements
IAssetsStorage.CreateFolderAsync(CreateFolderModel)

DeleteAsync(String)

Deletes the given resource

Declaration
public virtual Task DeleteAsync(string uri)
Parameters
System.String uri

The unique resource identifier (URI)

Returns
System.Threading.Tasks.Task

Implements
IAssetsStorage.DeleteAsync(String)

DeleteFolderAsync(String)

Delete the given folder at uri

Declaration
public virtual Task DeleteFolderAsync(string uri)
Parameters
System.String uri

The unique resource identifier (URI) of the folder

Returns
System.Threading.Tasks.Task

Implements
IAssetsStorage.DeleteFolderAsync(String)

EnsureDefaultFolders()

Ensures the root and default folders will be created.

Declaration
protected override void EnsureDefaultFolders()
Overrides
ResourceStorageBase.EnsureDefaultFolders()

FolderExists(String)

Determines if the given folder uri exists.

Declaration
public virtual bool FolderExists(string uri)
Parameters
System.String uri

The unique resource identifier (URI) of the folder.

Returns
System.Boolean

true, if the folder exists, else false

Implements
IResourceStorage.FolderExists(String)

FolderHasContents(String)

Gets all resources contained in the given uri

Declaration
public virtual bool FolderHasContents(string uri)
Parameters
System.String uri

The unique resource identifier(URI) of the folder.

Returns
System.Boolean

A list of all resources found in the folder as an enumerable of ResourceModelBase

Implements
IResourceStorage.FolderHasContents(String)

FolderNameExists(String)

Determines if the given folder folderName exists. The default implementation returns the result of the FolderExists(String).

Declaration
public virtual bool FolderNameExists(string folderName)
Parameters
System.String folderName

The path to the folder using Name identifiers.

Returns
System.Boolean

true, if the folder exists, else false

Implements
IResourceStorage.FolderNameExists(String)

GetAllByExtension(String[])

Lists all report resources found in the baseDir folder specified in the constructor and all nested directories

Declaration
public virtual IEnumerable<ResourceFileModel> GetAllByExtension(string[] extensions)
Parameters
System.String[] extensions

The search strings to match against the names of files in the path. This parameter can contain a combination of valid literal path and wildcard (* and ?) characters, but it doesn't support regular expressions.

Returns
System.Collections.Generic.IEnumerable<ResourceFileModel>

A list of all report resource file names and full paths present in the specified directory.

Implements
IResourceStorage.GetAllByExtension(String[])

GetAsync(String)

Finds a report resource file by its name. The name is the full filename (with extension). The default implementation returns the result of the GetByUri(String).

Declaration
public virtual Task<byte[]> GetAsync(string resourceName)
Parameters
System.String resourceName

The report resource filename (with extension).

Returns
System.Threading.Tasks.Task<System.Byte[]>

System.Byte array.

Implements
IAssetsStorage.GetAsync(String)

GetByUri(String)

Finds a resource by its resourceUri and returns its contents as byte array.

Declaration
public virtual byte[] GetByUri(string resourceUri)
Parameters
System.String resourceUri

The unique resource identifier (URI) of the resource.

Returns
System.Byte[]

Implements
IResourceStorage.GetByUri(String)

GetFile(String)

Finds a resource by its URI and returns a model containing the download data.

Declaration
public virtual ResourceFileDataModel GetFile(string resourceUri)
Parameters
System.String resourceUri

The URI of the resource.

Returns
ResourceFileDataModel

Implements
IResourceStorage.GetFile(String)

GetFolderAsync(String)

Gets the folder model at uri.

Declaration
public virtual Task<ResourceFolderModel> GetFolderAsync(string uri)
Parameters
System.String uri

The unique resource identifier (URI).

Returns
System.Threading.Tasks.Task<ResourceFolderModel>

The ResourceFolderModel of the obtained folder.

Implements
IAssetsStorage.GetFolderAsync(String)

GetFolderByName(String)

Gets the folder model at folderName. The default implementation returns the result of the Telerik.WebReportDesigner.Services.ResourceStorage.GetFolder(System.String) method.

Declaration
public virtual ResourceFolderModel GetFolderByName(string folderName)
Parameters
System.String folderName

The path to the folder using Name identifiers.

Returns
ResourceFolderModel

The ResourceFolderModel of the obtained folder.

Implements
IResourceStorage.GetFolderByName(String)

GetFolderContents(String, String[])

Lists all report definition files in the given uri.

Declaration
public virtual IEnumerable<ResourceModelBase> GetFolderContents(string uri, string[] searchPattern)
Parameters
System.String uri

The unique resource identifier(URI) of the folder. null or empty string represents the root (BaseDir) directory

System.String[] searchPattern

Returns
System.Collections.Generic.IEnumerable<ResourceModelBase>

A list of all report definitions and folders found in the folder as an enumerable of ResourceModelBase

GetFolderContentsAsync(String)

Lists all report resource files found in the given uri.

Declaration
public virtual Task<IEnumerable<ResourceModelBase>> GetFolderContentsAsync(string uri)
Parameters
System.String uri

The unique resource identifier(URI) of the folder. null or empty string represents the root (BaseDir) directory

Returns
System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<ResourceModelBase>>

A list of all files and subfolders found in the provided folder URI as an enumerable of ResourceModelBase

Implements
IAssetsStorage.GetFolderContentsAsync(String)

GetModelAsync(String)

Finds a resource by its uri and returns the information about it

Declaration
public virtual Task<ResourceFileModel> GetModelAsync(string resourceUri)
Parameters
System.String resourceUri

The unique resource identifier (URI)

Returns
System.Threading.Tasks.Task<ResourceFileModel>

Implements
IAssetsStorage.GetModelAsync(String)

GetModelByName(String)

Finds a resource by its name and returns the information about it. The default implementation returns the result of the Telerik.WebReportDesigner.Services.ResourceStorage.GetModel(System.String).

Declaration
public virtual ResourceFileModel GetModelByName(string resourceName)
Parameters
System.String resourceName

The full path to the resource using Name identifiers.

Returns
ResourceFileModel

ResourceFileModel, containg the information about the resource.

Implements
IResourceStorage.GetModelByName(String)

GetModelCore<T>(String)

Reads the model of the given type T.

Declaration
protected T GetModelCore<T>(string resourceUri)
    where T : ResourceFileModel, new()
Parameters
System.String resourceUri

Returns
T

Instance of T.

Type Parameters
T

GetOrderedDefaultFoldersToCreate()

Orders the folders to be created in a way that ensures the parents will be created first.

Declaration
protected override IEnumerable<CreateFolderModel> GetOrderedDefaultFoldersToCreate()
Returns
System.Collections.Generic.IEnumerable<CreateFolderModel>

Overrides
ResourceStorageBase.GetOrderedDefaultFoldersToCreate()

Move(MoveResourceModel)

Moves the given resource NewParentUri

Declaration
public virtual ResourceFileModel Move(MoveResourceModel model)
Parameters
MoveResourceModel model

The model containing the move operation data

Returns
ResourceFileModel

ResourceFileModel, containg the information about the folder

Implements
IResourceStorage.Move(MoveResourceModel)

MoveCore<T>(MoveResourceModel)

Moves a resource of the given type T to a new parent.

Declaration
protected T MoveCore<T>(MoveResourceModel model)
    where T : ResourceFileModel, new()
Parameters
MoveResourceModel model

Returns
T

Instance of T.

Type Parameters
T

MoveFolder(MoveFolderModel)

Moves a folder from the given OldUri to NewParentUri, including all of its content

Declaration
public virtual ResourceFolderModel MoveFolder(MoveFolderModel model)
Parameters
MoveFolderModel model

The model containing the move operation data

Returns
ResourceFolderModel

The ResourceFolderModel of the newly created folder

Implements
IResourceStorage.MoveFolder(MoveFolderModel)

Overwrite(OverwriteResourceModel, Byte[])

Overwrties the given resource contents with resource

Declaration
public virtual ResourceFileModel Overwrite(OverwriteResourceModel model, byte[] resource)
Parameters
OverwriteResourceModel model

The model containing the overwrite operation data

System.Byte[] resource

The new contents of the resource

Returns
ResourceFileModel

ResourceFileModel, containg the information about the folder

Implements
IResourceStorage.Overwrite(OverwriteResourceModel, Byte[])

OverwriteCore<T>(OverwriteResourceModel, Byte[])

Overwrites the model of given type T using the provided bytes.

Declaration
public T OverwriteCore<T>(OverwriteResourceModel model, byte[] resource)
    where T : ResourceFileModel, new()
Parameters
OverwriteResourceModel model

System.Byte[] resource

Returns
T

Instance of T.

Type Parameters
T

Exceptions
System.ArgumentNullException

RenameAsync(RenameResourceModel)

Renames the given resource

Declaration
public virtual Task<ResourceFileModel> RenameAsync(RenameResourceModel model)
Parameters
RenameResourceModel model

The model containing the rename operation data

Returns
System.Threading.Tasks.Task<ResourceFileModel>

ResourceFileModel, containg the information about the folder

Implements
IAssetsStorage.RenameAsync(RenameResourceModel)
Exceptions
InvalidResourceNameException

RenameCore<T>(RenameResourceModel)

Renames a resource of the given type T.

Declaration
protected T RenameCore<T>(RenameResourceModel model)
    where T : ResourceFileModel, new()
Parameters
RenameResourceModel model

Returns
T

Instance of T.

Type Parameters
T

RenameFolderAsync(RenameFolderModel)

Renames the given folder at OldUri to Name, including all of its contents (similar to the MoveFolder(MoveFolderModel) method)

Declaration
public virtual Task<ResourceFolderModel> RenameFolderAsync(RenameFolderModel model)
Parameters
RenameFolderModel model

The model containing the rename operation data

Returns
System.Threading.Tasks.Task<ResourceFolderModel>

The ResourceFolderModel of the newly created folder

Implements
IAssetsStorage.RenameFolderAsync(RenameFolderModel)
Exceptions
InvalidFolderNameException

ResourceExists(String)

Determines if a resource with the provided URI exists.

Declaration
public virtual bool ResourceExists(string resourceUri)
Parameters
System.String resourceUri

The unique resource identifier (URI) of the resource.

Returns
System.Boolean

true, if the resource exists, else false.

Implements
IResourceStorage.ResourceExists(String)

ResourceNameExists(String)

Determines if a resource with the provided name exists. The default implementation returns the result of the ResourceExists(String).

Declaration
public virtual bool ResourceNameExists(string resourceName)
Parameters
System.String resourceName

The full path to the resource using Name identifiers.

Returns
System.Boolean

true, if the resource exists, else false.

Implements
IResourceStorage.ResourceNameExists(String)

Save(String, Byte[])

Creates new or overwrites an existing report resource file with the provided resource bytes.

Declaration
[Obsolete("The Telerik.WebReportDesigner.Services.ResourceStorage(string, byte[]) is now obsolete. Please use Telerik.WebReportDesigner.Services.ResourceStorage(SaveResourceModel, byte[])", false)]
public virtual string Save(string resourceName, byte[] resource)
Parameters
System.String resourceName

The report resource filename including the file extension.

System.Byte[] resource

The new bytes of the report resource.

Returns
System.String

The location of the resource file.

Implements
IResourceStorage.Save(String, Byte[])

SaveAsync(SaveResourceModel, Byte[])

Saves the new bytes of a resource and returns the information about it.

Declaration
public virtual Task<ResourceFileModel> SaveAsync(SaveResourceModel model, byte[] resource)
Parameters
SaveResourceModel model

The model containing the save operation data

System.Byte[] resource

The contents of the resource

Returns
System.Threading.Tasks.Task<ResourceFileModel>

Implements
IAssetsStorage.SaveAsync(SaveResourceModel, Byte[])
Exceptions
InvalidResourceNameException

SaveAsync(SaveResourceModel, Byte[], Boolean)

Saves the new bytes of a resource and returns the information about it.

Declaration
public virtual Task<ResourceFileModel> SaveAsync(SaveResourceModel model, byte[] resource, bool forcePath)
Parameters
SaveResourceModel model

The model containing the save operation data

System.Byte[] resource

The contents of the resource

System.Boolean forcePath

Determines whether the path to the resource will be created, if it does not exist, or an exception will be thrown.

Returns
System.Threading.Tasks.Task<ResourceFileModel>

Exceptions
InvalidResourceNameException

SaveCore<T>(SaveResourceModel, Byte[], Boolean)

Saves the model of the given type T using the provided bytes.

Declaration
protected T SaveCore<T>(SaveResourceModel model, byte[] resource, bool forcePath)
    where T : ResourceFileModel, new()
Parameters
SaveResourceModel model

The model containing the save operation data

System.Byte[] resource

The contents of the resource

System.Boolean forcePath

Determines whether the path to the resource will be created, if it does not exist, or an exception will be thrown.

Returns
T

Instance of T.

Type Parameters
T

Exceptions
ResourceAlreadyExistsException

Search(SearchResourcesModel)

Searches for resource in the given ResourceFolderUri

Declaration
public virtual IEnumerable<ResourceModelBase> Search(SearchResourcesModel model)
Parameters
SearchResourcesModel model

The model containing the search operation data. The SearchPattern can contain a combination of valid literal path and wildcard (* and ?) characters, but regular expressions are not supported.

Returns
System.Collections.Generic.IEnumerable<ResourceModelBase>

The search results, both files and folders, as an enumerable of ResourceModelBase

Implements
IResourceStorage.Search(SearchResourcesModel)

Was this article helpful?

Tell us how we can improve this article

Skip
Getting Started
  • Install Now
  • Online Demos
Support Resources
  • Documentation
  • Knowledge Base
  • Videos
  • Reporting Samples Repository
  • Reporting Release History
Community
  • Forums
  • Blogs
  • Reporting Feedback Portal

Copyright © 2018 Progress Software Corporation and/or its subsidiaries or affiliates.
All Rights Reserved.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks for appropriate markings.