Class
FileDefinitionStorageBase

Abstract base class for file-based definition storage implementations in the WebReportDesigner system.

Definition

Namespace:Telerik.WebReportDesigner.Services

Assembly:Telerik.WebReportDesigner.Services.dll

Syntax:

cs-api-definition
public abstract class FileDefinitionStorageBase : ResourceStorage, IResourceStorage, IAssetsStorage

Inheritance: objectResourceStorageBaseResourceStorageFileDefinitionStorageBase

Derived Classes: FileDefinitionStorageFileSharedDataSourceStorageFileTemplateDefinitionStorage

Implements: IAssetsStorageIResourceStorage

Inherited Members ResourceStorage.RootFolderNameResourceStorage.GetOrderedDefaultFoldersToCreate()ResourceStorage.GetAllByExtension(string[])ResourceStorage.GetFolderContentsAsync(string)ResourceStorage.FolderHasContents(string)ResourceStorage.GetFolderByName(string)ResourceStorage.CreateFolderAsync(CreateFolderModel)ResourceStorage.MoveFolder(MoveFolderModel)ResourceStorage.RenameFolderAsync(RenameFolderModel)ResourceStorage.DeleteFolderAsync(string)ResourceStorage.FolderNameExists(string)ResourceStorage.FolderExists(string)ResourceStorage.GetAsync(string)ResourceStorage.GetByUri(string)ResourceStorage.ResourceNameExists(string)ResourceStorage.ResourceExists(string)ResourceStorage.GetFile(string)ResourceStorage.GetModelByName(string)ResourceStorage.GetModelCore<T>(string)ResourceStorage.Save(string, byte[])ResourceStorage.SaveAsync(SaveResourceModel, byte[])ResourceStorage.SaveAsync(SaveResourceModel, byte[], bool)ResourceStorage.SaveCore<T>(SaveResourceModel, byte[], bool)ResourceStorage.Overwrite(OverwriteResourceModel, byte[])ResourceStorage.OverwriteCore<T>(OverwriteResourceModel, byte[])ResourceStorage.RenameAsync(RenameResourceModel)ResourceStorage.RenameCore<T>(RenameResourceModel)ResourceStorage.Move(MoveResourceModel)ResourceStorage.MoveCore<T>(MoveResourceModel)ResourceStorage.Search(SearchResourcesModel)ResourceStorage.CreateDirectory(string[])ResourceStorage.EnsureDefaultFolders()ResourceStorage.CreateDefaultFolder(CreateFolderModel)ResourceStorage.BaseDirResourceStorageBase.defaultFoldersResourceStorageBase.DefaultFoldersToCreateResourceStorageBase.ValidateSavedResourceExtension(string)ResourceStorageBase.IsExtensionValid(string)

Constructors

FileDefinitionStorageBase(string, string[])

Creates an instance of FileDefinitionStorageBase class.

Declaration

cs-api-definition
public FileDefinitionStorageBase(string baseDir, string[] definitionFolders)

Parameters

baseDir

string

The base directory where definition files are stored.

definitionFolders

string[]

The collection of definition folders to be created by default.

Remarks

Creates a definition storage with the specified base directory and default folder structure, using no excluded folders.

FileDefinitionStorageBase(string, string[], string[])

Creates an instance of FileDefinitionStorageBase class.

Declaration

cs-api-definition
public FileDefinitionStorageBase(string baseDir, string[] definitionFolders, string[] excludedFolders)

Parameters

baseDir

string

The base directory where definition files are stored.

definitionFolders

string[]

The collection of definition folders to be created by default.

excludedFolders

string[]

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

Remarks

Creates a definition storage with specified base directory, default folders, and the ability to exclude specific folders from operations.

Properties

FileExtensions

Gets the array of allowed file extensions for this definition storage.

Declaration

cs-api-definition
protected abstract string[] FileExtensions { get; }

Property Value

string[]

Remarks

Implemented by derived classes to specify which file extensions are valid for the particular definition type being managed.

Methods

DeleteAsync(string)

Deletes a definition file by its URI.

Declaration

cs-api-definition
public override Task DeleteAsync(string uri)

Parameters

uri

string

The unique resource identifier (URI) of the definition.

Returns

Task

Overrides ResourceStorage.DeleteAsync(string)

Remarks

Validates the definition identifier before deletion and suppresses ResourceNotFoundException for non-existing definitions, allowing idempotent delete operations.

GetByUri<TDefinitionNotFoundException>(string)

Retrieves the raw bytes from the specified definition resource.

Declaration

cs-api-definition
protected virtual byte[] GetByUri<TDefinitionNotFoundException>(string uri) where TDefinitionNotFoundException : Exception

