コード例 #1
0
 public void InitializeOutput(object output)
 {
     if (OutputDelay != null)
     {
         OutputDelay.ExecutePersistors(output);
     }
     OutputDelay = null;
 }
コード例 #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;
        }
コード例 #3
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);
                        }
                    }
                }
            }
        }
コード例 #4
0
ファイル: ComputationContext.cs プロジェクト: FrederikP/NMF
        /// <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;
        }
コード例 #5
0
 internal static void DelayOutput(this Computation computation, OutputDelay outputDelay)
 {
     var cc = computation.Context as ComputationContext;
     cc.DelayOutput(outputDelay);
 }
コード例 #6
0
ファイル: MultipleDependency.cs プロジェクト: FrederikP/NMF
        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);
                        }
                    }
                }
            }
        }