C# Class Rhino.Kit

Collection of utilities
Show file Open project: hazzik/Rhino.Net

Public Methods

Method Description
AddListener ( object bag, object listener ) : object

Add listener to bag of listeners.

Add listener to bag of listeners. The function does not modify bag and return a new collection containing listener and all listeners from bag. Bag without listeners always represented as the null value.

Usage example:

 private volatile Object changeListeners; public void addMyListener(PropertyChangeListener l) { synchronized (this) { changeListeners = Kit.addListener(changeListeners, l); } } public void removeTextListener(PropertyChangeListener l) { synchronized (this) { changeListeners = Kit.removeListener(changeListeners, l); } } public void fireChangeEvent(Object oldValue, Object newValue) { // Get immune local copy Object listeners = changeListeners; if (listeners != null) { PropertyChangeEvent e = new PropertyChangeEvent( this, "someProperty" oldValue, newValue); for (int i = 0; ; ++i) { Object l = Kit.getListener(listeners, i); if (l == null) break; ((PropertyChangeListener)l).propertyChange(e); } } } 
ClassOrNull ( ClassLoader loader, string className ) : Type

Attempt to load the class of the given name.

Attempt to load the class of the given name. Note that the type parameter isn't checked.

ClassOrNull ( string className ) : Type
CodeBug ( ) : Exception

Throws RuntimeException to indicate failed assertion.

Throws RuntimeException to indicate failed assertion. The function never returns and its return type is RuntimeException only to be able to write throw Kit.codeBug() if plain Kit.codeBug() triggers unreachable code error.

CodeBug ( string msg ) : Exception

Throws RuntimeException to indicate failed assertion.

Throws RuntimeException to indicate failed assertion. The function never returns and its return type is RuntimeException only to be able to write throw Kit.codeBug() if plain Kit.codeBug() triggers unreachable code error.

GetListener ( object bag, int index ) : object

Get listener at index position in bag or null if index equals to number of listeners in bag.

Get listener at index position in bag or null if index equals to number of listeners in bag.

For usage example, see AddListener(object, object) .

InitCause ( Exception ex, Exception cause ) : Exception

If initCause methods exists in Throwable, call ex.initCause(cause) or otherwise do nothing.

If initCause methods exists in Throwable, call ex.initCause(cause) or otherwise do nothing.

MakeHashKeyFromPair ( object key1, object key2 ) : object
ReadReader ( TextReader r ) : string
ReadStream ( Stream @is, int initialBufferCapacity ) : byte[]
RemoveListener ( object bag, object listener ) : object

Remove listener from bag of listeners.

Remove listener from bag of listeners. The function does not modify bag and return a new collection containing all listeners from bag except listener. If bag does not contain listener, the function returns bag.

For usage example, see AddListener(object, object) .

XDigitToInt ( int c, int accumulator ) : int

If character c is a hexadecimal digit, return accumulator * 16 plus corresponding number.

If character c is a hexadecimal digit, return accumulator * 16 plus corresponding number. Otherise return -1.

Private Methods

Method Description
InitHash ( object>.IDictionary h, object key, object initialValue ) : object
Kit ( ) : System
NewInstanceOrNull ( Type cl ) : object
TestIfCanLoadRhinoClasses ( ClassLoader loader ) : bool

Check that testClass is accessible from the given loader.

Check that testClass is accessible from the given loader.

Method Details

AddListener() public static method

Add listener to bag of listeners.
Add listener to bag of listeners. The function does not modify bag and return a new collection containing listener and all listeners from bag. Bag without listeners always represented as the null value.

Usage example:

 private volatile Object changeListeners; public void addMyListener(PropertyChangeListener l) { synchronized (this) { changeListeners = Kit.addListener(changeListeners, l); } } public void removeTextListener(PropertyChangeListener l) { synchronized (this) { changeListeners = Kit.removeListener(changeListeners, l); } } public void fireChangeEvent(Object oldValue, Object newValue) { // Get immune local copy Object listeners = changeListeners; if (listeners != null) { PropertyChangeEvent e = new PropertyChangeEvent( this, "someProperty" oldValue, newValue); for (int i = 0; ; ++i) { Object l = Kit.getListener(listeners, i); if (l == null) break; ((PropertyChangeListener)l).propertyChange(e); } } } 
public static AddListener ( object bag, object listener ) : object
bag object Current collection of listeners.
listener object Listener to add to bag
return object

ClassOrNull() public static method

Attempt to load the class of the given name.
Attempt to load the class of the given name. Note that the type parameter isn't checked.
public static ClassOrNull ( ClassLoader loader, string className ) : Type
loader ClassLoader
className string
return System.Type

ClassOrNull() public static method

public static ClassOrNull ( string className ) : Type
className string
return System.Type

CodeBug() public static method

Throws RuntimeException to indicate failed assertion.
Throws RuntimeException to indicate failed assertion. The function never returns and its return type is RuntimeException only to be able to write throw Kit.codeBug() if plain Kit.codeBug() triggers unreachable code error.
public static CodeBug ( ) : Exception
return System.Exception

CodeBug() public static method

Throws RuntimeException to indicate failed assertion.
Throws RuntimeException to indicate failed assertion. The function never returns and its return type is RuntimeException only to be able to write throw Kit.codeBug() if plain Kit.codeBug() triggers unreachable code error.
public static CodeBug ( string msg ) : Exception
msg string
return System.Exception

GetListener() public static method

Get listener at index position in bag or null if index equals to number of listeners in bag.
Get listener at index position in bag or null if index equals to number of listeners in bag.

For usage example, see AddListener(object, object) .

public static GetListener ( object bag, int index ) : object
bag object Current collection of listeners.
index int Index of the listener to access.
return object

InitCause() public static method

If initCause methods exists in Throwable, call ex.initCause(cause) or otherwise do nothing.
If initCause methods exists in Throwable, call ex.initCause(cause) or otherwise do nothing.
public static InitCause ( Exception ex, Exception cause ) : Exception
ex System.Exception
cause System.Exception
return System.Exception

MakeHashKeyFromPair() public static method

public static MakeHashKeyFromPair ( object key1, object key2 ) : object
key1 object
key2 object
return object

ReadReader() public static method

public static ReadReader ( TextReader r ) : string
r System.IO.TextReader
return string

ReadStream() public static method

public static ReadStream ( Stream @is, int initialBufferCapacity ) : byte[]
@is Stream
initialBufferCapacity int
return byte[]

RemoveListener() public static method

Remove listener from bag of listeners.
Remove listener from bag of listeners. The function does not modify bag and return a new collection containing all listeners from bag except listener. If bag does not contain listener, the function returns bag.

For usage example, see AddListener(object, object) .

public static RemoveListener ( object bag, object listener ) : object
bag object Current collection of listeners.
listener object Listener to remove from bag
return object

XDigitToInt() public static method

If character c is a hexadecimal digit, return accumulator * 16 plus corresponding number.
If character c is a hexadecimal digit, return accumulator * 16 plus corresponding number. Otherise return -1.
public static XDigitToInt ( int c, int accumulator ) : int
c int
accumulator int
return int