C# Class StopGuessing.AccountStorage.Sql.TableKeyEncoding

Azure tables forbid the folowing characters in PartitionKey and RowKey properties: --The forward slash(/) character --The backslash(\) character --The number sign(#) character --The question mark (?) character --Control characters from U+0000 to U+001F, including: --The horizontal tab(\t) character --The linefeed(\n) character --The carriage return (\r) character --Control characters from U+007F to U+009F (see https://msdn.microsoft.com/library/azure/dd179338.aspx) This class provides a method to encode any string to remove the forbidden characters and allow its use as a PartitionKey or RowKey, as well as a method to decode the keys to recover the original string with the forbidden characters. It encodes forbidden chracters using the '!' (exclamation point) character as an escape character. !! = ! ('!' is a legal character but '!!' is needed to indicate '!' is not escaping anything) !f = / !b = \ !p = # !q = ? !t = \t (tab) !n = \n (line feed) !r = \r (carriage return) !xXY = character with unicode value 0xXY
Mostra file Open project: Microsoft/StopGuessing Class Usage Examples

Public Methods

Method Description
Decode ( string key ) : string

Decode a string that was encoded with the Encode method

Encode ( string unsafeForUseAsAKey ) : string

Encode a string to ensure that it can safely be used as a PartitionKey or RowKey in an AzureTable

Method Details

Decode() public static method

Decode a string that was encoded with the Encode method
public static Decode ( string key ) : string
key string A string that had been encoded with the Encode() method to remove forbidden characters.
return string

Encode() public static method

Encode a string to ensure that it can safely be used as a PartitionKey or RowKey in an AzureTable
public static Encode ( string unsafeForUseAsAKey ) : string
unsafeForUseAsAKey string A string that may contain characters that are forbidden for use in an AzureTable PartitionKey or RowKey.
return string