//===================================================================== // IsValid(IInputExchangeItem inputExchangeItem, IOutputExchangeItem outputExchangeItem, // IDataOperation[] SelectedDataOperations): bool //===================================================================== /// <summary> /// For a given combination of inputExchangeItem, outputExchangeItem and list of dataOperation /// it is decided if the dataOperations constitutes a valid set seen from a spatial settings /// point of view. /// </summary> /// <param name="inputExchangeItem">The input exchange item</param> /// <param name="outputExchangeItem">The output exchange item</param> /// <param name="SelectedDataOperations">List of selected dataOperations</param> public override bool IsValid(IInputExchangeItem inputExchangeItem, IOutputExchangeItem outputExchangeItem, IDataOperation[] SelectedDataOperations) { bool returnValue = true; bool methodAvaileble = false; ElementMapper elementMapper = new ElementMapper(); foreach (string idString in elementMapper.GetIDsForAvailableDataOperations(outputExchangeItem.ElementSet.ElementType, inputExchangeItem.ElementSet.ElementType)) { if (ID == idString) { methodAvaileble = true; } } if (!methodAvaileble) { return(false); } // --- check that only one SpatialMapping dataoperation is selected. --- int numberOfSelectedSpatialMappingDataOperations = 0; foreach (IDataOperation dataOperation in SelectedDataOperations) { for (int i = 0; i < dataOperation.ArgumentCount; i++) { if (dataOperation.GetArgument(i).Id == "Type") { if (dataOperation.GetArgument(i).Value == "SpatialMapping") { numberOfSelectedSpatialMappingDataOperations++; //this counting is done to check if the same dataOpertion is added twise if (dataOperation.ID != ID) //the selected dataoperation must be this dataOperation { returnValue = false; //the selected dataoperation must be this } } } } } if (numberOfSelectedSpatialMappingDataOperations > 1) { returnValue = false; } return(returnValue); }