Parameters

uri

string

The unique resource identifier of the definition.

Returns

byte[]

The definition content as a byte array.

Remarks

Validates the definition identifier and wraps resource exceptions in definition-specific exceptions for consistent error handling.

GetFolderAsync(string)

Retrieves the folder model at the specified URI or returns null if not found.

Declaration

cs-api-definition
public override Task<ResourceFolderModel> GetFolderAsync(string uri)

Parameters

uri

string

The unique resource identifier of the folder.

Returns

Task<ResourceFolderModel>

The ResourceFolderModel or null if the folder is not found.

Overrides ResourceStorage.GetFolderAsync(string)

Remarks

Provides null-safe folder retrieval by catching ResourceFolderNotFoundException and returning null instead of propagating the exception.

GetFolderContents(string, string[])

Lists all definition resource files found in the given uri.

Declaration

cs-api-definition
public override IEnumerable<ResourceModelBase> GetFolderContents(string uri, string[] searchPattern)

Parameters

uri

string

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

searchPattern

string[]

The file search patterns used when retrieving definition resources.

Returns

IEnumerable<ResourceModelBase>

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

Overrides ResourceStorage.GetFolderContents(string, string[])

Remarks

Overrides the base implementation to use the storage-specific file extensions instead of the provided search pattern, ensuring only valid definition files are returned.

GetModelAsync(string)

Retrieves the resource model at the specified URI or returns null if not found.

Declaration

cs-api-definition
public override Task<ResourceFileModel> GetModelAsync(string uri)

Parameters

uri

string

The unique resource identifier of the resource.

Returns

Task<ResourceFileModel>

The ResourceFileModel or null if the resource is not found.

Overrides ResourceStorage.GetModelAsync(string)

Remarks

Provides null-safe resource retrieval by catching ResourceNotFoundException and returning null instead of propagating the exception.

RenameAsync<TInvalidDefinitionNameException>(RenameResourceModel)

Renames a definition file.

Declaration

cs-api-definition
protected virtual Task<ResourceFileModel> RenameAsync<TInvalidDefinitionNameException>(RenameResourceModel model) where TInvalidDefinitionNameException : Exception

Parameters

model

RenameResourceModel

The model containing rename operation data.

Returns

Task<ResourceFileModel>

A task representing the asynchronous rename operation with the updated resource model.

Remarks

Wraps invalid resource name exceptions in definition-specific exceptions for consistent error handling across different definition types.

Save(SaveResourceModel, byte[], bool, bool)

Creates a new or overwrites an existing definition file with the provided content.

Declaration

cs-api-definition
public ResourceFileModel Save(SaveResourceModel model, byte[] resource, bool overwrite, bool forcePath)

Parameters

model

SaveResourceModel

The model containing save operation data.

resource

byte[]

The definition content as a byte array.

overwrite

bool

Whether to overwrite existing files.

forcePath

bool

Whether to create the directory path if it doesn't exist.

Returns

ResourceFileModel

The ResourceFileModel of the saved definition.

Remarks

Validates the definition identifier and handles both new file creation and existing file overwrite scenarios with proper path management.

SaveAsync<TDefinitionNotFoundException>(SaveResourceModel, byte[])

Saves a definition file to the storage system.

Declaration

cs-api-definition
protected virtual Task<ResourceFileModel> SaveAsync<TDefinitionNotFoundException>(SaveResourceModel model, byte[] resource) where TDefinitionNotFoundException : Exception

Parameters

model

SaveResourceModel

The model containing save operation data.

resource

byte[]

The definition content as a byte array.

Returns

Task<ResourceFileModel>

A task representing the asynchronous save operation with the saved resource model.

Remarks

Wraps resource not found exceptions in definition-specific exceptions for consistent error handling during save operations.

ValidateDefinitionId(string)

Validates the provided definition identifier according to the storage's rules.

Declaration

cs-api-definition
protected abstract void ValidateDefinitionId(string definitionId)

Parameters

definitionId

string

The definition identifier to validate.

Remarks

Implemented by derived classes to enforce specific naming conventions and validation rules for definition identifiers.

WrapException<TResult, TDefinitionException, TResourceException>(Func<TResult>)

Executes a callback and wraps resource exceptions in definition-specific exceptions.

Declaration

cs-api-definition
protected TResult WrapException<TResult, TDefinitionException, TResourceException>(Func<TResult> callback) where TDefinitionException : Exception where TResourceException : Exception

Parameters

callback

Func<TResult>

The operation to execute.

Returns

TResult

The result of the callback operation.

Remarks

Provides consistent exception handling by converting generic resource exceptions into definition-specific exceptions with preserved inner exception details.