C# Класс mybox.Common

A class which is used to store common functions common to the client and server
Показать файл Открыть проект

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

Свойство Тип Описание
TempDir String
UserHome String

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

Метод Описание
BufferToSignal ( byte buffer ) : Signal

Convert a byte array to a single byte signal

CreateLocalDirectory ( String absPath ) : bool

Create a directory on the local filesystem if it does not exist

DateTimeToUnixTimestamp ( System.DateTime dateTime ) : long

Convert DateTime to unix timestamp.

DeleteLocal ( String absPath ) : bool

Delete a local file or directory

EncryptPassword ( string pwd, string salt ) : string

Enrcypt a password with a salt and return the result

EndDirWithSlash ( String absPath ) : string

Make sure the input directory path has a trailing slash.

ExitError ( ) : void

Quit the program when an error occurs.

FileChecksumToBytes ( String absPath ) : byte[]
FileChecksumToString ( String absPath ) : String
GenerateSalt ( int size ) : string

Generates a random salt for password encryption purposes

GetFilesRecursive ( string baseDir ) : List

Gets a recursive listing of files from a directory

GetModTime ( String fullPath ) : long

Get the data modification time of a local file

Md5Hash ( String input ) : String

Md5 digest a string.

ReceiveFile ( Socket socket, string baseDir ) : MyFile

Receive a file over a socket

ReceiveString ( Socket socket ) : String

Get a string from a socket which is sent by SendString

SendString ( Socket socket, String str ) : bool

Send a string along a socket

Sha256Hash ( String input ) : String

Compute Sha256 for a string.

ShowCliHelp ( OptionSet options, Assembly thisAssembly ) : void

Display the command line options and then exit.

SignalToBuffer ( Signal signal ) : byte[]

Convert the signal to a byte array

UnixTimeStampToDateTime ( long unixTimeStamp ) : System.DateTime

Convert UNIX timestamp to a datetime object

Приватные методы

Метод Описание
SendFile ( String relPath, Socket socket, String baseDir ) : MyFile

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

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

Convert a byte array to a single byte signal
public static BufferToSignal ( byte buffer ) : Signal
buffer byte
Результат Signal

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

Create a directory on the local filesystem if it does not exist
public static CreateLocalDirectory ( String absPath ) : bool
absPath String
Результат bool

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

Convert DateTime to unix timestamp.
public static DateTimeToUnixTimestamp ( System.DateTime dateTime ) : long
dateTime System.DateTime /// DateTime ///
Результат long

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

Delete a local file or directory
public static DeleteLocal ( String absPath ) : bool
absPath String the absolute path to the item
Результат bool

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

Enrcypt a password with a salt and return the result
public static EncryptPassword ( string pwd, string salt ) : string
pwd string
salt string
Результат string

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

Make sure the input directory path has a trailing slash.
public static EndDirWithSlash ( String absPath ) : string
absPath String
Результат string

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

Quit the program when an error occurs.
public static ExitError ( ) : void
Результат void

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

public static FileChecksumToBytes ( String absPath ) : byte[]
absPath String
Результат byte[]

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

public static FileChecksumToString ( String absPath ) : String
absPath String
Результат String

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

Generates a random salt for password encryption purposes
public static GenerateSalt ( int size ) : string
size int the length in bytes of the salt
Результат string

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

Gets a recursive listing of files from a directory
public static GetFilesRecursive ( string baseDir ) : List
baseDir string
Результат List

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

Get the data modification time of a local file
public static GetModTime ( String fullPath ) : long
fullPath String
Результат long

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

Md5 digest a string.
public static Md5Hash ( String input ) : String
input String /// Any string ///
Результат String

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

Receive a file over a socket
public static ReceiveFile ( Socket socket, string baseDir ) : MyFile
socket System.Net.Sockets.Socket
baseDir string the base directory the file will live in
Результат MyFile

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

Get a string from a socket which is sent by SendString
public static ReceiveString ( Socket socket ) : String
socket System.Net.Sockets.Socket
Результат String

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

Send a string along a socket
public static SendString ( Socket socket, String str ) : bool
socket System.Net.Sockets.Socket
str String
Результат bool

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

Compute Sha256 for a string.
public static Sha256Hash ( String input ) : String
input String /// Input. ///
Результат String

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

Display the command line options and then exit.
public static ShowCliHelp ( OptionSet options, Assembly thisAssembly ) : void
options OptionSet
thisAssembly System.Reflection.Assembly
Результат void

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

Convert the signal to a byte array
public static SignalToBuffer ( Signal signal ) : byte[]
signal Signal
Результат byte[]

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

Convert UNIX timestamp to a datetime object
public static UnixTimeStampToDateTime ( long unixTimeStamp ) : System.DateTime
unixTimeStamp long /// Unix time stamp. ///
Результат System.DateTime

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

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

The system temp directory
public static String TempDir
Результат String

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

The user's system home directory primarialy used for determining where the config directory is
public static String UserHome
Результат String