private void GetExchangeItemsFromOpenMIComponent() { // ZZZ // Match the Input and Output Exchange Items foreach (IBaseInput baseInput in _openMIComponent.Inputs) { foreach (IBaseOutput baseOutput in _openMIComponent.Outputs) { if (baseInput.Id.CompareTo(baseOutput.Id) == 0) { ITimeSpaceInput timeSpaceInput = baseInput as ITimeSpaceInput; ITimeSpaceOutput timeSpaceOutput = baseOutput as ITimeSpaceOutput; var IO = new ExchangeItem(timeSpaceOutput); IO.AddIn(timeSpaceInput); if (IO != null && !_inout.ContainsKey(timeSpaceOutput.Id)) { _inout.Add(timeSpaceOutput.Id, IO); } } } } foreach (IBaseInput baseIn in _openMIComponent.Inputs) { ITimeSpaceInput timeSpaceIn = baseIn as ITimeSpaceInput; if (timeSpaceIn != null && !_inout.ContainsKey(baseIn.Id)) { _inputs.Add(timeSpaceIn.Id, new ExchangeItem(timeSpaceIn)); } } foreach (IBaseOutput baseOut in _openMIComponent.Outputs) { ITimeSpaceOutput timeSpaceOut = baseOut as ITimeSpaceOutput; if (timeSpaceOut != null && !_inout.ContainsKey(baseOut.Id)) { //ZZZ var I = new ExchangeItem(timeSpaceOut); if (I != null) { _outputs.Add(timeSpaceOut.Id, I); } } } }
public IExchangeItem GetExchangeItem(string exchangeItemID) { // ZZZ Removes the . at the end of the exchangeItemID if there is one // Try and Map what's after the . to a location index char[] delimiterChars = { '.' }; string[] idx = exchangeItemID.Split(delimiterChars); int idxTemp; if (idx.Length == 2) { if (_inout.ContainsKey(idx[1])) { ExchangeItem I = _inout[idx[1]]; try { idxTemp = Convert.ToInt32(idx[0]); I.AddSingleIdx(idxTemp); } catch (Exception e) { System.Console.WriteLine("ExchangeItem index invalid (not an integer): " + e.Message); } return(I); //return _outputs[exchangeItemID]; } if (_outputs.ContainsKey(idx[1])) { ExchangeItem I = _outputs[idx[1]]; try { idxTemp = Convert.ToInt32(idx[0]); I.AddSingleIdx(idxTemp); } catch (Exception e) { System.Console.WriteLine("ExchangeItem index invalid (not an integer): " + e.Message); } return(I); //return _outputs[exchangeItemID]; } if (!_inputs.ContainsKey(idx[1])) { throw new Exception("Could not find exchange item \"" + exchangeItemID + "\""); } return(_inputs[idx[1]]); } if (idx.Length == 1) { if (_inout.ContainsKey(idx[0])) { ExchangeItem I = _inout[idx[0]]; return(I); //return _outputs[exchangeItemID]; } if (_outputs.ContainsKey(idx[0])) { ExchangeItem I = _outputs[idx[0]]; return(I); //return _outputs[exchangeItemID]; } if (!_inputs.ContainsKey(idx[1])) { throw new Exception("Could not find exchange item \"" + exchangeItemID + "\""); } return(_inputs[idx[1]]); } return(null); }