/// <summary> /// Creates a statementLine using the given member data. /// </summary> /// <returns>Returns the generated CodeStatement.</returns> public CodeStatement CreateStatement() { CodeCatchClause codeCatchClause; if (Type != null && Catch != null) { codeCatchClause = new CodeCatchClause(LocalName, new CodeTypeReference(Type), Catch.Select(s => s.CreateStatement()).ToArray()); } else if (Type != null && Catch == null) { codeCatchClause = new CodeCatchClause(LocalName, new CodeTypeReference(Type)); } else { codeCatchClause = new CodeCatchClause(LocalName); } return(Finally != null ? new CodeTryCatchFinallyStatement(Try.Select(s => s.CreateStatement()).ToArray(), new[] { codeCatchClause }, Finally.Select(s => s.CreateStatement()).ToArray()) : new CodeTryCatchFinallyStatement(Try.Select(s => s.CreateStatement()).ToArray(), new[] { codeCatchClause })); }
public static Finally SuspendProcess(Process process) { var suspendedThreads = new HashSet <IntPtr>(); foreach (ProcessThread thread in process.Threads) { var hThread = Win32.OpenThread(ThreadAccessFlags.SuspendResume, false, thread.Id); if (hThread != IntPtr.Zero) { suspendedThreads.Add(hThread); Win32.SuspendThread(hThread); } else { Console.WriteLine("Could not open thread {0}", thread.Id); } } return(Finally.Do(() => { foreach (IntPtr hThread in suspendedThreads) { Win32.ResumeThread(hThread); Win32.CloseHandle(hThread); } })); }
protected override void EmitInternal(Context ctx, bool mustReturn) { var gen = ctx.CurrentMethod.Generator; var backup = ctx.CurrentTryBlock; ctx.CurrentTryBlock = this; EndLabel = gen.BeginExceptionBlock(); Code.Emit(ctx, false); gen.EmitLeave(EndLabel); foreach (var curr in CatchClauses) { curr.Emit(ctx, false); } if (Finally != null) { gen.BeginFinallyBlock(); Finally.Emit(ctx, false); } gen.EndExceptionBlock(); ctx.CurrentTryBlock = backup; }
/// <summary> /// Add action to Finally block /// </summary> /// <param name="action">Action to add</param> public void AddFinally(IScriptAction action) { if (Finally == null) { Finally = new Block(); } Finally.Add(action); }
public UniRx.IObservable <float> CreateNewRoutine(float duration, bool isEnter) { if (isEnter) { _enterInQue = false; return (RoutineRunner(duration) .DoOnCancel(() => { EnterCancel.Invoke(); _enterInQue = true; }) .DoOnSubscribe(() => { IsInTransition.Value = true; }) .Do(f => { if (duration > 0) { _enterRoutine(f); } }) .DoOnCompleted(() => { if (duration == 0) { _enterCall(); } _currentState.Value = this; _enterInQue = true; IsInTransition.Value = false; })); } _exitInQue = false; return (RoutineRunner(duration) .DoOnCancel(() => { ExitCancel.Invoke(); _exitInQue = true; }) .DoOnSubscribe(() => IsInTransition.Value = true) .Do(f => { if (duration > 0) { _exitRoutine(f); } }) .DoOnCompleted(() => { if (duration == 0) { _exitCall(); } _exitInQue = true; IsInTransition.Value = false; Finally.Invoke(); })); }
public Expression Update(Expression body, IEnumerable <CatchBlock> handlers, Expression @finally) { if (Body.Equals(body) && Finally.Equals(@finally) && Handlers.Equals(handlers)) { return(this); } return(AstExpression.TryCatch(_tryCatch, ParentScope, Visitor)); }
public override int GetHashCode() { unchecked { int hashCode = (Code != null ? Code.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (CatchClauses != null ? CatchClauses.GetHashCode() : 0); hashCode = (hashCode * 397) ^ (Finally != null ? Finally.GetHashCode() : 0); return(hashCode); } }
public override int GetHashCode() { unchecked { var hashCode = 37 + Body.GetHashCode(); hashCode = (hashCode * 397) ^ CatchBlocks.GetHashCode(); hashCode = (hashCode * 397) ^ Finally.GetHashCode(); return(hashCode); } }
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment) { if (Try == null || Try.Body.Count == 0) { return(Completion.Void); } ExecutionEnvironment te = new ExecutionEnvironment(enviroment); var c = Try.Execute(te); if (c.Type == CompletionType.Exception) { ExecutionEnvironment ec = new ExecutionEnvironment(enviroment); ec.RegisterValue("e", c.ReturnValue); if (Catch != null && Catch.Body.Count > 0) { ExecutionEnvironment ee = new ExecutionEnvironment(ec); c = Catch.Execute(ee); } else { c = Completion.Void; } if (c.Type == CompletionType.Exception) { return(c); } } Completion fc = Completion.Void; if (Finally != null && Finally.Body.Count > 0) { ExecutionEnvironment fe = new ExecutionEnvironment(enviroment); fc = Finally.Execute(fe); } if (c.Type == CompletionType.Return) { return(c); } else if (c.Type == CompletionType.Value) { return(c); } if (fc.Type == CompletionType.Return) { return(fc); } return(c); }
public override void Visit(CommandVisitor visitor) { base.Visit(visitor); if (Try != null) { Try.Visit(visitor); } if (Catch != null) { Catch.Visit(visitor); } if (Finally != null) { Finally.Visit(visitor); } }
public DotNetRulesContext(Type policy) { if (policy == null) { throw new ArgumentNullException("policy"); } var constructorInfo = policy.GetConstructor(Type.EmptyTypes); if (constructorInfo == null) { throw new Exception(string.Format("Policy {0} needs constructor without any arguments", policy)); } _policy = constructorInfo.Invoke(null); _establishClause = Helper.GetFieldValuesFor <Establish>(_policy, policy.GetInstanceFieldsOfType <Establish>()).FirstOrDefault(); _givenClauses = Helper.GetFieldValuesFor <Given>(_policy, policy.GetInstanceFieldsOfType <Given>()); _orClauses = Helper.GetFieldValuesFor <Or>(_policy, policy.GetInstanceFieldsOfType <Or>()); _thenClauses = Helper.GetFieldValuesFor <Then>(_policy, policy.GetInstanceFieldsOfType <Then>()); _finally = Helper.GetFieldValuesFor <Finally>(_policy, policy.GetInstanceFieldsOfType <Finally>()).FirstOrDefault(); }
public static int Main() { Finally f = new Finally(); TestLibrary.TestFramework.BeginTestCase("Finally blocks"); if (f.RunTests()) { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("PASS"); return(100); } else { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("FAIL"); return(0); } }
public static int Main() { Finally f = new Finally(); TestLibrary.TestFramework.BeginTestCase("Finally blocks"); if (f.RunTests()) { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("PASS"); return 100; } else { TestLibrary.TestFramework.EndTestCase(); TestLibrary.TestFramework.LogInformation("FAIL"); return 0; } }
internal override void EmitStmt(ILGenerator ilg) { ilg.BeginExceptionBlock(); WrapEmit(Stmt, ilg); if (Catches.Length == 0 && Finally == null) { ilg.BeginCatchBlock(Compilation.Get(NativeType.Object).Type); } foreach (var c in Catches) { WrapEmit(c, ilg); } if (Finally != null) { Finally.Emit(ilg); } ilg.EndExceptionBlock(); UnwrapReturn(ilg); }
private IEnumerator <object> SetCurrentSnapshot(HeapSnapshotInfo info) { var oldSnapshot = Snapshot; if (oldSnapshot != null) { oldSnapshot.Info.ReleaseStrongReference(); } using (Finally.Do(() => { UseWaitCursor = false; })) { var fSnapshot = Instance.GetSnapshot(info); yield return(fSnapshot); Snapshot = fSnapshot.Result; RefreshHeap(); } }
public DelegateAsyncCommand(Func <object, Task> execute, bool canExecute = true) : base(parameter => execute(parameter), canExecute) { base.execute = async paramter => { try { SetCanExecute(false); await execute(paramter); } catch (Exception ex) { Exception?.Invoke(this, new DelegateExceptionEventArgs(ex)); } finally { SetCanExecute(true); Finally?.Invoke(this, EventArgs.Empty); } }; }
public override AstVisitAction VisitTryStatement(TryStatementAst tryStatementAst) { var tryBody = VisitSyntaxNode(tryStatementAst.Body); var body = tryBody as Block; if (body == null) { body = new Block(tryBody); } var catches = new List <Catch>(); foreach (var catchClause in tryStatementAst.CatchClauses) { var catchNode = VisitSyntaxNode(catchClause) as Catch; catches.Add(catchNode); } if (tryStatementAst.Finally != null) { var fin = VisitSyntaxNode(tryStatementAst.Finally); var finBody = fin as Block; if (finBody == null) { finBody = new Block(fin); } var fina = new Finally(finBody); _currentNode = new Try(body, catches, fina); } else { _currentNode = new Try(body, catches); } return(AstVisitAction.SkipChildren); }
public Completion Execute(ExecutionEnvironment enviroment) { if (Try == null || Try.Body.Count == 0) { return(Completion.Void); } ExecutionEnvironment te = new ExecutionEnvironment(enviroment); var c = Try.Execute(te); if (c.Type == CompletionType.Exception) { if (Catch != null && Catch.Body.Count > 0) { ExecutionEnvironment ee = new ExecutionEnvironment(enviroment); c = Catch.Execute(ee); } } Completion fc = Completion.Void; if (Finally != null && Finally.Body.Count > 0) { ExecutionEnvironment fe = new ExecutionEnvironment(enviroment); fc = Finally.Execute(fe); } if (c.Type == CompletionType.Return) { return(c); } else if (c.Type == CompletionType.Value) { return(fc); } if (fc.Type == CompletionType.Return) { return(fc); } return(c); }
public override Statement VisitFinally(Finally Finally) { if (Finally == null) return null; BlockScope savedCurrentFinallyClause = this.currentFinallyClause; this.currentFinallyClause = Finally.Block.Scope; Finally.Block = this.VisitBlock(Finally.Block); this.currentFinallyClause = savedCurrentFinallyClause; return Finally; }
private bool Equals(TryBlock other) { return(Body.Equals(other.Body) && CatchBlocks.Equals(other.CatchBlocks) && Finally.Equals(other.Finally)); }
public override Statement VisitFinally(Finally Finally) { throw new ApplicationException("unimplemented"); }
protected override void BeginProcessing() { // convert scripts to strings _Script = Script.ToString(); if (Begin != null) { _Begin = Begin.ToString(); } if (End != null) { _End = End.ToString(); } if (Finally != null) { _Finally = Finally.ToString(); } // Count if (_Count <= 0) { _Count = Environment.ProcessorCount; } // MaxQueue after Count if (MaxLoad < int.MaxValue / _Count) { MaxQueue = _Count * MaxLoad; } // to import modules if (Module != null) { _iss.ImportPSModule(Module); } // import variables _iss.Variables.Add(new SessionStateVariableEntry("LogEngineLifeCycleEvent", false, string.Empty)); // whole log disabled _iss.Variables.Add(new SessionStateVariableEntry("LogProviderLifeCycleEvent", false, string.Empty)); // start is still logged if (Variable != null) { foreach (var name in Variable) { _iss.Variables.Add(new SessionStateVariableEntry(name, GetVariableValue(name), string.Empty)); } } // import functions if (Function != null) { foreach (var name in Function) { var function = (FunctionInfo)SessionState.InvokeCommand.GetCommand(name, CommandTypes.Function); _iss.Commands.Add(new SessionStateFunctionEntry(name, function.Definition)); } } // verbose state object parameter; if (MyInvocation.BoundParameters.TryGetValue("Verbose", out parameter)) { _verbose = ((SwitchParameter)parameter).ToBool(); } else { // #12 VerbosePreference value can be anything ActionPreference preference; if (LanguagePrimitives.TryConvertTo <ActionPreference>(GetVariableValue("VerbosePreference"), out preference)) { _verbose = preference != ActionPreference.SilentlyContinue; } } }
protected internal virtual Node TransformFinally(Finally @finally) { return @finally.AcceptTransformer(this, true); }
protected internal virtual Node TransformFinally(Finally @finally) { return(@finally.AcceptTransformer(this, true)); }
protected internal virtual void TraverseFinally(Finally @finally) { TraverseClause(@finally); }
public override Statement VisitFinally(Finally Finally) { if (Finally == null) return null; return base.VisitFinally((Finally)Finally.Clone()); }
protected internal override Node TransformFinally(Finally @finally) { return(Dispatch(@finally)); }
IEnumerator <object> SearchInFiles(SearchQuery search, BlockingQueue <string> filenames, IFuture completionFuture) { var searchedFiles = new HashSet <string>(StringComparer.Ordinal); var buffer = new List <SearchResult>(); var sb = new StringBuilder(); int numFiles = 0; using (Finally.Do(() => { SetSearchResults(buffer); lblStatus.Text = String.Format("{0} result(s) found.", buffer.Count); pbProgress.Style = ProgressBarStyle.Continuous; pbProgress.Value = 0; })) while (filenames.Count > 0 || !completionFuture.Completed) { var f = filenames.Dequeue(); yield return(f); var filename = f.Result as string; if (filename == null) { continue; } if (searchedFiles.Contains(filename)) { continue; } if (PendingSearchQuery != null) { break; } searchedFiles.Add(filename); int lineNumber = 0; var lineBuffer = new LineEntry[3]; var insertResult = (Action)(() => { var item = new SearchResult(); item.Filename = filename; item.LineNumber = lineBuffer[1].LineNumber; sb.Remove(0, sb.Length); for (int i = 0; i < 3; i++) { if (lineBuffer[i].Text != null) { var line = lineBuffer[i].Text; if (line.Length > 512) { line = line.Substring(0, 512); } sb.Append(line); } if (i < 2) { sb.Append("\r\n"); } } item.Context = sb.ToString(); buffer.Add(item); if ((buffer.Count % 250 == 0) || ((buffer.Count < 50) && (buffer.Count % 5 == 1))) { SetSearchResults(buffer); } }); var stepSearch = (Action)(() => { string currentLine = lineBuffer[1].Text; if ((currentLine != null) && search.Regex.IsMatch(currentLine)) { insertResult(); } }); var insertLine = (Action <LineEntry>)((line) => { lineBuffer[0] = lineBuffer[1]; lineBuffer[1] = lineBuffer[2]; lineBuffer[2] = line; stepSearch(); }); numFiles += 1; if (numFiles % 50 == 0) { lblStatus.Text = String.Format("Scanning '{0}'...", filename); if (completionFuture.Completed) { int totalNumFiles = numFiles + filenames.Count; int progress = (numFiles * 1000 / totalNumFiles); if (pbProgress.Value != progress) { pbProgress.Value = progress; } if (pbProgress.Style != ProgressBarStyle.Continuous) { pbProgress.Style = ProgressBarStyle.Continuous; } } } // Opening files is slow over network shares. FileDataAdapter adapter = null; var fAdapter = Future.RunInThread( () => new FileDataAdapter(filename, System.IO.FileMode.Open, System.IO.FileAccess.Read) ); yield return(fAdapter); if (fAdapter.Failed) { continue; } else { adapter = fAdapter.Result; } using (adapter) { var fEncoding = Future.RunInThread( () => DetectEncoding(adapter.BaseStream) ); yield return(fEncoding); Future <string> thisLine = null, nextLine = null; using (var reader = new AsyncTextReader(adapter, fEncoding.Result, SearchBufferSize)) while (true) { thisLine = nextLine; if (thisLine != null) { yield return(thisLine); } nextLine = reader.ReadLine(); if (thisLine == null) { continue; } lineNumber += 1; string line = thisLine.Result; insertLine(new LineEntry { Text = line, LineNumber = lineNumber }); if (line == null) { break; } if (PendingSearchQuery != null) { break; } if (lineNumber % 10000 == 5000) { var newStatus = String.Format("Scanning '{0}'... (line {1})", filename, lineNumber); if (lblStatus.Text != newStatus) { lblStatus.Text = newStatus; } } } } } }
public virtual Statement VisitFinally(Finally Finally1, Finally Finally2) { if (Finally1 == null) return null; if (Finally2 == null) Finally1.Block = this.VisitBlock(Finally1.Block, null); else Finally1.Block = this.VisitBlock(Finally1.Block, Finally2.Block); return Finally1; }
protected internal override void TraverseFinally(Finally @finally) { _writer.WriteLine("finally"); TraverseClause(@finally); }
protected internal override Node TransformFinally(Finally @finally) { return Dispatch(@finally); }
public override Statement VisitFinally(Finally Finally){ if (Finally == null) return null; this.continueTargets.Add(Finally); this.exitTargets.Add(Finally); Finally.Block = this.VisitBlock(Finally.Block); this.continueTargets.Count--; this.exitTargets.Count--; return Finally; }
public void RegisterFinally(Finally handler) => _runFinally += handler;
protected internal override void TraverseFinally(Finally @finally) { Dispatch(@finally); }
public virtual Statement VisitFinally(Finally Finally){ if (Finally == null) return null; Finally.Block = this.VisitBlock(Finally.Block); return Finally; }
protected IEnumerator <object> SymbolResolverTask() { var batch = new List <PendingSymbolResolve>(); var nullProgress = new CallbackProgressListener(); ActivityIndicator.CountedItem progress = null; while (true) { var count = SymbolResolveBatchSize - batch.Count; SymbolResolveQueue.DequeueMultiple(batch, count); if (batch.Count == 0) { if (progress != null) { progress.Decrement(); progress = null; } if (!SymbolResolveState.Progress.Active && (SymbolResolveQueue.Count <= 0)) { SymbolResolveState.Count = 0; } var f = SymbolResolveQueue.Dequeue(); using (f) yield return(f); batch.Add(f.Result); } else { if (progress == null) { progress = SymbolResolveState.Progress.Increment(); } var maximum = SymbolResolveState.Count + Math.Max(0, SymbolResolveQueue.Count) + 1; progress.Maximum = maximum; progress.Progress = Math.Min(maximum, SymbolResolveState.Count); string infile = Path.GetTempFileName(), outfile = Path.GetTempFileName(); var padNumberRight = (Func <uint, int, string>)((num, length) => { var result = String.Format("{0:X}", num); if (result.Length < length) { result = new String(' ', length - result.Length) + result; } return(result); }); var symbolModules = SymbolModules.ToArray(); yield return(Future.RunInThread(() => { using (var sw = new StreamWriter(infile, false, Encoding.ASCII)) { sw.WriteLine("// Loaded modules:"); sw.WriteLine("// Base Size Module"); foreach (var module in symbolModules) { sw.WriteLine( "// {0} {1} {2}", padNumberRight(module.BaseAddress, 8), padNumberRight(module.Size, 8), Path.GetFullPath(module.Filename) ); } sw.WriteLine("//"); sw.WriteLine("// Process modules enumerated."); sw.WriteLine(); sw.WriteLine("*- - - - - - - - - - Heap 0 Hogs - - - - - - - - - -"); sw.WriteLine(); for (int i = 0; i < batch.Count; i++) { sw.WriteLine( "{0:X8} bytes + {1:X8} at {2:X8} by BackTrace{3:X8}", 1, 0, i + 1, i + 1 ); sw.WriteLine("\t{0:X8}", batch[i].Frame); sw.WriteLine(); } } })); var psi = new ProcessStartInfo( Settings.UmdhPath, String.Format( "\"{0}\" -f:\"{1}\"", infile, outfile ) ); using (var rp = Scheduler.Start( Program.RunProcess(psi, ProcessPriorityClass.Idle), TaskExecutionPolicy.RunAsBackgroundTask )) yield return(rp); using (Finally.Do(() => { try { File.Delete(infile); } catch { } try { File.Delete(outfile); } catch { } })) { var rtc = new RunToCompletion <HeapDiff>( HeapDiff.FromFile(outfile, nullProgress) ); using (rtc) yield return(rtc); var fProcess = Future.RunInThread(() => { var cacheBatch = Database.SymbolCache.CreateBatch(batch.Count); DecisionUpdateCallback <HashSet <UInt32> > updateCallback = (ref HashSet <UInt32> oldValue, ref HashSet <UInt32> newValue) => { newValue.UnionWith(oldValue); return(true); }; foreach (var traceback in rtc.Result.Tracebacks) { var index = (int)(traceback.Key) - 1; var key = batch[index].Frame; var frame = traceback.Value.Frames.Array[traceback.Value.Frames.Offset]; batch[index].Result.Complete(frame); lock (SymbolResolveLock) { ResolvedSymbolCache[key] = frame; PendingSymbolResolves.Remove(key); } cacheBatch.Add(key, frame); if (frame.Function != null) { var tempHash = new HashSet <uint>(); tempHash.Add(key); } } foreach (var frame in batch) { if (frame.Result.Completed) { continue; } Interlocked.Increment(ref TotalFrameResolveFailures); var tf = new TracebackFrame(frame.Frame); frame.Result.Complete(tf); lock (SymbolResolveLock) { ResolvedSymbolCache[frame.Frame] = tf; PendingSymbolResolves.Remove(frame.Frame); } cacheBatch.Add(frame.Frame, tf); // Console.WriteLine("Could not resolve: {0:X8}", frame.Frame); } return(new IBatch[] { cacheBatch }); }); yield return(fProcess); foreach (var manglerBatch in fProcess.Result) { yield return(manglerBatch.Execute()); } Interlocked.Add(ref SymbolResolveState.Count, batch.Count); batch.Clear(); } } } }
public virtual void VisitFinally(Finally Finally) { if (Finally == null) return; this.VisitBlock(Finally.Block); }
public virtual Differences VisitFinally(Finally finally1, Finally finally2){ Differences differences = new Differences(finally1, finally2); if (finally1 == null || finally2 == null){ if (finally1 != finally2) differences.NumberOfDifferences++; else differences.NumberOfSimilarities++; return differences; } Finally changes = (Finally)finally2.Clone(); Finally deletions = (Finally)finally2.Clone(); Finally insertions = (Finally)finally2.Clone(); Differences diff = this.VisitBlock(finally1.Block, finally2.Block); if (diff == null){Debug.Assert(false); return differences;} changes.Block = diff.Changes as Block; deletions.Block = diff.Deletions as Block; insertions.Block = diff.Insertions as Block; Debug.Assert(diff.Changes == changes.Block && diff.Deletions == deletions.Block && diff.Insertions == insertions.Block); differences.NumberOfDifferences += diff.NumberOfDifferences; differences.NumberOfSimilarities += diff.NumberOfSimilarities; if (differences.NumberOfDifferences == 0){ differences.Changes = null; differences.Deletions = null; differences.Insertions = null; }else{ differences.Changes = changes; differences.Deletions = deletions; differences.Insertions = insertions; } return differences; }
public virtual Statement VisitFinally(Finally Finally, Finally changes, Finally deletions, Finally insertions){ this.UpdateSourceContext(Finally, changes); if (Finally == null) return changes; if (changes != null){ if (deletions == null || insertions == null) Debug.Assert(false); else{ } }else if (deletions != null) return null; return Finally; }
public virtual void VisitFinally(Finally node) { node.Body.Accept(this); }
protected internal override T ReduceFinally(Finally @finally) { return(Dispatch(@finally)); }
public double Satisfy (State s, Finally @finally) { // Search states such that enclosed in finally is true var validStates = States.Where (x => Satisfy(x, @finally.Enclosed) > 0); if (validStates.Contains (s)) return 1; else if (validStates.Count () == 0) return 0; Console.WriteLine ("---------- [States satisfying enclosed]"); Console.WriteLine (string.Join (", ", validStates.Select (x => x.Identifier))); Console.WriteLine ("----------"); var smToValidStates = new MarkovChain (); foreach (var state in validStates) { DFS (validStates, smToValidStates); } Console.WriteLine ("---------- [States in S tilde]"); Console.WriteLine (string.Join (", ", smToValidStates.States.Select (x => x.Identifier))); Console.WriteLine ("----------"); var table = smToValidStates.BuildConversionTable (); var transitions = smToValidStates.GetTransitionMatrix(table); /* Console.WriteLine ("---------- [Conversion Table]"); Console.WriteLine (string.Join ("\n", table.Select (x => x.Key + ":" + x.Value))); Console.WriteLine ("----------"); Console.WriteLine ("---------- [Transitions]"); Console.WriteLine (transitions); Console.WriteLine ("----------"); */ // Build the transition matrix for this sub state-machine var system = new DiagonalMatrix (transitions.RowCount, transitions.ColumnCount, 1) - transitions; /* Console.WriteLine ("---------- [System]"); Console.WriteLine (system); Console.WriteLine ("----------"); */ var vector = new DenseVector ( smToValidStates.States.Select (x => Transitions.Where (y => y.From.Equals (x)) .Where (y => validStates.Contains (y.To)) .Select (y => y.Probability).Sum () ).ToArray () ); /* Console.WriteLine ("---------- [Vector]"); Console.WriteLine (vector); Console.WriteLine ("----------"); */ var result = system.LU ().Solve (vector); /* Console.WriteLine ("---------- [Result]"); Console.WriteLine (result); Console.WriteLine ("----------"); */ return table.ContainsKey (s.Identifier) ? result[table[s.Identifier]] : 0; }