/// <summary> /// Create an adapted output, assuming that the adaptee and target are matching (check must /// be done beforehand. /// </summary> /// <param name="adaptee">Adaptee to connect to multi input</param> /// <param name="target">Target of created multi input adaptor</param> /// <returns>Multi input adaptor, connected to adaptee</returns> public ITimeSpaceAdaptedOutput CreateAdaptedOutput(IBaseOutput adaptee, IBaseInput target) { MultiInputAdaptor multiInputAdaptor; if (!ExistingMultiInputAdaptors.TryGetValue(target, out multiInputAdaptor)) { // Set up a multi input adaptor having the same properties as the target multiInputAdaptor = new MultiInputAdaptor("MultiInputAdaptor:" + target.Id) { SpatialDefinition = ((ITimeSpaceInput)target).SpatialDefinition, ValueDefinition = target.ValueDefinition, }; ExistingMultiInputAdaptors.Add(target, multiInputAdaptor); } // Identity adaptor, create and register with multiInput //adaptedOutput = multiInputAdaptor.CreateChildAdaptor(adaptee); // The trick here is to always return and use the same multi input adaptor. // for all adaptees. multiInputAdaptor.Adaptees.Add((ITimeSpaceOutput)adaptee); // Connect adaptee and adaptor - the factory must do this. if (!adaptee.AdaptedOutputs.Contains(multiInputAdaptor)) { adaptee.AddAdaptedOutput(multiInputAdaptor); } return(multiInputAdaptor); }
public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IBaseInput target) { MultiInputAdaptor multiInputAdaptor = null; if (adaptedOutputId == _identityAdaptor) { // If a MultiInputAdaptor already exists for the target, get that one, otherwise create a new. return(CreateAdaptedOutput(adaptee, target)); } if (multiInputAdaptor == null) { throw new ArgumentException("Adapted output id could not be found", "adaptedOutputId"); } return(multiInputAdaptor); }