Util Methods |
The Util type exposes the following members.
Name | Description | |
---|---|---|
AllMessages |
Get a message that describes the current exception and all inner exceptions.
| |
BaseUnit |
Get base unit (SI)
| |
CandoUnitConversion |
Returns true if unit conversions can be performed between the two units, i.e.
they are different and none of them are undefined.
| |
CheckDirectoryForFile |
Check a directory for the file, if the directory or the parent directory exists.
| |
CreateDirectoryForFileIfNotExists |
Creates a directory for the file, if the directory does not already exist.
It only creates one level of directory. If the directory already exists, nothing is done. The method returns false if it was not possible to create directory, becase the parent directory did not exists either. Otherwise it returns true. | |
CreateDirectoryIfNotExists |
Creates a directory, if the directory does not already exist.
It many levels of directory. If the directory already exists, nothing is done. The method returns false if it was not possible to create directory, becase the parent directory did not exists either. Otherwise it returns true. | |
CreateStackTraceString |
From a stack trace object, return a stack trace string.
Call like:
CreateStackTraceString(System.Diagnostics.StackTrace(true), false) | |
EasterSunday |
Calculation of Easter Sunday for a given year | |
GetParameters |
Get parameters of unit
| |
GetUnitConversionFactor(eumQuantity, eumQuantity) |
Get a unit conversion factor from target unit to source unit. Undefined units are treated as SI unit, and
does not contribute to the factor. Units need not be equivalent.
See also UnitConversionFactors(eumUnit, eumUnit, Double, Double, Boolean) for details. | |
GetUnitConversionFactor(eumUnit, eumUnit) |
Get a unit conversion factor from target unit to source unit. Undefined units are treated as SI unit, and
does not contribute to the factor. Units need not be equivalent.
See also UnitConversionFactors(eumUnit, eumUnit, Double, Double, Boolean) for details. | |
GetUnitConversionFactor(IUnitProvider, eumItem, eumUnit) |
Get a unit conversion factor for EUM quantity
| |
GetUnitConversionFactor(IUnitProvider, eumItem, eumUnit, eumUnit) |
Get a unit conversion factor for EUM quantity
| |
GetUserUnitOrDefault |
Get a unit conversion factor for EUM quantity
| |
IsDefined |
Check if this double "is defined", i.e. does not equal the UndefinedDouble | |
IsSimple |
Returns true if this is a "simple" type
| |
LimitTimeStepToCheckPoint |
Make sure timestep hits exactly checkPoint.
The lookAhead parameter defines how many time steps before checkPoint to modify in order to hit the checkPoint. If lookAhead is 1, only the last time step before checkPoint will be modified. If 2, then two time steps before checkPoint will be modified etc. Assuming checkPoint is after currentTime (suggestedTimeStep is returned). | |
MakeValidFileName |
Makes a file name valid by replacing invalid file name characters by an underscore.
The input string must be the file name only, and can not contain any path characters. | |
Max |
Maximum of span 1 and span 2
| |
Min |
Minimum of span 1 and span 2
| |
NextTimeAfter |
Returns the next time after currentTime, being an integer
multiplum of dt after startTime | |
ReadAssemblyBuildDateTime |
Returns the DateTime that the assembly was build.
The PE header of the assembly file includes a time stamp (in UTC time) of when it was build. this procedures opens the assembly file, reads the header and returns the build time. | |
ReadSelectionFile |
Read a MU .MUS file into a list of strings
| |
RoundDown |
Rounding up time to nearest dt, where
dt is typicalle on the form dt = TimeSpan.FromHours(1) | |
RoundUp |
Rounding up time to nearest dt, where
dt is typicalle on the form dt = TimeSpan.FromHours(1) | |
SetupEnvironmentPath |
Setup environment path to this DHI install root.
| |
SetupInstallRoot |
Sets up a run environment that does not utilize the GAC.
This is only necessary in a develoment environment and should not
be used by others.
| |
SetupInstallRoot(String) |
Sets up a run environment that does not utilize the GAC.
This is only necessary in a develoment environment and should not
be used by others.
| |
SwapT |
Swapping two elements.
| |
TrimString |
Trim the string c from back and front of string str.
| |
Truncate |
Truncate string to the maximum length specified.
| |
UnitConversionFactors(eumUnit, eumUnit, Double, Double, Boolean) |
Calculate scale factor and offset for converting between eum units.
In case of success, the factor and offset contains the conversion values, that will convert from source to target using target = source*factor + offset The method will fail if one of the units are undefined, or if the units are not equivalent and unitsMustBeEquivalent is set. On failure, default values are used (scale is 1 and offset is 0). and false is returned It can handle units that are not equivalent, i.e. if the target is kg/m3 and the source is g/s, and there is some processing (in proper units) between the target and the source, the conversion will take care of the factor 1000 here. | |
UnitConversionFactors(eumQuantity, eumQuantity, Double, Double, Boolean, Boolean) |
Calculate scale factor and offset for converting between eum units.
In case of success, the factor and offset contains the conversion values, that will convert from source to target using target = source*factor + offset The method will fail 1) if one of the units are undefined and undefinedAsSI is not set, or 2) if the units are not equivalent and unitsMustBeEquivalent is set. On failure, default values are used (scale is 1 and offset is 0). and false is returned It can handle units that are not equivalent, i.e. if the target is kg/m3 and the source is g/s, and there is some processing (in proper units) between the target and the source, the conversion will take care of the factor 1000 here. | |
UnitConversionFactors(eumUnit, eumUnit, Double, Double, Boolean, Boolean) |
Calculate scale factor and offset for converting between eum units.
In case of success, the factor and offset contains the conversion values, that will convert from source to target using target = source*factor + offset The method will fail 1) if one of the units are undefined and undefinedAsSI is not set, or 2) if the units are not equivalent and unitsMustBeEquivalent is set. On failure, default values are used (scale is 1 and offset is 0). and false is returned It can handle units that are not equivalent, i.e. if the target is kg/m3 and the source is g/s, and there is some processing (in proper units) between the target and the source, the conversion will take care of the factor 1000 here. | |
UpdateQuantityUserUnit |
Update quantity with user unit, if user unit is available
| |
UserUnitToString(eumItem) |
Return a unit as a string
| |
UserUnitToString(IUnitProvider, eumItem) |
Return a unit as a string
| |
ValueInUserUnit(eumItem, Double) |
Convert a value to user unit and return as a string
| |
ValueInUserUnit(IUnitProvider, eumItem, Double) |
Convert a value to user unit and return as a string
| |
ValueInUserUnit(IUnitProvider, eumQuantity, Double) |
Convert a value to user unit and return as a string
| |
ValueInUserUnitToString(eumItem, Double) |
Convert a value to user unit and return as a string
| |
ValueInUserUnitToString(IUnitProvider, eumItem, Double) |
Convert a value to user unit and return as a string
| |
ValueInUserUnitToStringWithUnit(eumItem, Double) |
Convert a value to user unit and return as a string
| |
ValueInUserUnitToStringWithUnit(IUnitProvider, eumItem, Double) |
Convert a value to user unit and return as a string
| |
ValueToString |
Convert a value to string, with appropriate number of digits
|