/// <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);
        }
Beispiel #2
0
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IBaseInput target)
        {
            IBaseAdaptedOutput adaptedOutput = new ElementMapperAdaptedOutput(adaptedOutputId, (ITimeSpaceOutput)adaptee, target.ElementSet());

            // Connect adaptor and adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptedOutput))
            {
                adaptee.AddAdaptedOutput(adaptedOutput);
            }

            return(adaptedOutput);
        }
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IBaseInput target)
        {
            IBaseAdaptedOutput adaptedOutput = new ElementMapperAdaptedOutput(adaptedOutputId, (ITimeSpaceOutput)adaptee, target.ElementSet());

            // Connect adaptor and adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptedOutput))
            {
                adaptee.AddAdaptedOutput(adaptedOutput);
            }

            return adaptedOutput;
        }
 public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputIdentifier, IBaseOutput adaptee, IBaseInput target)
 {
   IBaseAdaptedOutput adaptor = adaptedOutputIdentifier as IBaseAdaptedOutput;
   if (adaptor == null)
   {
     throw new ArgumentException("Unknown adaptedOutput type - it does not originate from this factory");
   }
   // Connect the adaptor and the adaptee
   if (!adaptee.AdaptedOutputs.Contains(adaptor))
   {
     adaptee.AddAdaptedOutput(adaptor);
   }
   return adaptor;
 }
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputIdentifier, IBaseOutput adaptee, IBaseInput target)
        {
            IBaseAdaptedOutput adaptor = adaptedOutputIdentifier as IBaseAdaptedOutput;

            if (adaptor == null)
            {
                throw new ArgumentException("Unknown adaptedOutput type - it does not originate from this factory");
            }
            // Connect the adaptor and the adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptor))
            {
                adaptee.AddAdaptedOutput(adaptor);
            }
            return(adaptor);
        }
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IBaseInput target)
        {
            ITimeSpaceAdaptedOutput adaptedOutput = adaptedOutputId as ITimeSpaceAdaptedOutput;

            if (adaptedOutput == null)
            {
                throw new ArgumentException("Adapted output id does no come from this factory", "adaptedOutputId");
            }
            // Connect adaptor and adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptedOutput))
            {
                adaptee.AddAdaptedOutput(adaptedOutput);
            }
            return(adaptedOutput);
        }
Beispiel #7
0
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputIdentifier, IBaseOutput adaptee, IBaseInput target)
        {
            IBaseAdaptedOutput adaptor = (from n in outputsCreatedSoFar
                                          where n.Id == adaptedOutputIdentifier.Id && n.Adaptee == adaptee
                                          select n).FirstOrDefault();

            if (adaptor == null)
            {
                throw new ArgumentException("Unknown adaptedOutput type - it does not originate from this factory");
            }
            // Connect the adaptor and the adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptor))
            {
                adaptee.AddAdaptedOutput(adaptor);
            }
            return(adaptor);
        }
Beispiel #8
0
        public static ITimeSpaceAdaptedOutput CreateAdaptedOutputMethod(IIdentifiable adaptedOutputId, IBaseOutput adaptee, IElementSet targetElmtSet)
        {
            SpatialMethod method = FindSMethod(adaptedOutputId);

            ITimeSpaceAdaptedOutput adaptedOutput = null;

            if (method.ElementMapperMethod != ElementMapperMethod.None)
            {
                if (targetElmtSet == null)
                {
                    throw new ArgumentException("Target not defined or spatial definition is not an element set. Can not create adaptor");
                }
                adaptedOutput = new ElementMapperAdaptedOutput(adaptedOutputId, (ITimeSpaceOutput)adaptee, targetElmtSet);
            }
            else
            {
                if (string.Equals(_ElementOperationPrefix + "200", adaptedOutputId.Id, StringComparison.OrdinalIgnoreCase))
                {
                    adaptedOutput = new ElementLineLengthOperationAdaptor(adaptedOutputId.Id, (ITimeSpaceOutput)adaptee);
                }
                else if (string.Equals(_ElementOperationPrefix + "300", adaptedOutputId.Id, StringComparison.OrdinalIgnoreCase))
                {
                    adaptedOutput = new ElementAreaOperationAdaptor(adaptedOutputId.Id, (ITimeSpaceOutput)adaptee);
                }
            }

            if (adaptedOutput == null)
            {
                throw new ArgumentException("Adapted output id could not be found", "adaptedOutputId");
            }

            // Connect adaptor and adaptee
            if (!adaptee.AdaptedOutputs.Contains(adaptedOutput))
            {
                adaptee.AddAdaptedOutput(adaptedOutput);
            }

            return(adaptedOutput);
        }
        public IBaseAdaptedOutput CreateAdaptedOutput(IIdentifiable adaptedOutputIdentifier, IBaseOutput parentOutput, IBaseInput target)
        {
            IBaseAdaptedOutput adaptedOutput = null;

            if (adaptedOutputIdentifier.Id.Equals(TimeInterpolatorId))
            {
                adaptedOutput = new MeasurementsInterpolator((ITimeSpaceOutput)parentOutput);
            }
            else if (adaptedOutputIdentifier.Id.Equals(TimeExtrapolatorId))
            {
                adaptedOutput = new TimeExtrapolator((ITimeSpaceOutput)parentOutput);
            }
            if (adaptedOutput == null)
            {
                throw new Exception("AdaptedOutput id: " + adaptedOutputIdentifier.Id);
            }

            // connect adaptor and adaptee
            if (!parentOutput.AdaptedOutputs.Contains(adaptedOutput))
            {
                parentOutput.AddAdaptedOutput(adaptedOutput);
            }
            return(adaptedOutput);
        }