Click or drag to resize

Util Methods

The Util type exposes the following members.

Methods
  NameDescription
Public methodStatic memberAllMessages
Get a message that describes the current exception and all inner exceptions.
Public methodStatic memberBaseUnit
Get base unit (SI)
Public methodStatic memberCandoUnitConversion
Returns true if unit conversions can be performed between the two units, i.e. they are different and none of them are undefined.
Public methodStatic memberCheckDirectoryForFile
Check a directory for the file, if the directory or the parent directory exists.
Public methodStatic memberCreateDirectoryForFileIfNotExists
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.

Public methodStatic memberCreateDirectoryIfNotExists
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.

Public methodStatic memberCreateStackTraceString
From a stack trace object, return a stack trace string. Call like:
CreateStackTraceString(System.Diagnostics.StackTrace(true), false)
Public methodStatic memberEasterSunday
Calculation of Easter Sunday for a given year
Public methodStatic memberGetParameters
Get parameters of unit
Public methodStatic memberGetUnitConversionFactor(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.

Public methodStatic memberGetUnitConversionFactor(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.

Public methodStatic memberGetUnitConversionFactor(IUnitProvider, eumItem, eumUnit)
Get a unit conversion factor for EUM quantity
Public methodStatic memberGetUnitConversionFactor(IUnitProvider, eumItem, eumUnit, eumUnit)
Get a unit conversion factor for EUM quantity
Public methodStatic memberGetUserUnitOrDefault
Get a unit conversion factor for EUM quantity
Public methodStatic memberIsDefined
Check if this double "is defined", i.e. does not equal the UndefinedDouble
Public methodStatic memberIsSimple
Returns true if this is a "simple" type
Public methodStatic memberLimitTimeStepToCheckPoint
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).

Public methodStatic memberMakeValidFileName
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.

Public methodStatic memberMax
Maximum of span 1 and span 2
Public methodStatic memberMin
Minimum of span 1 and span 2
Public methodStatic memberNextTimeAfter
Returns the next time after currentTime, being an integer multiplum of dt after startTime
Public methodStatic memberReadAssemblyBuildDateTime
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.

Public methodStatic memberReadSelectionFile
Read a MU .MUS file into a list of strings
Public methodStatic memberRoundDown
Rounding up time to nearest dt, where dt is typicalle on the form
dt = TimeSpan.FromHours(1)
Public methodStatic memberRoundUp
Rounding up time to nearest dt, where dt is typicalle on the form
dt = TimeSpan.FromHours(1)
Public methodStatic memberSetupEnvironmentPath
Setup environment path to this DHI install root.
Public methodStatic memberSetupInstallRoot
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.
Public methodStatic memberSetupInstallRoot(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.
Public methodStatic memberSwapT
Swapping two elements.
Public methodStatic memberTrimString
Trim the string c from back and front of string str.
Public methodStatic memberTruncate
Truncate string to the maximum length specified.
Public methodStatic memberUnitConversionFactors(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.

Public methodStatic memberUnitConversionFactors(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.

Public methodStatic memberUnitConversionFactors(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.

Public methodStatic memberUpdateQuantityUserUnit
Update quantity with user unit, if user unit is available
Public methodStatic memberUserUnitToString(eumItem)
Return a unit as a string
Public methodStatic memberUserUnitToString(IUnitProvider, eumItem)
Return a unit as a string
Public methodStatic memberValueInUserUnit(eumItem, Double)
Convert a value to user unit and return as a string
Public methodStatic memberValueInUserUnit(IUnitProvider, eumItem, Double)
Convert a value to user unit and return as a string
Public methodStatic memberValueInUserUnit(IUnitProvider, eumQuantity, Double)
Convert a value to user unit and return as a string
Public methodStatic memberValueInUserUnitToString(eumItem, Double)
Convert a value to user unit and return as a string
Public methodStatic memberValueInUserUnitToString(IUnitProvider, eumItem, Double)
Convert a value to user unit and return as a string
Public methodStatic memberValueInUserUnitToStringWithUnit(eumItem, Double)
Convert a value to user unit and return as a string
Public methodStatic memberValueInUserUnitToStringWithUnit(IUnitProvider, eumItem, Double)
Convert a value to user unit and return as a string
Public methodStatic memberValueToString
Convert a value to string, with appropriate number of digits
Top
See Also