Class ResourceStorage
Represents a resource storage to resolve report resources from local directory.
Inherited Members
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
CreateDirectory(String[])
Creates a directory using the provided relativePaths.
Declaration
protected void CreateDirectory(string[] relativePaths)
Parameters
|
System.String[]
relativePaths
|
CreateFolderAsync(CreateFolderModel)
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
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
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
EnsureDefaultFolders()
Ensures the root and default folders will be created.
Declaration
protected override void EnsureDefaultFolders()
Overrides
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
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
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
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
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
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
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
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
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
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
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
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
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 |
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
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
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 |
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
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
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 |
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
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 |
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
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
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
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
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
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 |
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 |