Click or drag to resize

DfsFileConverter Class

Class wrapping an DfsFile, applying a number of IDfsDataConverters to the DfsFile methods.
Inheritance Hierarchy
SystemObject
  DHI.Generic.MikeZero.DFSDfsFileConverter

Namespace:  DHI.Generic.MikeZero.DFS
Assembly:  DHI.Generic.MIKEZero.DFS (in DHI.Generic.MIKEZero.DFS.dll) Version: 19.0.0.0 (11.1.1.1111)
Syntax
public class DfsFileConverter : IDfsFile, 
	IDfsFileIO, IDfsFileStaticIO, IDisposable

The DfsFileConverter type exposes the following members.

Properties
  NameDescription
Public propertyFileInfo
Public propertyFileMode
Mode of the current file

This is set to Closed when the file has been closed.

Public propertyItemInfo
Top
Methods
  NameDescription
Public methodClose
Public methodDfsCurrentVersion
Public methodDispose
Close file and release ressources on the unmanaged side.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Public methodFindItem
Positions the file pointer at the location in the file where the specified dynamic item at the specified time step starts.
Public methodFindTimeStep
Positions the file pointer at the location in the file where the specified time step starts.
Public methodFlush
Public methodFlushTimeStep
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodReadItemTimeStep(Int32, Int32)
Public methodReadItemTimeStep(IDfsItemData, Int32)
Public methodReadItemTimeStepNext
Public methodReadStaticItem
Public methodReadStaticItemNext
Public methodReset
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodWriteItemTimeStep
Writes data to the specified item and timestep in the file.

If the item-timestep exists already, data is updated. If it does not exist, the item number and timestep index must match exactly the next item-timestep after the last one in the file.

The size of the data must match the data size of the item that is to be written.

The time value is only relevant for files with non-equidistant time axis. For files with an equidistant time axis, the time value is ignored, and a zero can be used.

Public methodWriteItemTimeStepNext

Writes the next dynamic item-timestep.

If the file pointer points to the end of the file, this will append a new item-timestep to the file. If the file pointer points to an existing item-timestep, the data of that item-timestep is updated.

Remember that the file pointer position depends on the mode that the file was opened: In edit mode the file pointer points at the first item-timestep. In append mode the file pointer points initially at the end of file.

It iterates over the item-timesteps as the ReadItemTimeStepNext, see there for more details.

This is the most efficient way to iterate through and update/append the items and timesteps in a file, since it iterates exactly as the data is stored on the disk.

The size of the data must match the data size of the item that is to be written.

The time value is only relevant for files with non-equidistant time axis. For files with an equidistant time axis, the time value is ignored, and a zero can be used.

Public methodWriteStaticItemData
Top
Extension Methods
  NameDescription
Public Extension MethodCreateEmptyItemData(Int32)Overloaded. (Defined by DfsExtensions.)
Public Extension MethodCreateEmptyItemDataT(Int32)Overloaded.
Create an IDfsItemDataT of the correct type for the item with the given itemNumber.

The result can be used by ReadItemTimeStep(IDfsItemData, Int32)

If not the item is of type {T}, an exception will be thrown.

(Defined by DfsExtensions.)
Public Extension MethodCreateEmptyItemDatasOverloaded. (Defined by DfsExtensions.)
Public Extension MethodCreateEmptyItemDatasTOverloaded.
Create an IDfsItemDataT of the provided type for each of the dynamic items in the file.

The result can be used by ReadItemTimeStep(IDfsItemData, Int32)

If not all items are of type {T}, an exception will be thrown.

(Defined by DfsExtensions.)
Public Extension MethodSearch(DateTime)Overloaded.
Searches the dfs file for the time step index of a time, and returns the zero-based time step index. The time axis of the file must be a calendar type time axis

NOTE: For the non-equidistant time axes, the metod will read the first item in the file for a number of timesteps in random order, performing a binary search in the file data on disc. This will be slow if used many times on the same file. In such a case, use the lazy version of GetDateTimes(IDfsFile, Boolean) or GetDateTimes(IDfsFile, DateTime, Boolean).

For the equidistant time axis, the method will calculate the time step index directly without reading data from the file.

(Defined by DfsExtensions.)
Public Extension MethodSearch(Double)Overloaded.
Searches the dfs file for the time step index of a time, and returns the zero-based time step index.

NOTE: For the non-equidistant time axes, the metod will read the first item in the file for a number of timesteps in random order, performing a binary search in the file data on disc. This will be slow if used many times on the same file. In such a case, use the lazy version of GetDateTimes(IDfsFile, Boolean) or GetDateTimes(IDfsFile, DateTime, Boolean).

For the equidistant time axis, the method will calculate the time step index directly without reading data from the file.

(Defined by DfsExtensions.)
Top
See Also