Example #1
0
 public void InitializeOutput(object output)
 {
     if (OutputDelay != null)
     {
         OutputDelay.ExecutePersistors(output);
     }
     OutputDelay = null;
 }
Example #2
0
        /// <summary>
        /// Delays the ouput of this computation with the given output delay
        /// </summary>
        /// <param name="delay"></param>
        internal void DelayOutput(OutputDelay delay)
        {
            if (delay == null)
            {
                throw new ArgumentNullException("delay");
            }

            if (OutputDelay != null)
            {
                delay.Persistors.AddRange(OutputDelay.Persistors);
            }
            OutputDelay = delay;
        }
        private void HandleDelayedComputation(Computation computation, ITransformationContext context, OutputDelay delay)
        {
            var inCollection = Selector(computation);

            if (inCollection != null)
            {
                if (Persistor != null)
                {
                    Type  listType = (typeof(List <>)).MakeGenericType(DependencyTransformation.OutputType);
                    IList list     = System.Activator.CreateInstance(listType) as IList;

                    MultipleResultAwaitingPersistor delayPersistor = new MultipleResultAwaitingPersistor()
                    {
                        List      = list,
                        Persistor = Persistor
                    };
                    if (context.IsThreadSafe)
                    {
                        Parallel.ForEach(inCollection, dependencyInput =>
                        {
                            HandleDelayedDependencyInput(computation, context, list, delayPersistor, dependencyInput);
                        });
                    }
                    else
                    {
                        foreach (var dependencyInput in inCollection)
                        {
                            HandleDelayedDependencyInput(computation, context, list, delayPersistor, dependencyInput);
                        }
                    }
                    delay.Persistors.Add(delayPersistor);
                }
                else
                {
                    if (context.IsThreadSafe)
                    {
                        Parallel.ForEach(inCollection, dependencyInput =>
                        {
                            GeneralTransformationRule dependent = DependencyTransformation;
                            var comp2 = context.CallTransformation(dependent, dependencyInput);

                            computation.MarkRequireInternal(comp2, ExecuteBefore, this);
                        });
                    }
                    else
                    {
                        foreach (var dependencyInput in inCollection)
                        {
                            GeneralTransformationRule dependent = DependencyTransformation;
                            var comp2 = context.CallTransformation(dependent, dependencyInput);

                            computation.MarkRequireInternal(comp2, ExecuteBefore, this);
                        }
                    }
                }
            }
        }
Example #4
0
        /// <summary>
        /// Delays the ouput of this computation with the given output delay
        /// </summary>
        /// <param name="delay"></param>
        internal void DelayOutput(OutputDelay delay)
        {
            if (delay == null) throw new ArgumentNullException("delay");

            if (OutputDelay != null)
            {
                delay.Persistors.AddRange(OutputDelay.Persistors);
            }
            OutputDelay = delay;
        }
Example #5
0
 internal static void DelayOutput(this Computation computation, OutputDelay outputDelay)
 {
     var cc = computation.Context as ComputationContext;
     cc.DelayOutput(outputDelay);
 }
Example #6
0
        private void HandleDelayedComputation(Computation computation, ITransformationContext context, OutputDelay delay)
        {
            var inCollection = Selector(computation);
            if (inCollection != null)
            {
                if (Persistor != null)
                {
                    Type listType = (typeof(List<>)).MakeGenericType(DependencyTransformation.OutputType);
                    IList list = System.Activator.CreateInstance(listType) as IList;

                    MultipleResultAwaitingPersistor delayPersistor = new MultipleResultAwaitingPersistor()
                    {
                        List = list,
                        Persistor = Persistor
                    };
                    if (context.IsThreadSafe)
                    {
                        Parallel.ForEach(inCollection, dependencyInput =>
                        {
                            HandleDelayedDependencyInput(computation, context, list, delayPersistor, dependencyInput);
                        });
                    }
                    else
                    {
                        foreach (var dependencyInput in inCollection)
                        {
                            HandleDelayedDependencyInput(computation, context, list, delayPersistor, dependencyInput);
                        }
                    }
                    delay.Persistors.Add(delayPersistor);
                }
                else
                {
                    if (context.IsThreadSafe)
                    {
                        Parallel.ForEach(inCollection, dependencyInput =>
                        {
                            GeneralTransformationRule dependent = DependencyTransformation;
                            var comp2 = context.CallTransformation(dependent, dependencyInput);

                            computation.MarkRequireInternal(comp2, ExecuteBefore, this);
                        });
                    }
                    else
                    {
                        foreach (var dependencyInput in inCollection)
                        {
                            GeneralTransformationRule dependent = DependencyTransformation;
                            var comp2 = context.CallTransformation(dependent, dependencyInput);

                            computation.MarkRequireInternal(comp2, ExecuteBefore, this);
                        }
                    }
                }
            }
        }