Table of Contents

Class ModelStateBase

Namespace
Cognite.Simulator.Utils
Assembly
Cognite.Simulator.Utils.dll

This base class represents the state of a model file TODO: See if we can remove FileState completely and move all the variables into this class Jira: https://cognitedata.atlassian.net/browse/POFSP-558

public abstract class ModelStateBase : FileState, IExtractionState
Inheritance
ModelStateBase
Implements
IExtractionState
Derived
Inherited Members

Constructors

ModelStateBase()

Creates a new model file state instance

public ModelStateBase()

Properties

CanRead

Indicates if the simulator can read the model file and its data

public bool CanRead { get; set; }

Property Value

bool

Downloaded

Indicates if the model file has been downloaded and the file exists on the disk. Also checks if all dependency files have their paths assigned.

public bool Downloaded { get; }

Property Value

bool

IsExtracted

Indicates if information has been extracted from the model file

public abstract bool IsExtracted { get; }

Property Value

bool

ParsingInfo

Information about model parsing

public ModelParsingInfo ParsingInfo { get; set; }

Property Value

ModelParsingInfo

Methods

DeduplicateDownloadFileIds(Dictionary<long, string>)

Gets all file IDs that are yet to be downloaded. This includes the main file ID and any dependency files.

public (List<long>, Dictionary<long, string>) DeduplicateDownloadFileIds(Dictionary<long, string> currentFilesCache)

Parameters

currentFilesCache Dictionary<long, string>

Returns

(List<long>, Dictionary<long, string>)

List of file IDs pending download, and a dictionary of already downloaded files with their paths

Exceptions

InvalidOperationException

Thrown if CdfId is not set

Init(FileStatePoco)

Initialize this model state using a data object from the state store

public override void Init(FileStatePoco poco)

Parameters

poco FileStatePoco

Data object

SetFilePath(long, string, string)

Sets the file path for the main file or a dependency file.

public void SetFilePath(long fileId, string filePath, string fileExtension = null)

Parameters

fileId long
filePath string
fileExtension string

ShouldProcess()

If true, the local file will be opened and parsed by the connector. By default, this happens only once per model revision. Can be overridden, when re-parsing on every download is preferred.

public virtual bool ShouldProcess()

Returns

bool

SyncProperties<TSource, TTarget>(TSource, TTarget)

Copies matching properties from the source object to the target object. Only properties with the same name and type are copied.

public static TTarget SyncProperties<TSource, TTarget>(TSource source, TTarget target) where TSource : class where TTarget : class

Parameters

source TSource
target TTarget

Returns

TTarget

Type Parameters

TSource
TTarget

UpdateDependencyFilePath(long, string)

Updates the file path of a dependency file. Throws an exception if the file reference does not exist in the state.

public void UpdateDependencyFilePath(long fileId, string filePath)

Parameters

fileId long

The ID of the dependency file

filePath string

The new file path for the dependency file

Exceptions

ArgumentNullException

Thrown if dependencyFile is null