Interface IAnalysisModelService
- Namespace
- ModelExchanger.AnalysisDataModel.Contracts
- Assembly
- ModelExchanger.AnalysisDataModel.Contracts.dll
Service to interact with an AnalysisModel. Defines CRUD operations along with validation
public interface IAnalysisModelService
Methods
AddItemToModel(AnalysisModel, IAnalysisObject, IObjectIdentifier)
Add an IAnalysisObject to an AnalysisModel
bool AddItemToModel(AnalysisModel model, IAnalysisObject analysisObject, IObjectIdentifier identifier = null)
Parameters
modelAnalysisModelThe AnalysisModel to which the provided IAnalysisObject needs to be added
analysisObjectIAnalysisObjectThe IAnalysisObject to be added to the provided AnalysisModel
identifierIObjectIdentifierAn optional IObjectIdentifier implementation that allows identification of objects across modules. Used primarily to compose validation warning or error messages
Returns
- bool
True if the object has been added to the model, false otherwise (in case of validation errors) when the object was not added to the model
AddItemsToModel(AnalysisModel, IReadOnlyCollection<IAnalysisObject>, IObjectIdentifier)
Adds a collection of IAnalysisObject to an AnalysisModel
IDictionary<Guid, bool> AddItemsToModel(AnalysisModel model, IReadOnlyCollection<IAnalysisObject> analysisObjects, IObjectIdentifier identifier = null)
Parameters
modelAnalysisModelThe AnalysisModel to which the provided collection of IAnalysisObject needs to be added
analysisObjectsIReadOnlyCollection<IAnalysisObject>The collection of IAnalysisObject to be added to the provided AnalysisModel
identifierIObjectIdentifierAn optional IObjectIdentifier implementation that allows identification of objects across modules. Used primarily to compose validation warning or error messages
Returns
- IDictionary<Guid, bool>
A dictionary containing a boolean for each object if it has been added to the model. If the value is false, it means the validation for that object has failed and the object was not added to the model.
AddOrUpdate(AnalysisModel, IAnalysisObject, IObjectIdentifier)
Add or update an IAnalysisObject depending on the state of the object in the AnalysisModel. If the IAnalysisObject does not exist, it is added. Otherwise it will be updated.
bool AddOrUpdate(AnalysisModel model, IAnalysisObject analysisObject, IObjectIdentifier identifier = null)
Parameters
modelAnalysisModelThe AnalysisModel to which the provided IAnalysisObject needs to be added or updated
analysisObjectIAnalysisObjectThe IAnalysisObject to be added or updated to or in the provided AnalysisModel
identifierIObjectIdentifierAn optional IObjectIdentifier implementation that allows identification of objects across modules. Used primarily to compose validation warning or error messages
Returns
- bool
True if the add or update succeeded, false otherwise.
RemoveItemFromModel(AnalysisModel, IAnalysisObject)
Remove an IAnalysisObject from an AnalysisModel. An exception will be raised if the IAnalysisObject is being referenced by another IAnalysisObject
void RemoveItemFromModel(AnalysisModel model, IAnalysisObject item)
Parameters
modelAnalysisModelThe AnalysisModel from which the provided IAnalysisObject needs to be removed
itemIAnalysisObjectThe IAnalysisObject to be removed from the provided AnalysisModel
Update(AnalysisModel, IAnalysisObject, IObjectIdentifier)
Update an existing IAnalysisObject in an AnalysisModel
bool Update(AnalysisModel model, IAnalysisObject analysisObject, IObjectIdentifier identifier = null)
Parameters
modelAnalysisModelThe AnalysisModel in which the provided IAnalysisObject needs to be updated
analysisObjectIAnalysisObjectThe IAnalysisObject to be updated in the provided AnalysisModel
identifierIObjectIdentifierAn optional IObjectIdentifier implementation that allows identification of objects across modules. Used primarily to compose validation warning or error messages
Returns
- bool
True if the updated object passed validation, false otherwise.
ValidateModel(AnalysisModel)
Validate an entire AnalysisModel
bool ValidateModel(AnalysisModel model)
Parameters
modelAnalysisModelThe model to validate
Returns
- bool
True if all objects in the model are valid, false otherwise