public ITreeBuilder End() { ++noOfCommands; if (RequiresRootNode()) { SetErrorCode(BuilderError.REQUIRES_A_ROOT_NODE); return(this); } if (IsTreeInvalid()) { return(this); } if (mCallStack.Count <= 0) { SetErrorCode(BuilderError.STACK_UNDERFLOW); return(this); } mCallStack.Pop(); if (!ContainsItems()) { State = BuilderState.TREE_OK; mErrorCode = BuilderError.NO_ERROR; } //delete frame; return(this); }
public TreeBuilder () { mCallStack = new Stack<TreeBuilderFrame> (); noOfCommands = 0; mErrorCode = BuilderError.NO_ERROR; State = BuilderState.INVALID_TREE; mRoot = null; }
public TreeBuilder() { mCallStack = new Stack <TreeBuilderFrame> (); noOfCommands = 0; mErrorCode = BuilderError.NO_ERROR; State = BuilderState.INVALID_TREE; mRoot = null; }
public void FreezeReference(TableModel table, IEnumerable <TableModel> tables) { ReferenceTable = tables.FirstOrDefault(t => t.Property.Name == _referenceTable.Name); if (ReferenceTable == null) { throw BuilderError.SelectorNotMappedToTable(_referenceTable.Name, _referenceTable.DeclaringType.Name).AsException(); } ReferenceColumns = _referenceColumns.MatchColumns(ReferenceTable.Name, ReferenceTable.Columns).ToImmutableArray(); // If the name was not explicitly set then we generate one based on the table and column names if (Name == null) { Name = BuilderHelper.GenerateForeignKeyName(table.Schema, table.Name, KeyColumns.Select(c => c.Name), ReferenceTable.Schema, ReferenceTable.Name); } }
public SetQueryBase(QueryBase innerBuilder, Expression column, Expression value) { if (column == null) { throw BuilderError.ArgumentNull(nameof(column)).AsException(); } var columnSelector = ExpressionHelpers.ParseSelector(column as LambdaExpression); if (value == null) { throw BuilderError.ArgumentNull(nameof(value)).AsException(); } InnerQuery = innerBuilder; //Column = column; Value = value; }
public async Task VerifySourceErrorRaised(string source, BuilderError builderError, params string[] locations) { const string fileNamePrefix = "Source"; const string projectName = "Project"; var projectId = ProjectId.CreateNewId(debugName: projectName); var solution = new AdhocWorkspace() .CurrentSolution .AddProject(projectId, projectName, projectName, LanguageNames.CSharp) .AddMetadataReferences(projectId, _references); var newFileName = $"{fileNamePrefix}1.cs"; var documentId = DocumentId.CreateNewId(projectId, debugName: newFileName); solution = solution.AddDocument(documentId, newFileName, SourceText.From(source)); var project = solution.GetProject(projectId); var options = project.CompilationOptions .WithOutputKind(OutputKind.DynamicallyLinkedLibrary) as CSharpCompilationOptions; project = project.WithCompilationOptions(options); var errors = await GetCompilationErrors(await project.GetCompilationAsync()); Assert.Equal(1, errors.Length); var error = errors.First(); Assert.Equal(builderError.ErrorId, error.ErrorId); Assert.Equal(builderError.Message, error.ErrorText); if (error.Locations != null) { foreach (var pair in error.Locations.Zip(locations, (l, r) => (l, r))) { Assert.Equal(pair.Item2, pair.Item1); } } }
public GroupByQueryBase(QueryBase innerQuery, LambdaExpression keys) { InnerQuery = innerQuery; if (keys == null) { throw BuilderError.ArgumentNull(nameof(keys)).AsException(); } // Keys must be named if (keys.Body is NewExpression newExpression) { KeyColumns = newExpression.Members.Zip(newExpression.Arguments, (l, r) => (Left: l, Right: r)) .Select(p => (p.Left as PropertyInfo, p.Right)) .ToImmutableArray(); } else { throw QueryBuilderError.GroupByNotNewExpression().AsException(); } }
private void SetErrorCode(BuilderError error) { mErrorCode = error; }
public ITreeBuilder End() { ++noOfCommands; if (RequiresRootNode()) { SetErrorCode(BuilderError.REQUIRES_A_ROOT_NODE); return this; } if(IsTreeInvalid()) { return this; } if(mCallStack.Count <= 0) { SetErrorCode (BuilderError.STACK_UNDERFLOW); return this; } mCallStack.Pop(); if(!ContainsItems()) { State = BuilderState.TREE_OK; mErrorCode = BuilderError.NO_ERROR; } //delete frame; return this; }