C# Class Simple301.Core.RedirectRepository

Redirect Repository that handles CRUD operations for the repository collection Utilizes Umbraco Database context to persist redirects into the database but utilizes an in-memory collection for fast querying.
Mostra file Open project: wkallhof/Simple301 Class Usage Examples

Public Methods

Method Description
AddRedirect ( bool isRegex, string oldUrl, string newUrl, string notes ) : Redirect

Add a new redirect to the redirects collection

DeleteRedirect ( int id ) : void

Handles deleting a redirect from the redirect collection

FindRedirect ( string oldUrl ) : Redirect

Handles finding a redirect based on the oldUrl

GetAllRedirects ( ) : IEnumerable

Get all redirects from the repositry

GetLookupTable ( ) : Redirect>.Dictionary

Get the lookup table for quick lookups

UpdateRedirect ( Redirect redirect ) : Redirect

Update a given redirect

Private Methods

Method Description
DetectLoop ( string oldUrl, string newUrl ) : bool

Detects a loop in the redirects list given the new redirect. Uses Floyd's cycle-finding algorithm.

FetchRedirectById ( int id ) : Redirect

Fetches a single redirect from the DB based on an Id

FetchRedirectsFromDb ( ) : Redirect>.Dictionary

Fetches all redirects from the database

RedirectRepository ( ) : System

Method Details

AddRedirect() public static method

Add a new redirect to the redirects collection
public static AddRedirect ( bool isRegex, string oldUrl, string newUrl, string notes ) : Redirect
isRegex bool
oldUrl string Old Url to redirect from
newUrl string New Url to redirect to
notes string Any associated notes with this redirect
return Simple301.Core.Models.Redirect

DeleteRedirect() public static method

Handles deleting a redirect from the redirect collection
public static DeleteRedirect ( int id ) : void
id int Id of redirect to remove
return void

FindRedirect() public static method

Handles finding a redirect based on the oldUrl
public static FindRedirect ( string oldUrl ) : Redirect
oldUrl string Url to search for
return Simple301.Core.Models.Redirect

GetAllRedirects() public static method

Get all redirects from the repositry
public static GetAllRedirects ( ) : IEnumerable
return IEnumerable

GetLookupTable() public static method

Get the lookup table for quick lookups
public static GetLookupTable ( ) : Redirect>.Dictionary
return Redirect>.Dictionary

UpdateRedirect() public static method

Update a given redirect
public static UpdateRedirect ( Redirect redirect ) : Redirect
redirect Simple301.Core.Models.Redirect Redirect to update
return Simple301.Core.Models.Redirect