C# Класс kOS.Safe.Persistence.PersistenceUtilities

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
GzipHeader byte[]

Открытые методы

Метод Описание
CharNeedsEncoding ( char character ) : bool

Returns true if the character has to be encoded and cannot be dumped into a persistence file as-is.

CookedFilename ( string fileName, string extensionName, bool trusted = false ) : string

This is both for error checking and blessing of user-created filenames, and to tack on a filename extension if there is none present.


Returns a version of the filename in which it has had the file extension added unless the filename already has any sort of file extension, in which case nothing is changed about it. If every place where the auto- extension-appending is attempted is done via this method, then it will never end up adding an extension when an explicit one exists already.

DecodeBase64ToBinary ( string input ) : byte[]
DecodeLine ( string input ) : string
EncodeBase64 ( byte input ) : string
EncodeLine ( string input ) : string
IdentifyCategory ( byte firstBytes ) : FileCategory

Given the first few bytes of content, decide what the FileCategory should be, based on what's in the Content.
This should be called before deciding how to set the content.

IsBinary ( FileCategory category ) : bool

Описание методов

CharNeedsEncoding() публичный статический Метод

Returns true if the character has to be encoded and cannot be dumped into a persistence file as-is.
public static CharNeedsEncoding ( char character ) : bool
character char character to test
Результат bool

CookedFilename() публичный статический Метод

This is both for error checking and blessing of user-created filenames, and to tack on a filename extension if there is none present.


Returns a version of the filename in which it has had the file extension added unless the filename already has any sort of file extension, in which case nothing is changed about it. If every place where the auto- extension-appending is attempted is done via this method, then it will never end up adding an extension when an explicit one exists already.
public static CookedFilename ( string fileName, string extensionName, bool trusted = false ) : string
fileName string Filename to maybe change. Can be full path or just the filename.
extensionName string Extension to add if there is none already.
trusted bool True if the filename is internally generated (and therefore allowed to /// have paths in it). False if the filename is from a user-land string (and therefore allowing /// a name that walks the directory tree is a security hole.)
Результат string

DecodeBase64ToBinary() публичный статический Метод

public static DecodeBase64ToBinary ( string input ) : byte[]
input string
Результат byte[]

DecodeLine() публичный статический Метод

public static DecodeLine ( string input ) : string
input string
Результат string

EncodeBase64() публичный статический Метод

public static EncodeBase64 ( byte input ) : string
input byte
Результат string

EncodeLine() публичный статический Метод

public static EncodeLine ( string input ) : string
input string
Результат string

IdentifyCategory() публичный статический Метод

Given the first few bytes of content, decide what the FileCategory should be, based on what's in the Content.
This should be called before deciding how to set the content.
public static IdentifyCategory ( byte firstBytes ) : FileCategory
firstBytes byte At least the first four bytes of the file read in binary form - can be longer if you wish
Результат FileCategory

IsBinary() публичный статический Метод

public static IsBinary ( FileCategory category ) : bool
category FileCategory
Результат bool

Описание свойств

GzipHeader публичное статическое свойство

public static byte[] GzipHeader
Результат byte[]