public static EngineResult Evaluate( Table table, IList <ColumnReferenceExpression> cols, ValuesInsertSource values, IArgument arg, IOutputSink sink, Scope scope) { foreach (var valuesExpr in values.RowValues) { var row = table.NewRow(scope.Env); for (var i = 0; i < cols.Count; ++i) { // TODO: take the last instead of the first? need more robust handling of multi-part names here var name = cols[i].MultiPartIdentifier.Identifiers[0].Value; row.SetValue(name, Evaluate(valuesExpr.ColumnValues[i], arg, scope)); } sink.Inserted(row, scope.Env); } scope.Env.RowCount = values.RowValues.Count; return(new EngineResult(values.RowValues.Count)); }
public SomeAlwaysRequiredProject(IProjectService projectService, IOutputSink output) { output.WriteVerboseMessage($"Executing {nameof(MountEverestBaseCampTrack)}.ctor"); this.projectService = projectService; this.output = output; }
public RentANewApartment(IProjectService projectService, IActionService actionService, IActionListService actionListService, IOutputSink output, ISomeSingletonService someSingletonService) { this.projectService = projectService; this.actionService = actionService; this.actionListService = actionListService; this.output = output; this.someSingletonService = someSingletonService; }
public TasksCommand(IOutputSink output, IReviewsProviderFactory reviewsProviderFactory) { System.Diagnostics.Debug.Assert(output != null); System.Diagnostics.Debug.Assert(reviewsProviderFactory != null); this.output = output; this.reviewsProviderFactory = reviewsProviderFactory; }
public MountEverestBaseCampTrack(IProjectService projectService, IActionService actionService, IActionListService actionListService, IOutputSink output, ISomeSingletonService someSingletonService) { output.WriteVerboseMessage($"Executing {nameof(MountEverestBaseCampTrack)}.ctor"); this.projectService = projectService; this.actionService = actionService; this.actionListService = actionListService; this.output = output; this.someSingletonService = someSingletonService; }
public static EngineResult Evaluate(InsertSpecification insert, IOutputSink sink, Scope scope) { var table = scope.Env.GetTable((NamedTableReference)insert.Target); return(insert.InsertSource switch { ValuesInsertSource values => Evaluate(table, insert.Columns, values, NullArgument.It, sink, scope), SelectInsertSource select => Evaluate(table, insert.Columns, Evaluate(@select.Select, scope).ResultSet, sink, scope), _ => throw FeatureNotSupportedException.Subtype(insert.InsertSource) });
public MountEverestBaseCampTrackNextSteps(IActionService actionService, IActionListService actionListService, IOutputSink output, ISomeSingletonService someSingletonService) { output.WriteVerboseMessage($"Executing {nameof(MountEverestBaseCampTrackNextSteps)}.ctor"); this.actionService = actionService; this.actionListService = actionListService; this.output = output; this.someSingletonService = someSingletonService; // TODO: How to silence the compiler? MountEverestBaseCampTrack = new MountEverestBaseCampTrack.Yield(); }
public Runtime(IOutputSink outputSink, IEnumerable <string> commands, IEnumerable <string> commandGroups, bool filter, string computerName, string userName, string password) { OutputSink = outputSink; Commands = commands; CommandGroups = commandGroups; FilterResults = filter; ComputerName = computerName; UserName = userName; Password = password; // test a remote connection first if a remote system is specified if (!string.IsNullOrEmpty(computerName)) { try { if (!string.IsNullOrEmpty(userName) && !string.IsNullOrEmpty(password)) { OutputSink.WriteHost($"[*] Running commands remotely against the host '{computerName}' with credentials -> user:{UserName} , password:{Password}\r\n"); var options = new ConnectionOptions(); options.Username = UserName; options.Password = Password; options.Impersonation = ImpersonationLevel.Impersonate; options.EnablePrivileges = true; var scope = new ManagementScope($"\\\\{computerName}\\root\\cimv2", options); scope.Connect(); } else { OutputSink.WriteHost($"[*] Running commands remotely against the host '{computerName}' with current user credentials\r\n"); var scope = new ManagementScope($"\\\\{computerName}\\root\\cimv2"); scope.Connect(); } InitializeCommands(); } catch (Exception e) { OutputSink.WriteError($"Error connecting to \"{computerName}\" : {e.Message}"); Environment.Exit(1); } wmiRegProv = WMIUtil.WMIRegConnection(computerName, userName, password); } else { InitializeCommands(); } }
public Seatbelt(string[] args) { Options = (new SeatbeltArgumentParser(args)).Parse(); _outputSink = OutputSinkFromArgs(Options.OutputFile); _runtime = new Runtime( _outputSink, Options.Commands, Options.CommandGroups, Options.FilterResults, Options.ComputerName, Options.UserName, Options.Password ); }
public static EngineResult Evaluate(UpdateSpecification update, IOutputSink sink, Scope scope) { var tableRef = (NamedTableReference)update.Target; var table = scope.Env.Tables[tableRef.SchemaObject.BaseIdentifier.Value]; var rowCount = 0; foreach (var row in table.Rows) { if (update.WhereClause == null || Evaluate(update.WhereClause.SearchCondition, new RowArgument(row), scope)) { Evaluate(update.SetClauses, row, row, sink, scope); rowCount++; } } scope.Env.RowCount = rowCount; return(new EngineResult(rowCount)); }
public static EngineResult Evaluate(DeleteSpecification delete, IOutputSink sink, Scope scope) { var tableRef = (NamedTableReference)delete.Target; var table = scope.Env.Tables[tableRef.SchemaObject.BaseIdentifier.Value]; var rowCount = 0; foreach (var row in table.Rows.ToList()) { if (delete.WhereClause == null || Evaluate(delete.WhereClause.SearchCondition, new RowArgument(row), scope)) { table.Rows.Remove(row); rowCount++; } sink.Deleted(row, scope.Env); } scope.Env.RowCount = rowCount; return(new EngineResult(rowCount)); }
public static EngineResult Evaluate( Table table, IList <ColumnReferenceExpression> cols, Table selectedRows, IOutputSink sink, Scope scope) { foreach (var valuesExpr in selectedRows.Rows) { var row = table.NewRow(scope.Env); foreach (var col in cols) { var columnName = col.MultiPartIdentifier.Identifiers[0].Value; row.SetValue(columnName, valuesExpr.GetValue(columnName)); } sink.Inserted(row, scope.Env); } scope.Env.RowCount = selectedRows.Rows.Count; return(new EngineResult(selectedRows.Rows.Count)); }
public static void Evaluate(MergeAction action, Table targetTable, Row row, IOutputSink sink, Scope scope) { Row GetTargetRow() => row.Sources[EquatableArray.Of(scope.ExpandTableName(new[] { targetTable.Name }))]; switch (action) { case InsertMergeAction insert: Evaluate(targetTable, insert.Columns, insert.Source, new RowArgument(row), sink, scope); return; case UpdateMergeAction update: Evaluate(update.SetClauses, GetTargetRow(), row, sink, scope); return; case DeleteMergeAction _: var r = GetTargetRow(); sink.Deleted(r, scope.Env); targetTable.Rows.Remove(r); return; default: throw FeatureNotSupportedException.Subtype(action); } }
public Seeder(ISeedBucketInfoBuilder <Type> seedBucketInfoBuilder, IOutputSink outputSink) { this.seedBucketInfoBuilder = seedBucketInfoBuilder; this.outputSink = outputSink; }
public FirstStartup(IOutputSink output) // TODO: Validation: can only be parameterless or have IOutputSink as parameter. { this.output = output; }
public InfoSubcommand(SeedBucket seedBucket, IOutputSink output, ITextColorsProvider textColorsProvider) : base(output) { this.seedBucket = seedBucket; textColors = textColorsProvider.GetTextColors(); }
public SevereMessagesOutputSink(IOutputSink outputSink) { _outputSink = outputSink; _severeMessages = new List <Tuple <LogLevel, string> >(); }
public NewSubcommand(IOutputSink output) : base(output) { }
public Runtime(IOutputSink outputSink, IEnumerable <string> commands, IEnumerable <string> commandGroups, bool filter, string computerName) : this(outputSink, commands, commandGroups, filter, computerName, "", "") { }
public SampleStartupForUnitTests(IOutputSink output) // TODO: Validation: can only be parameterless or have IOutputSink as parameter. { this.output = output; }
public void AddOutputSink(IOutputSink sink) => OutputSinks.Add(sink);
public InfoSubcommand(IOutputSink output) : base(output) { }
public static EngineResult Evaluate(MergeSpecification merge, IOutputSink sink, Scope scope) { var(targetTable, scope2) = Evaluate(merge.Target, null, scope); scope = merge.TableAlias == null ? scope2 : scope2.PushAlias( merge.TableAlias.Value, scope.ExpandTableName( ((NamedTableReference)merge.Target).SchemaObject.Identifiers .Select(x => x.Value) .ToArray())); var(sourceTable, scope3) = Evaluate(merge.TableReference, null, scope); scope = scope3; var rowCount = 0; var matched = new List <Row>(); var notMatchedByTarget = new List <Row>(); var notMatchedBySource = new List <Row>(); var matchedClauses = merge.ActionClauses .Where(x => x.Condition == MergeCondition.Matched) .ToList(); var notMatchedByTargetClauses = merge.ActionClauses .Where(x => x.Condition == MergeCondition.NotMatchedByTarget || x.Condition == MergeCondition.NotMatched) .ToList(); var notMatchedBySourceClauses = merge.ActionClauses .Where(x => x.Condition == MergeCondition.NotMatchedBySource) .ToList(); if (matchedClauses.Any() || notMatchedByTargetClauses.Any()) { foreach (var s in sourceTable.Rows) { var rows = targetTable.Rows .Select(t => InnerRow(sourceTable, s, targetTable, t, scope)) .Where(row => Evaluate( merge.SearchCondition, new RowArgument(row), scope)) .ToList(); if (matchedClauses.Any() && rows.Any()) { matched.AddRange(rows); } else if (notMatchedByTargetClauses.Any()) { notMatchedByTarget.Add(LeftRow(sourceTable, s, targetTable, scope)); } } } if (notMatchedBySourceClauses.Any()) { foreach (var t in targetTable.Rows) { var isMatched = sourceTable.Rows.Any(s => Evaluate( merge.SearchCondition, new RowArgument(InnerRow(sourceTable, s, targetTable, t, scope)), scope)); if (!isMatched) { notMatchedBySource.Add(RightRow(sourceTable, targetTable, t, scope)); } } } // TODO: what order should merge actions be applied? foreach (var clause in matchedClauses) { foreach (var row in matched) { if (clause.SearchCondition == null || Evaluate(clause.SearchCondition, new RowArgument(row), scope)) { rowCount++; Evaluate(clause.Action, targetTable, row, sink, scope); } } } foreach (var clause in notMatchedByTargetClauses) { foreach (var row in notMatchedByTarget) { if (clause.SearchCondition == null || Evaluate(clause.SearchCondition, new RowArgument(row), scope)) { rowCount++; Evaluate(clause.Action, targetTable, row, sink, scope); } } } foreach (var clause in notMatchedBySourceClauses) { foreach (var row in notMatchedBySource) { if (Evaluate(clause.SearchCondition, new RowArgument(row), scope)) { rowCount++; Evaluate(clause.Action, targetTable, row, sink, scope); } } } scope.Env.RowCount = rowCount; return(new EngineResult(rowCount)); }
public static Task Seeds <TSeed1, TSeed2>(SeedBucketStartup seedBucketStartup, IOutputSink outputSink) where TSeed1 : ISeed where TSeed2 : ISeed { return(SeedSeeds(null, seedBucketStartup, outputSink, typeof(TSeed1), typeof(TSeed2))); }
public IntCodeComputer(IInputProvider inputProvider, IOutputSink outputSink) { _inputProvider = inputProvider; _outputSink = outputSink; }
protected BaseCommand(IOutputSink output) { Output = output; Filter = string.Empty; }
public static void Evaluate(IList <SetClause> clauses, Row targetRow, Row sourceRow, IOutputSink sink, Scope scope) { var originalTargetRow = targetRow.Copy(); foreach (var clause in clauses) { switch (clause) { case AssignmentSetClause set: var columnName = set.Column.MultiPartIdentifier.Identifiers.Last().Value; targetRow.Values[targetRow.GetColumnOrdinal(columnName)] = Evaluate( set.AssignmentKind, sourceRow.Values[sourceRow.GetColumnOrdinal(columnName)], Evaluate(set.NewValue, new RowArgument(sourceRow), scope)); break; default: throw FeatureNotSupportedException.Subtype(clause); } } sink.Updated(originalTargetRow, targetRow, scope.Env); }
/// <summary> /// TODO. /// </summary> /// <param name="output">TODO. TODO.</param> /// <param name="filter">TODO. TODO. TODO.</param> /// <returns>A <see cref="Task{TResult}"/> representing the result of the asynchronous operation.</returns> public Task Seed(IOutputSink output, ISeedableFilter?filter = null) // TODO: Think of dependency injection of the engine in generall and especially for IOutputSink. { return(new Seeder(seedBucketInfoBuilder, output).SeedSeedBucket(GetType(), filter)); }
protected BaseCommand(IOutputSink output) { Output = output; }