C# Class Bloom.UrlPathString

A wrapper around string designed to reduced bugs introduced by losing track of the encoded/unencoded state of a string. It does this by requiring users to specify what they are putting in/getting out, and it keeps track.
Exibir arquivo Open project: BloomBooks/BloomDesktop Class Usage Examples

Public Methods

Method Description
CreateFromHtmlXmlEncodedString ( string encoded ) : UrlPathString

In these strings, "&" would be & space would just be " "

CreateFromUnencodedString ( string unencoded, bool strictlyTreatAsEncoded = false ) : UrlPathString
CreateFromUrlEncodedString ( string encoded ) : UrlPathString

NOTE: Assumes '+' is literal. See BL-3259

Equals ( object obj ) : bool
GetFullyDecodedPath ( string directory, string &filename ) : string

Some library books have been uploaded with the cover image filename URL encoded in the file instead of HTML/XML encoded. So if the file doesn't exist, try one more level of decoding to see if that may be the problem, but preserve the original path in case an error message is still needed.

See https://silbloom.myjetbrains.com/youtrack/issue/BL-3901.

GetHashCode ( ) : int
operator ( ) : bool

Protected Methods

Method Description
Equals ( UrlPathString other ) : bool

Private Methods

Method Description
UrlPathString ( string notEncodedString ) : System.Diagnostics

Method Details

CreateFromHtmlXmlEncodedString() public static method

In these strings, "&" would be & space would just be " "
public static CreateFromHtmlXmlEncodedString ( string encoded ) : UrlPathString
encoded string
return UrlPathString

CreateFromUnencodedString() public static method

public static CreateFromUnencodedString ( string unencoded, bool strictlyTreatAsEncoded = false ) : UrlPathString
unencoded string
strictlyTreatAsEncoded bool
return UrlPathString

CreateFromUrlEncodedString() public static method

NOTE: Assumes '+' is literal. See BL-3259
public static CreateFromUrlEncodedString ( string encoded ) : UrlPathString
encoded string
return UrlPathString

Equals() protected method

protected Equals ( UrlPathString other ) : bool
other UrlPathString
return bool

Equals() public method

public Equals ( object obj ) : bool
obj object
return bool

GetFullyDecodedPath() public static method

Some library books have been uploaded with the cover image filename URL encoded in the file instead of HTML/XML encoded. So if the file doesn't exist, try one more level of decoding to see if that may be the problem, but preserve the original path in case an error message is still needed.
See https://silbloom.myjetbrains.com/youtrack/issue/BL-3901.
public static GetFullyDecodedPath ( string directory, string &filename ) : string
directory string path of the containing folder
filename string base filename to be combined with directory. This may be modified by HttpUtility.UrlDecode().
return string

GetHashCode() public method

public GetHashCode ( ) : int
return int

operator() public static method

public static operator ( ) : bool
return bool