Example #1
2
        public static void report(StringWriter output, IList<Machine> machines, Robot robot)
        {
            output.Write("<h1>FACTORY REPORT</h1>\n");

            IEnumerator<Machine> line = machines.GetEnumerator();
            while (line.MoveNext())
            {
                Machine machine = line.Current;
                output.Write("<h2>" + machine.Name() + "</h2>\n");
                output.Write("<ul>\n");
                output.Write("<li>location = " + machine.Location() + "</li>\n");

                if (machine.Bin() != null)
                    output.Write("<li>bin containing " + machine.Bin() + "</li>\n");
                else
                    output.Write("<li>no bin</li>\n");

                output.Write("</ul>\n");
            }

            output.Write("<h2>Robot</h2>\n<ul>\n");
            if (robot.Location() != null)
                output.Write("<li>location = " + robot.Location().Name() + "</li>\n");

            if (robot.Bin() != null)
                output.Write("<li>bin containing " + robot.Bin() + "</li>\n");

            output.Write("</ul>\n");
        }
 /// <summary>
 /// Simplify a collection of <c>TaggedLineString</c>s.
 /// </summary>
 /// <param name="taggedLines">The collection of lines to simplify.</param>
 public virtual void Simplify(IList taggedLines)
 {
     for (IEnumerator i = taggedLines.GetEnumerator(); i.MoveNext(); )
         _inputIndex.Add((TaggedLineString)i.Current);
     for (IEnumerator i = taggedLines.GetEnumerator(); i.MoveNext(); )
     {
         TaggedLineStringSimplifier tlss
                       = new TaggedLineStringSimplifier(_inputIndex, _outputIndex);
         tlss.DistanceTolerance = _distanceTolerance;
         tlss.Simplify((TaggedLineString)i.Current);
     }
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="edges"></param>
 /// <param name="si"></param>
 /// <param name="testAllSegments"></param>
 public override void ComputeIntersections(IList edges, SegmentIntersector si, bool testAllSegments)
 {
     for (IEnumerator i0 = edges.GetEnumerator(); i0.MoveNext(); )
     {
         Edge edge0 = (Edge)i0.Current;
         for (IEnumerator i1 = edges.GetEnumerator(); i1.MoveNext(); )
         {
             Edge edge1 = (Edge)i1.Current;
             if (testAllSegments || edge0 != edge1)
                 ComputeIntersects(edge0, edge1, si);
         }
     }
 }
 protected override void PerformOperations(IList<IAccount> selectedAccs)
 {
     // Decides about to perform a write or read operation.
       int res = rnd.Next(100);
       if (res < UpdatesTax) {
     WriteOperations(selectedAccs.GetEnumerator());
     nrOfWriteIterations++;
       }
       else {
     int totalBal = ReadOperations(selectedAccs.GetEnumerator());
     int avgBal = totalBal / selectedAccs.Count;
     if (avgBal > maxAvgBalance) maxAvgBalance = avgBal;
     nrOfReadIterations++;
       }
 }
Example #5
1
        public static IList<CommandArgument> Load(IList<string> arguments)
        {
            var ret = new List<CommandArgument>();

            var enumerator = arguments.GetEnumerator();
            if (!enumerator.MoveNext())
                return ret;

            while (true)
            {
                if (enumerator.Current.StartsWith("-"))
                {
                    var argument = enumerator.Current.Substring(1);
                    bool hasNext = enumerator.MoveNext();
                    string value = hasNext && !enumerator.Current.StartsWith("-") ? enumerator.Current : null;

                    ret.Add(new CommandArgument { Argument = argument, Value = value });

                    if (hasNext && enumerator.Current.StartsWith("-")) //Skip movenext
                        continue;
                }
                else
                {
                    ret.Add(new CommandArgument { Value = enumerator.Current });
                }

                if (!enumerator.MoveNext())
                    break;
            }

            return ret;
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="dirEdgeList"></param>
        public void FindEdge(IList dirEdgeList)
        {
            /*
             * Check all forward DirectedEdges only.  This is still general,
             * because each edge has a forward DirectedEdge.
             */
            for (IEnumerator i = dirEdgeList.GetEnumerator(); i.MoveNext(); )
            {
                DirectedEdge de = (DirectedEdge) i.Current;
                if (!de.IsForward) continue;
                CheckForRightmostCoordinate(de);
            }

            /*
             * If the rightmost point is a node, we need to identify which of
             * the incident edges is rightmost.
             */
            Assert.IsTrue(minIndex != 0 || minCoord.Equals(minDe.Coordinate), "inconsistency in rightmost processing");
            if (minIndex == 0)
                 FindRightmostEdgeAtNode();
            else FindRightmostEdgeAtVertex();

            /*
             * now check that the extreme side is the R side.
             * If not, use the sym instead.
             */
            orientedDe = minDe;
            Positions rightmostSide = GetRightmostSide(minDe, minIndex);
            if (rightmostSide == Positions.Left)
                orientedDe = minDe.Sym;
        }
Example #7
1
        /// <summary>
        /// Find the innermost enclosing shell EdgeRing containing the argument EdgeRing, if any.
        /// The innermost enclosing ring is the <i>smallest</i> enclosing ring.
        /// The algorithm used depends on the fact that:
        /// ring A contains ring B iff envelope(ring A) contains envelope(ring B).
        /// This routine is only safe to use if the chosen point of the hole
        /// is known to be properly contained in a shell
        /// (which is guaranteed to be the case if the hole does not touch its shell).
        /// </summary>
        /// <param name="shellList"></param>
        /// <param name="testEr"></param>
        /// <returns>Containing EdgeRing, if there is one, OR
        /// null if no containing EdgeRing is found.</returns>
        public static EdgeRing FindEdgeRingContaining(EdgeRing testEr, IList shellList)
        {
            ILinearRing teString = testEr.Ring;
            IEnvelope testEnv = teString.EnvelopeInternal;

            EdgeRing minShell = null;
            IEnvelope minEnv = null;
            for (IEnumerator it = shellList.GetEnumerator(); it.MoveNext(); )
            {
                EdgeRing tryShell = (EdgeRing) it.Current;
                ILinearRing tryRing = tryShell.Ring;
                IEnvelope tryEnv = tryRing.EnvelopeInternal;
                if (minShell != null)
                    minEnv = minShell.Ring.EnvelopeInternal;
                bool isContained = false;
                // the hole envelope cannot equal the shell envelope
                if (tryEnv.Equals(testEnv)) continue;

                // ICoordinate testPt = PointNotInList(teString.Coordinates, tryRing.Coordinates);
                ICoordinate testPt = CoordinateArrays.PointNotInList(teString.Coordinates, tryRing.Coordinates);
                if (tryEnv.Contains(testEnv) && CGAlgorithms.IsPointInRing(testPt, tryRing.Coordinates))
                    isContained = true;
                // check if this new containing ring is smaller than the current minimum ring
                if (isContained)
                {
                    if (minShell == null || minEnv.Contains(tryEnv))
                        minShell = tryShell;
                }
            }
            return minShell;
        }
Example #8
1
 /// <summary>
 /// Returns a List containing the parent Edge (possibly null) for each of the given
 /// DirectedEdges.
 /// </summary>
 /// <param name="dirEdges"></param>
 /// <returns></returns>
 public static IList ToEdges(IList dirEdges)
 {
     IList edges = new ArrayList();
     for (IEnumerator i = dirEdges.GetEnumerator(); i.MoveNext(); ) 
         edges.Add(((DirectedEdge) i.Current).parentEdge);            
     return edges;
 }
Example #9
1
		private void StoreAll(IList expected)
		{
			for (IEnumerator objIter = expected.GetEnumerator(); objIter.MoveNext(); )
			{
				object obj = objIter.Current;
			}
		}
        /// <summary>
        /// Initializes a new instance of the <see cref="SmallBlockTableWriter"/> class.
        /// </summary>
        /// <param name="documents">a IList of POIFSDocument instances</param>
        /// <param name="root">the Filesystem's root property</param>
        public SmallBlockTableWriter(POIFSBigBlockSize bigBlockSize, IList documents,
                                     RootProperty root)
        {
            _sbat = new BlockAllocationTableWriter(bigBlockSize);
            _small_blocks = new ArrayList();
            _root         = root;
            IEnumerator iter = documents.GetEnumerator();

            while (iter.MoveNext())
            {
                POIFSDocument   doc    = ( POIFSDocument ) iter.Current;
                BlockWritable[] blocks = doc.SmallBlocks;

                if (blocks.Length != 0)
                {
                    doc.StartBlock=_sbat.AllocateSpace(blocks.Length);
                    for (int j = 0; j < blocks.Length; j++)
                    {
                        _small_blocks.Add(blocks[ j ]);
                    }
                } else {
            	    doc.StartBlock=POIFSConstants.END_OF_CHAIN;
                }
            }
            _sbat.SimpleCreateBlocks();
            _root.Size=_small_blocks.Count;
            _big_block_count = SmallDocumentBlock.Fill(bigBlockSize, _small_blocks);
        }
Example #11
1
 public ListEnumerator(IList list, int offset)
 {
     this.original = list;
     this.enumerator = list.GetEnumerator();
     this.offset = offset;
     this.AdjustOffset();
 }
Example #12
1
 public NumericRange(IList<double> values)
 {
     double num3;
     double num4;
     double current;
     Func<double, double> selector = null;
     double num = 0.0;
     double num2 = 0.0;
     goto Label_016A;
     Label_00F1:
     using (IEnumerator<double> enumerator = values.GetEnumerator())
     {
         goto Label_011B;
     Label_00FB:
         if ((((uint) current) - ((uint) num)) > uint.MaxValue)
         {
             goto Label_0142;
         }
         num4 += current * current;
     Label_011B:
         if (!enumerator.MoveNext())
         {
             goto Label_0157;
         }
         current = enumerator.Current;
         num = Math.Max(num, current);
         num2 = Math.Min(num2, current);
     Label_0142:
         num3 += current;
         goto Label_00FB;
     }
     Label_0157:
     this._xdc8f3f8857bee4c6 = values.Count;
     this._x628ea9b89457a2a9 = num;
     this._xd12d1dba8a023d95 = num2;
     this._x0eb49ee242305597 = num3 / ((double) this._xdc8f3f8857bee4c6);
     this._xcce91100698a4514 = Math.Sqrt(num4 / ((double) this._xdc8f3f8857bee4c6));
     if (((((uint) num2) & 0) != 0) || ((((uint) num2) + ((uint) current)) >= 0))
     {
         if (selector == null)
         {
             selector = new Func<double, double>(this, (IntPtr) this.xf29670e286f5562f);
         }
         double num6 = values.Sum<double>(selector);
         this._x8db8a12c7e795fea = Math.Sqrt(num6 / ((double) this._xdc8f3f8857bee4c6));
         if ((((uint) current) + ((uint) num4)) > uint.MaxValue)
         {
             goto Label_00F1;
         }
         if ((((uint) num6) - ((uint) current)) <= uint.MaxValue)
         {
             return;
         }
     }
     Label_016A:
     num3 = 0.0;
     num4 = 0.0;
     goto Label_00F1;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="lineList"></param>
 /// <param name="leftLoc"></param>
 /// <param name="rightLoc"></param>
 private void AddCurves(IList lineList, Locations leftLoc, Locations rightLoc)
 {
     for (IEnumerator i = lineList.GetEnumerator(); i.MoveNext(); )
     {
         ICoordinate[] coords = (ICoordinate[]) i.Current;
         AddCurve(coords, leftLoc, rightLoc);
     }
 }
Example #14
1
 /// <summary> 
 /// For nodes in the Collection, link the DirectedEdges at the node that are in the result.
 /// This allows clients to link only a subset of nodes in the graph, for
 /// efficiency (because they know that only a subset is of interest).
 /// </summary>
 /// <param name="nodes"></param>
 public static void LinkResultDirectedEdges(IList nodes)
 {
     for (IEnumerator nodeit = nodes.GetEnumerator(); nodeit.MoveNext(); ) 
     {
         Node node = (Node) nodeit.Current;
         ((DirectedEdgeStar) node.Edges).LinkResultDirectedEdges();
     }
 }
Example #15
1
 /// <summary>
 /// Add a collection of geometries to be polygonized.
 /// May be called multiple times.
 /// Any dimension of Geometry may be added;
 /// the constituent linework will be extracted and used.
 /// </summary>
 /// <param name="geomList">A list of <c>Geometry</c>s with linework to be polygonized.</param>
 public virtual void Add(IList geomList)
 {
     for (IEnumerator i = geomList.GetEnumerator(); i.MoveNext(); ) 
     {
         Geometry geometry = (Geometry) i.Current;
         Add(geometry);
     }
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="edges"></param>
 /// <param name="edgeSet"></param>
 private void Add(IList edges, object edgeSet)
 {
     for (IEnumerator i = edges.GetEnumerator(); i.MoveNext(); ) 
     {
         Edge edge = (Edge) i.Current;
         Add(edge, edgeSet);
     }
 }
 public PredictiveMaintenanceTelemetry(IConfigurationProvider config, ILogger logger, string deviceId, IList<ExpandoObject> dataset)
 {
     _config = config;
     _logger = logger;
     _deviceId = deviceId;
     _active = false;
     _data = dataset.GetEnumerator();
 }
Example #18
1
 private void Apply(IList toFree)
 {
     for (var slotIter = toFree.GetEnumerator(); slotIter.MoveNext();)
     {
         var slot = ((Slot) slotIter.Current);
         _freespaceManager.Free(slot);
     }
     toFree.Clear();
 }
		private void WriteIds(ByteArrayBuffer buffer, IList ids)
		{
			buffer.WriteInt(ids.Count);
			for (IEnumerator idIter = ids.GetEnumerator(); idIter.MoveNext(); )
			{
				int id = ((int)idIter.Current);
				buffer.WriteInt(id);
			}
		}
Example #20
0
        public async Task LoadAsync()
        {
            questions = await LanguageQuestion.LoadAsync();
            JoinAllAnswers();

            Debug.WriteLine(questions.Count);
            enumerator = questions.GetEnumerator();
            enumerator.MoveNext(); // TODO: Assert.
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="edges"></param>
 private void Add(IList edges)
 {
     for (IEnumerator i = edges.GetEnumerator(); i.MoveNext(); ) 
     {
         Edge edge = (Edge) i.Current;
         // edge is its own group
         Add(edge, edge);
     }
 }
Example #22
0
		public TestRunner (IList tests, string working_dir, Driver driver)
		{
			this.driver = driver;
			this.tests = tests;
			this.working_dir = working_dir;

			tests_enumerator = tests.GetEnumerator ();
			tests_lock = new object ();
		}
Example #23
0
 /// <summary>
 /// Adds a collection of Geometries to be processed. May be called multiple times.
 /// Any dimension of Geometry may be added; the constituent linework will be
 /// extracted.
 /// </summary>
 /// <param name="geometries"></param>
 public void Add(IList geometries)
 {
     IEnumerator i = geometries.GetEnumerator();
     while (i.MoveNext())
     {
         IGeometry geometry = (IGeometry) i.Current;
         Add(geometry);
     }
 }
Example #24
0
 public static IList<int> AddList(IList<int> list1, IList<int> list2)
 {
     IList<int> temp = NewList();
     IEnumerator<int> iter1 = list1.GetEnumerator();
     IEnumerator<int> iter2 = list2.GetEnumerator();
     while(iter1.MoveNext() != false){
       iter2.MoveNext();
       temp.Add(iter1.Current + iter2.Current);
     }
     return temp;
 }
Example #25
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="edges"></param>
 /// <returns></returns>
 private static IList ToSegmentStrings(IList edges)
 {
     // convert Edges to SegmentStrings
     IList segStrings = new ArrayList();
     for (IEnumerator i = edges.GetEnumerator(); i.MoveNext(); )
     {
         Edge e = (Edge)i.Current;
         segStrings.Add(new SegmentString(e.Coordinates, e));
     }
     return segStrings;
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="seq"></param>
 /// <param name="lines"></param>
 /// <returns></returns>
 public bool HasIntersectionWithLineStrings(ICoordinateSequence seq, IList lines)
 {
     for (IEnumerator i = lines.GetEnumerator(); i.MoveNext(); ) 
     {
         ILineString line = (ILineString) i.Current;
         HasIntersection(seq, line.CoordinateSequence);
         if (hasIntersection)
             break;
     }
     return hasIntersection;
 }
Example #27
0
            public FieldAndTermEnumAnonymousInnerClassHelper(List<Term> terms)
            {
                if (!terms.Any())
                {
                    throw new ArgumentException("no terms provided");
                }

                this.terms = terms;
                terms.Sort();
                iter = terms.GetEnumerator();
            }
 /// <summary>
 ///
 /// </summary>
 /// <param name="seq"></param>
 /// <param name="lines"></param>
 /// <returns></returns>
 public bool HasIntersectionWithLineStrings(IList<Coordinate> seq, IList lines)
 {
     for (IEnumerator i = lines.GetEnumerator(); i.MoveNext(); )
     {
         LineString line = (LineString)i.Current;
         HasIntersection(seq, line.Coordinates);
         if (_hasIntersection)
             break;
     }
     return _hasIntersection;
 }
 public AssemblyBundle(IList assemblyList)
 {
     this.assemblies = new ArrayList();
     IEnumerator iAssemblies = assemblyList.GetEnumerator();
     while (iAssemblies.MoveNext()) {
         AssemblyDefinition dfn = AssemblyFactory.GetAssembly((String)iAssemblies.Current);
         IAssembly assembly = new CompleteAssembly(dfn);
         //Console.WriteLine("ASSEMBLY: " + assembly.getAssemblyName() + "  " + dfn.GetType());
         this.assemblies.Add(assembly);
     }
     this.buildRelationships();
 }
Example #30
0
        public static Task <AccountProperties> GetDatabaseAccountFromAnyLocationsAsync(
            Uri defaultEndpoint,
            IList <string>?locations,
            Func <Uri, Task <AccountProperties> > getDatabaseAccountFn)
        {
            GetAccountPropertiesHelper threadSafeGetAccountHelper = new GetAccountPropertiesHelper(
                defaultEndpoint,
                locations?.GetEnumerator(),
                getDatabaseAccountFn);

            return(threadSafeGetAccountHelper.GetAccountPropertiesAsync());
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="edges0"></param>
 /// <param name="edges1"></param>
 /// <param name="si"></param>
 public override void ComputeIntersections(IList edges0, IList edges1, SegmentIntersector si)
 {
     for (IEnumerator i0 = edges0.GetEnumerator(); i0.MoveNext(); )
     {
         Edge edge0 = (Edge)i0.Current;
         for (IEnumerator i1 = edges1.GetEnumerator(); i1.MoveNext(); )
         {
             Edge edge1 = (Edge)i1.Current;
             ComputeIntersects(edge0, edge1, si);
         }
     }
 }
 public virtual IEnumerator GetEnumerator()
 {
     return(seq.GetEnumerator());
 }
Example #33
0
 public IEnumerator <List <int> > GetEnumerator()
 {
     return(_data.GetEnumerator());
 }
Example #34
0
 public IEnumerator <ReadOnlyMemory <byte> > GetEnumerator()
 {
     return(_segments?.GetEnumerator() ?? _lazySegments.GetEnumerator());
 }
 /// <inheritdoc/>
 public IEnumerator <T> GetEnumerator()
 {
     theLock.EnterWriteLock(); try {
         return(list.GetEnumerator());
     } finally { theLock.ExitWriteLock(); }
 }
Example #36
0
 /// <devdoc>
 ///    <para>Creates and retrieves a new enumerator for this collection.</para>
 /// </devdoc>
 public IEnumerator GetEnumerator()
 {
     return(designers.GetEnumerator());
 }
Example #37
0
 public IEnumerator <TValue> GetEnumerator() => _list?.GetEnumerator() ?? EmptyValues.GetEnumerator();
Example #38
0
 public IEnumerator <TEntity> GetEnumerator()
 {
     return(_copyEntities.GetEnumerator());
 }
Example #39
0
 public IEnumerator <SymbolicValue> GetEnumerator()
 {
     return(_slots.GetEnumerator());
 }
Example #40
0
 IEnumerator <ExecutionTreeNode> IEnumerable <ExecutionTreeNode> .GetEnumerator()
 {
     return(children?.GetEnumerator());
 }
Example #41
0
 /// <summary>
 /// Gets an <see cref="IEnumerator{T}"/> for the list.
 /// </summary>
 public IEnumerator <T> GetEnumerator()
 {
     return(new TypeSafeEnumeratorWrapper <T>(_inner.GetEnumerator()));
 }
Example #42
0
 /// <summary>
 ///   Produces an enumerator for the segments of the message body.
 /// </summary>
 ///
 /// <returns>An enumerator that can be used to iterate through the segments of the message body.</returns>
 ///
 public override IEnumerator <ReadOnlyMemory <byte> > GetEnumerator() =>
 _segments?.GetEnumerator() ?? _lazySegments.GetEnumerator();
Example #43
0
 System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
 {
     return(attributes.GetEnumerator());
 }
 public IEnumerator <KeyValuePair <string, string> > GetEnumerator()
 {
     return(_params.GetEnumerator());
 }
Example #45
0
 public override IEnumerator <IModelItem> getChildrenIterator()
 {
     return(_content.GetEnumerator());
 }
Example #46
0
 public IEnumerator <KeyValuePair <TKey, TValue> > GetEnumerator()
 {
     return(_keyValuePairs.GetEnumerator());
 }
Example #47
0
        // IBindableIterable implementation:

        public IBindableIterator First()
        {
            IEnumerator enumerator = list.GetEnumerator();

            return(new EnumeratorToIteratorAdapter <object>(new EnumerableToBindableIterableAdapter.NonGenericToGenericEnumerator(enumerator)));
        }
Example #48
0
 /// <summary>
 /// Returns an enumerator that iterates through the <see cref="termArrays"/> collection.
 /// </summary>
 /// <returns>An enumerator that can be used to iterate through the <see cref="termArrays"/> collection.</returns>
 // LUCENENET specific
 public IEnumerator <Term[]> GetEnumerator()
 {
     return(termArrays.GetEnumerator());
 }
 public IEnumerator <IArticleResultValues> GetEnumerator()
 {
     return(model.GetEnumerator());
 }
Example #50
0
 public IEnumerator GetEnumerator()
 {
     return(_list?.GetEnumerator() ?? Array.Empty <object>().GetEnumerator());
 }
Example #51
0
 public IEnumerator <T> GetEnumerator()
 {
     return(_configurations.GetEnumerator());
 }
 public IEnumerator <T> GetEnumerator()
 {
     return(_items.GetEnumerator());
 }
 public IEnumerator <IActionData> GetEnumerator()
 {
     return(data.GetEnumerator());
 }
Example #54
0
 /// <summary/>
 public IEnumerator <TimedValue <TTime, TValue> > GetEnumerator()
 {
     return(mySet.GetEnumerator());
 }
 public IEnumerator GetEnumerator() => _list?.GetEnumerator() ?? Array.Empty <object>().GetEnumerator();
Example #56
0
 public IEnumerator GetEnumerator()
 {
     return(m_items.GetEnumerator());
 }
 public IEnumerator <T> GetEnumerator()
 {
     return(_list.GetEnumerator());
 }
Example #58
0
 public IEnumerator <OpenerElement> GetEnumerator()
 {
     return(_targetBlankMimeTypeExtensions.GetEnumerator());
 }
Example #59
0
 public IEnumerator <T> GetEnumerator()
 {
     return(list?.GetEnumerator() ?? EmptyEnumerator());
        private void RunClause(Action <FunctionContext> clause, object dollarUnderbar, object inputToProcess)
        {
            ExecutionContext.CheckStackDepth();

            _anyClauseExecuted = true;
            Pipe oldErrorOutputPipe = this.Context.ShellFunctionErrorOutputPipe;

            // If the script block has a different language mode than the current,
            // change the language mode.
            PSLanguageMode?oldLanguageMode = null;
            PSLanguageMode?newLanguageMode = null;

            if ((_scriptBlock.LanguageMode.HasValue) &&
                (_scriptBlock.LanguageMode != Context.LanguageMode))
            {
                oldLanguageMode = Context.LanguageMode;
                newLanguageMode = _scriptBlock.LanguageMode;
            }

            try
            {
                var oldScopeOrigin = this.Context.EngineSessionState.CurrentScope.ScopeOrigin;

                try
                {
                    this.Context.EngineSessionState.CurrentScope.ScopeOrigin =
                        this._dontUseScopeCommandOrigin ? CommandOrigin.Internal : this.Command.CommandOrigin;

                    // Set the language mode. We do this before EnterScope(), so that the language
                    // mode is appropriately applied for evaluation parameter defaults.
                    if (newLanguageMode.HasValue)
                    {
                        Context.LanguageMode = newLanguageMode.Value;
                    }

                    bool?oldLangModeTransitionStatus = null;
                    try
                    {
                        // If it's from ConstrainedLanguage to FullLanguage, indicate the transition before parameter binding takes place.
                        if (oldLanguageMode == PSLanguageMode.ConstrainedLanguage && newLanguageMode == PSLanguageMode.FullLanguage)
                        {
                            oldLangModeTransitionStatus = Context.LanguageModeTransitionInParameterBinding;
                            Context.LanguageModeTransitionInParameterBinding = true;
                        }

                        EnterScope();
                    }
                    finally
                    {
                        if (oldLangModeTransitionStatus.HasValue)
                        {
                            // Revert the transition state to old value after doing the parameter binding
                            Context.LanguageModeTransitionInParameterBinding = oldLangModeTransitionStatus.Value;
                        }
                    }

                    if (commandRuntime.ErrorMergeTo == MshCommandRuntime.MergeDataStream.Output)
                    {
                        Context.RedirectErrorPipe(commandRuntime.OutputPipe);
                    }
                    else if (commandRuntime.ErrorOutputPipe.IsRedirected)
                    {
                        Context.RedirectErrorPipe(commandRuntime.ErrorOutputPipe);
                    }

                    if (dollarUnderbar != AutomationNull.Value)
                    {
                        _localsTuple.SetAutomaticVariable(AutomaticVariable.Underbar, dollarUnderbar, _context);
                    }
                    else if (_dollarUnderbar != AutomationNull.Value)
                    {
                        _localsTuple.SetAutomaticVariable(AutomaticVariable.Underbar, _dollarUnderbar, _context);
                    }

                    if (inputToProcess != AutomationNull.Value)
                    {
                        if (inputToProcess == null)
                        {
                            inputToProcess = MshCommandRuntime.StaticEmptyArray.GetEnumerator();
                        }
                        else
                        {
                            IList list = inputToProcess as IList;
                            inputToProcess = (list != null)
                                                 ? list.GetEnumerator()
                                                 : LanguagePrimitives.GetEnumerator(inputToProcess);
                        }

                        _localsTuple.SetAutomaticVariable(AutomaticVariable.Input, inputToProcess, _context);
                    }

                    clause(_functionContext);
                }
                catch (TargetInvocationException tie)
                {
                    // DynamicInvoke wraps exceptions, unwrap them here.
                    throw tie.InnerException;
                }
                finally
                {
                    Context.ShellFunctionErrorOutputPipe = oldErrorOutputPipe;

                    if (oldLanguageMode.HasValue)
                    {
                        Context.LanguageMode = oldLanguageMode.Value;
                    }

                    Context.EngineSessionState.CurrentScope.ScopeOrigin = oldScopeOrigin;
                }
            }
            catch (ExitException ee)
            {
                if (!this.FromScriptFile || _rethrowExitException)
                {
                    throw;
                }

                this._exitWasCalled = true;

                int exitCode = (int)ee.Argument;
                this.Command.Context.SetVariable(SpecialVariables.LastExitCodeVarPath, exitCode);

                if (exitCode != 0)
                {
                    this.commandRuntime.PipelineProcessor.ExecutionFailed = true;
                }
            }
            catch (FlowControlException)
            {
                throw;
            }
            catch (RuntimeException e)
            {
                // This method always throws.
                ManageScriptException(e);
            }
            catch (Exception e)
            {
                // This cmdlet threw an exception, so wrap it and bubble it up.
                throw ManageInvocationException(e);
            }
        }