C# Class CsQuery.Utility.Support

Some static methods that didn't fit in anywhere else.
Mostra file Open project: prepare/HTML-Renderer Class Usage Examples

Public Methods

Method Description
CleanFilePath ( string path ) : string

Convert slashes to backslashes; make sure there's one (or zero, if not rooted) leading or trailing backslash; resolve parent and current folder references. Missing values are returned as just one backslash.

CombinePaths ( string path1, string path2 ) : string

Combine two file paths, normalizing slashes and eliminating any relative path markers.

CopyFiles ( DirectoryInfo source, DirectoryInfo destination ) : void

Copies files matching a pattern. Existing files will be overwritten.

CopyFiles ( DirectoryInfo source, DirectoryInfo destination, bool overwrite ) : void

Copies files matching a pattern.

DeleteFiles ( DirectoryInfo directory ) : void

Deletes the files in a directory matching one or more patterns (nonrecursive)

DoubleOrZero ( string value ) : double

Convert a string value to a double, or zero if non-numeric

EnumToAttribute ( Enum value ) : string

Convert an enum to a lowercased attribute value

FromCamelCase ( string name ) : string

Given a string, convert each uppercase letter to a "-" followed by the lower case letter. E.g. "fontSize" becomes "font-size".

GetEncodedStream ( string html, Encoding encoding ) : Stream

Return a stream, including BOM preamble, from a string

GetFirstExternalAssembly ( ) : Assembly

Gets the first assembly that is not the assembly that this method belongs to

GetResourceStream ( string resourceName ) : Stream

Gets a resource from the calling assembly

GetResourceStream ( string resourceName, Assembly assembly ) : Stream

Gets a resource name using the assembly and resource name

GetResourceStream ( string resourceName, string assembly ) : Stream

Gets an embedded resource from an assembly by name

IntOrZero ( string value ) : int

Convert a string value to an integer, or zero if non-numeric

MethodPath ( MemberInfo mi ) : string

Get a fully qualified namespaced path to a member

MethodPath ( Type type, string memberName ) : string

Get a fully qualified namespaced path to a member.

NumberToDoubleOrInt ( IConvertible value ) : IConvertible

Return an int or double from any number.

StreamToCharArray ( Stream stream ) : char[]

Conver a stream to a character array.

StreamToString ( Stream stream ) : string

Convert a string to a stream using ASCII encoding.

TypePath ( Type type ) : string

Get a fully qualified namespaced path to a type, e.g. "CsQuery.Utility.Support.TypePath"

Private Methods

Method Description
RemoveRelativePath ( string path ) : string

Method Details

CleanFilePath() public static method

Convert slashes to backslashes; make sure there's one (or zero, if not rooted) leading or trailing backslash; resolve parent and current folder references. Missing values are returned as just one backslash.
public static CleanFilePath ( string path ) : string
path string /// The path to clean ///
return string

CombinePaths() public static method

Combine two file paths, normalizing slashes and eliminating any relative path markers.
public static CombinePaths ( string path1, string path2 ) : string
path1 string /// The first path. ///
path2 string /// The second path. ///
return string

CopyFiles() public static method

Copies files matching a pattern. Existing files will be overwritten.
public static CopyFiles ( DirectoryInfo source, DirectoryInfo destination ) : void
source System.IO.DirectoryInfo /// Source directory for the files ///
destination System.IO.DirectoryInfo /// Destination directory. ///
return void

CopyFiles() public static method

Copies files matching a pattern.
/// Thrown when one or more arguments have unsupported or illegal values. ///
public static CopyFiles ( DirectoryInfo source, DirectoryInfo destination, bool overwrite ) : void
source System.IO.DirectoryInfo /// Source for the. ///
destination System.IO.DirectoryInfo /// Destination for the. ///
overwrite bool /// true to overwrite, false to preserve. ///
return void

DeleteFiles() public static method

Deletes the files in a directory matching one or more patterns (nonrecursive)
/// Thrown when the directory is missing ///
public static DeleteFiles ( DirectoryInfo directory ) : void
directory System.IO.DirectoryInfo /// Directory where files are located. ///
return void

DoubleOrZero() public static method

Convert a string value to a double, or zero if non-numeric
public static DoubleOrZero ( string value ) : double
value string /// The value. ///
return double

EnumToAttribute() public static method

Convert an enum to a lowercased attribute value
public static EnumToAttribute ( Enum value ) : string
value System.Enum /// The value. ///
return string

FromCamelCase() public static method

Given a string, convert each uppercase letter to a "-" followed by the lower case letter. E.g. "fontSize" becomes "font-size".
public static FromCamelCase ( string name ) : string
name string /// The string to uncamelcase ///
return string

GetEncodedStream() public static method

Return a stream, including BOM preamble, from a string
public static GetEncodedStream ( string html, Encoding encoding ) : Stream
html string /// The HTML. ///
encoding System.Text.Encoding /// The encoding. ///
return Stream

GetFirstExternalAssembly() public static method

Gets the first assembly that is not the assembly that this method belongs to
/// Thrown when the requested operation is invalid. ///
public static GetFirstExternalAssembly ( ) : Assembly
return System.Reflection.Assembly

GetResourceStream() public static method

Gets a resource from the calling assembly
public static GetResourceStream ( string resourceName ) : Stream
resourceName string
return Stream

GetResourceStream() public static method

Gets a resource name using the assembly and resource name
public static GetResourceStream ( string resourceName, Assembly assembly ) : Stream
resourceName string
assembly System.Reflection.Assembly
return Stream

GetResourceStream() public static method

Gets an embedded resource from an assembly by name
public static GetResourceStream ( string resourceName, string assembly ) : Stream
resourceName string /// The resource name ///
assembly string /// The assembly name ///
return Stream

IntOrZero() public static method

Convert a string value to an integer, or zero if non-numeric
public static IntOrZero ( string value ) : int
value string /// The value. ///
return int

MethodPath() public static method

Get a fully qualified namespaced path to a member
public static MethodPath ( MemberInfo mi ) : string
mi System.Reflection.MemberInfo
return string

MethodPath() public static method

Get a fully qualified namespaced path to a member.
public static MethodPath ( Type type, string memberName ) : string
type System.Type /// The type to inspect. ///
memberName string /// Name of the member. ///
return string

NumberToDoubleOrInt() public static method

Return an int or double from any number.
public static NumberToDoubleOrInt ( IConvertible value ) : IConvertible
value IConvertible /// The number to convert ///
return IConvertible

StreamToCharArray() public static method

Conver a stream to a character array.
public static StreamToCharArray ( Stream stream ) : char[]
stream Stream /// The stream. ///
return char[]

StreamToString() public static method

Convert a string to a stream using ASCII encoding.
public static StreamToString ( Stream stream ) : string
stream Stream /// The stream. ///
return string

TypePath() public static method

Get a fully qualified namespaced path to a type, e.g. "CsQuery.Utility.Support.TypePath"
public static TypePath ( Type type ) : string
type System.Type /// The type to inspect ///
return string