internal AssignmentStatement(ContextScope scope, Lexer lexer) : base(scope, lexer) { // VARIABLE = EXPR; // VARIABLE += EXPR; // VARIABLE -= EXPR; // VARIABLE *= EXPR; // VARIABLE /= EXPR; // VARIABLE %= EXPR; // VARIABLE &= EXPR; // VARIABLE |= EXPR; // TO DO: VARIABLE++/--; // or // EXPR; _scope = scope; switch (lexer.TokenType) { case TokenEnum.VARIABLE: { if (Parser.TypeTokens[lexer.TokenContents] != null) { DeclVariable d = new DeclVariable(scope, lexer); _varExpr = d; _varName = d.varName; } else { _varName = lexer.TokenContents; _varExpr = new IndexedExpression(scope, lexer).Get(); } _assigntype = lexer.TokenType; if (_assigntype == TokenEnum.ASSIGN || _assigntype == TokenEnum.PLUSASSIGN || _assigntype == TokenEnum.MINUSASSIGN || _assigntype == TokenEnum.ASTERISKASSIGN || _assigntype == TokenEnum.SLASHASSIGN || _assigntype == TokenEnum.PERCENTASSIGN || _assigntype == TokenEnum.AMPASSIGN || _assigntype == TokenEnum.PIPEASSIGN ) { lexer.Next(); //ASSIGN _value = new Expression(scope, lexer).Get(); } else { _assigntype = TokenEnum.NOTHING; } } break; default: { _assigntype = TokenEnum.NOTHING; _value = new Expression(scope, lexer).Get(); } break; } }
protected void setup() { Host = new InMemoryHost(startup: new StartupProperties { OpenRasta = { Errors = { HandleAllExceptions = false, HandleCatastrophicExceptions = false } } }); Pipeline = null; _actions = new Dictionary <Type, Func <ICommunicationContext, Task <PipelineContinuation> > >(); var manager = Host.HostManager; Resolver.AddDependencyInstance(typeof(IErrorCollector), Errors = new TestErrorCollector()); Resolver.AddDependency <IPathManager, PathManager>(); _ambientContext = new ContextScope(new AmbientContext()); _requestScope = Resolver.CreateRequestScope(); manager.SetupCommunicationContext(Context = new WriteTrackingResponseCommunicationContext(InnerContext = new InMemoryCommunicationContext())); }
/// <summary> /// Execute all the work that was 'scheduled' by the tasks running on this runner. /// </summary> public void Execute() { if (this.isDisposed) { throw new ObjectDisposedException(nameof(LocalTaskRunner)); } try { // Execute all the work that was scheduled on this runner. using (var contextScope = ContextScope.WithContext(this.context)) { this.context.Execute(); } } finally { // Remove any tasks that are now finished. lock (this.runningTasksLock) { for (int i = this.runningTasks.Count - 1; i >= 0; i--) { if (this.runningTasks[i].IsCompleted) { this.runningTasks.RemoveAt(i); } } } } }
internal Function(ContextScope scope, Lexer lexer) : base(scope, lexer) { // FUNCNAME ( PARAM , PARAM , PARAM , ...) // ^ // or FUNCNAME() _funcName = lexer.TokenContents; lexer.Next(); //FUNCTION if (lexer.TokenType != TokenEnum.BRACKETOPEN) { throw new ParseException(lexer, TokenEnum.BRACKETOPEN); } lexer.Next(); //BRACKETOPEN while (lexer.TokenType != TokenEnum.BRACKETCLOSE) { _param.Add(new Expression(scope, lexer).Get()); while (lexer.TokenType == TokenEnum.COMMA) { lexer.Next(); //COMMA _param.Add(new Expression(scope, lexer).Get()); } } lexer.Next(); //BRACKETCLOSE }
public void ContextScope_Description_ReturnsParentDescription() { MockScope parent = new MockScope("special-desc"); ContextScope contextScope = new ContextScope(parent, ValueTypeEnum.DateTime, true); Assert.AreEqual("special-desc", contextScope.Description); }
internal ParenthesizedExpression(ContextScope scope, Lexer lexer) : base(scope, lexer) { // ( TERN_EXPR ) // ^ bool parens = false; if (lexer.TokenType == TokenEnum.BRACKETOPEN) { parens = true; _scope = scope.Next; lexer.Next(); // BRACKETOPEN } else { _scope = scope; } _expression = new Expression(_scope, lexer).Get(); if (parens) { if (lexer.TokenType != TokenEnum.BRACKETCLOSE) { throw new ParseException(lexer, TokenEnum.BRACKETCLOSE); } else { lexer.Next(); // BRACKETCLOSE } } }
public MemoryContext() : base(new DbContextOptionsBuilder <MemoryContext>().UseInMemoryDatabase(Guid.NewGuid().ToString()).Options) { ContextScope = new ContextScope(); ContextScope.StateActions.Add(EntityState.Added, SetCreatedAuditFields); ContextScope.StateActions.Add(EntityState.Modified, SetModifiedAuditFields); }
public ContextScope CreateContextScope(CGFParserReporterContext.Type contextType, String filePath) { CGFParserReporterContext reporterContext = CGFParserReporterContext.CreateContext(contextType, filePath); ContextScope contextScope = new ContextScope(this, reporterContext); return(contextScope); }
public void ContextScope_Constructor_PopulatesParentTypeContextAndIsRequired() { MockScope parent = new MockScope(); ContextScope contextScope = new ContextScope(parent, ValueTypeEnum.DateTime, true); Assert.AreEqual(parent, contextScope.Parent); Assert.AreEqual(ValueTypeEnum.DateTime, contextScope.TypeContext); Assert.IsTrue(contextScope.IsRequired); }
public void In(FlowEventArgs e) { SetValue(nameof(ValueName)); SetValue(nameof(Value)); if (ValueName != null) { ContextScope.SetValue(ValueName, Value); } }
public static ContextLogger FromCallStack(ContextScope scope = ContextScope.Namespace, ILogger logger = null) { var stackTrace = new StackTrace(); var stackFrame = stackTrace.GetFrame(1); var method = stackFrame.GetMethod(); return(FromScope(GetScope(scope, method), logger)); }
internal RootStatement(ContextScope scope, Lexer lexer) : base(scope, lexer) { // STATEMENT STATEMENT ... while (!lexer.EndOfStream) { Statements.Add(new Statement(scope, lexer).Get()); } }
internal PrimaryExpression(ContextScope scope, Lexer lexer) : base(scope, lexer) { TokenEnum t = lexer.TokenType; switch (t) { case TokenEnum.BRACKETOPEN: _child = new ParenthesizedExpression(scope, lexer).Get(); break; case TokenEnum.FUNCTION: _child = new Function(scope, lexer).Get(); break; case TokenEnum.VARIABLE: _child = new Variable(scope, lexer).Get(); break; case TokenEnum.NEW: _child = new NewObjectExpression(scope, lexer).Get(); break; //Literals case TokenEnum.NULLLITERAL: _child = new NullLiteral(scope, lexer).Get(); break; case TokenEnum.BOOLEANLITERAL: _child = new BoolLiteral(scope, lexer).Get(); break; case TokenEnum.DECIMALINTEGERLITERAL: _child = new IntLiteral(scope, lexer).Get(); break; case TokenEnum.HEXINTEGERLITERAL: _child = new HexLiteral(scope, lexer).Get(); break; case TokenEnum.REALLITERAL: _child = new SingleLiteral(scope, lexer).Get(); break; case TokenEnum.STRINGLITERAL: _child = new StringLiteral(scope, lexer).Get(); break; case TokenEnum.BRACEOPEN: _child = new ArrayLiteral(scope, lexer).Get(); break; default: throw new ParseException(lexer); } }
internal ForStatement(ContextScope scope, Lexer lexer) : base(scope, lexer) { // FOR ( STATEMENT; CONDEXPR; EXPR ) STATEMENT // FOR ( STATEMENT; CONDEXPR; EXPR ) { STATEMENT STATEMENT STATEMENT ... } // or // ASSIGNMENTEXPR if (lexer.TokenType == TokenEnum.FOR) { lexer.Next(); //FOR if (lexer.TokenType != TokenEnum.BRACKETOPEN) { throw new ParseException(lexer, TokenEnum.BRACKETOPEN); } lexer.Next(); //BRACKETOPEN _scope = scope.Next; _begin = new Statement(_scope, lexer).Get(); _condition = new Expression(_scope, lexer).Get(); if (lexer.TokenType != TokenEnum.SEMICOLON) { throw new ParseException(lexer, TokenEnum.SEMICOLON); } lexer.Next(); //SEMICOLON _next = new AssignmentStatement(_scope, lexer).Get(); if (lexer.TokenType != TokenEnum.BRACKETCLOSE) { throw new ParseException(lexer, TokenEnum.BRACKETCLOSE); } lexer.Next(); //BRACKETCLOSE if (lexer.TokenType == TokenEnum.BRACEOPEN) { lexer.Next(); //BRACEOPEN while (lexer.TokenType != TokenEnum.BRACECLOSE) { _actions.Add(new Statement(_scope, lexer).Get()); } lexer.Next(); //BRACECLOSE } else { _actions.Add(new Statement(scope, lexer).Get()); } } else { _actions.Add(GetNext(scope, lexer)); } }
public void SetsCurrentScope() { ActiveRecordConfiguration.Configure(c => { c.ConnectionStringIs("foo"); //c.MapTypes(typeof(Customer)); }); using(var scope = new ContextScope()) { ContextScope.Current.ShouldBeTheSameAs(scope); } }
public void SetsCurrentScope() { ActiveRecordConfiguration.Configure(c => { c.ConnectionStringIs("foo"); //c.MapTypes(typeof(Customer)); }); using (var scope = new ContextScope()) { ContextScope.Current.ShouldBeTheSameAs(scope); } }
public void UsesAlternativeScopeStorage() { ActiveRecordConfiguration.Configure(c => { c.ConnectionStringIs("foo"); //c.MapTypes(typeof(Customer)); c.ScopeStorage(new TestScopeStorage()); }); using (var scope = new ContextScope()) { TestScopeStorage.Scope.ShouldBeTheSameAs(scope); } }
internal ForEachStatement(ContextScope scope, Lexer lexer) : base(scope, lexer) { // FOREACH ( DECL VAR IN EXPR ) STATEMENT // FOREACH ( DECL VAR IN EXPR ) { STATEMENT STATEMENT STATEMENT ... } // or // ASSIGNMENTEXPR if (lexer.TokenType == TokenEnum.FOREACH) { lexer.Next(); //FOREACH if (lexer.TokenType != TokenEnum.BRACKETOPEN) { throw new ParseException(lexer, TokenEnum.BRACKETOPEN); } lexer.Next(); //BRACKETOPEN _scope = scope.Next; _var = new DeclVariable(_scope, lexer); if (lexer.TokenType != TokenEnum.IN) { throw new ParseException(lexer, TokenEnum.IN); } lexer.Next(); //IN _enumerable = new Expression(_scope, lexer).Get(); if (lexer.TokenType != TokenEnum.BRACKETCLOSE) { throw new ParseException(lexer, TokenEnum.BRACKETCLOSE); } lexer.Next(); //BRACKETCLOSE if (lexer.TokenType == TokenEnum.BRACEOPEN) { lexer.Next(); //BRACEOPEN while (lexer.TokenType != TokenEnum.BRACECLOSE) { _actions.Add(new Statement(_scope, lexer).Get()); } lexer.Next(); //BRACECLOSE } else { _actions.Add(new Statement(scope, lexer).Get()); } } else { _actions.Add(GetNext(scope, lexer)); } }
internal LogicalAndExpression(ContextScope scope, Lexer lexer) : base(scope, lexer) { // EQUALEXPR && EQUALEXPR ... _first = GetNext(scope, lexer); while (lexer.TokenType == TokenEnum.AMPAMP // && ) { lexer.Next(); //AMPAMP _set.Add(GetNext(scope, lexer)); } }
internal LogicalOrExpression(ContextScope scope, Lexer lexer) : base(scope, lexer) { // ANDEXPR || ANDEXPR ... _first = GetNext(scope, lexer); while (lexer.TokenType == TokenEnum.PIPEPIPE // || ) { lexer.Next(); //PIPEPIPE _set.Add(GetNext(scope, lexer)); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (ContextScope != null) { ContextScope.Dispose(); } } ContextScope = null; ParentContext = null; }
internal SingleStatement(ContextScope scope, Lexer lexer) : base(scope, lexer) { _statement = GetNext(scope, lexer); if (lexer.TokenType == TokenEnum.SEMICOLON) { lexer.Next(); // SEMICOLON } else { throw new ParseException(lexer, TokenEnum.SEMICOLON); } }
internal IndexedExpression(ContextScope scope, Lexer lexer) : base(scope, lexer) { // EXPR[EXPR,...][EXPR,...]... // ^ // Multi-dimensional array example: // float[,][,] f = new float[1, 1][,]; // f[0, 0][1, 2] = 1; _expression = GetNext(scope, lexer); if (lexer.TokenType != TokenEnum.SQBRACKETOPEN) { return; } // indexer if (lexer.TokenType == TokenEnum.SQBRACKETOPEN) { List <CExpression[]> indexlist = new List <CExpression[]>(); while (lexer.TokenType == TokenEnum.SQBRACKETOPEN) { lexer.Next(); // SQBRACKETOPEN List <CExpression> innerlist = new List <CExpression> { new Expression(scope, lexer).Get() }; while (lexer.TokenType == TokenEnum.COMMA) { lexer.Next(); // COMMA innerlist.Add(new Expression(scope, lexer).Get()); } indexlist.Add(innerlist.ToArray()); if (lexer.TokenType != TokenEnum.SQBRACKETCLOSE) { throw new ParseException(lexer, TokenEnum.SQBRACKETCLOSE); } lexer.Next(); // SQBRACKETCLOSE } _indices_expr = indexlist.ToArray(); _indices = new int[_indices_expr.Length][]; for (int i = 0; i < _indices_expr.Length; i++) { _indices[i] = new int[_indices_expr[i].Length]; } } }
public void CleansUpScope() { ActiveRecordConfiguration.Configure(c => { c.ConnectionStringIs("foo"); //c.MapTypes(typeof(Customer)); c.ScopeStorage(new TestScopeStorage()); }); using (var scope = new ContextScope()) { TestScopeStorage.Scope.ShouldBeTheSameAs(scope); } TestScopeStorage.Scope.ShouldBeNull(); }
public void FindsCustomerById() { using (var scope = new ContextScope()) { var cmd = CreateCommand(); cmd.CommandText = "insert into Customer (Name) values ('Jeremy')"; cmd.ExecuteNonQuery(); var cmd2 = CreateCommand(); cmd2.CommandText = "select @@identity"; var id = Convert.ToInt32(cmd2.ExecuteScalar()); var cust = Customer.FindById(id); cust.ShouldNotBeNull(); } }
internal AddExpression(ContextScope scope, Lexer lexer) : base(scope, lexer) { // MULTIEXPR + MULTIEXPR ... // MULTIEXPR - MULTIEXPR ... _first = GetNext(scope, lexer); while (lexer.TokenType == TokenEnum.PLUS || // + lexer.TokenType == TokenEnum.MINUS // - ) { TokenEnum _type = lexer.TokenType; lexer.Next(); //PLUS / MINUS _set.Add(GetNext(scope, lexer), _type); } }
internal Statement(ContextScope scope, Lexer lexer) : base(scope, lexer) { // IFTHENELSE if (lexer.TokenType != TokenEnum.NOTHING && lexer.TokenType != TokenEnum.COMMENT) { _statement = GetNext(scope, lexer); // comment (eliminated by lexer) //if (lexer.TokenType == TokenEnum.COMMENT) // lexer.Next(); } else { lexer.Next(); } }
private void InitScope(Action <IScope> scopeInit) { if (ParentContext != null && ParentContext.Scope != null) { ContextScope = ParentContext.Scope.OpenScope(ContextName); Action <IScope> configure = Configure; if (scopeInit != null) { configure = (Action <IScope>)Delegate.Combine(configure, scopeInit); } configure(ContextScope); ContextScope.Unregister <IContext>(); ContextScope.RegisterInstance <IContext>(this); ContextScope = ContextScope.AsReadOnly(); } }
internal MultiplyExpression(ContextScope scope, Lexer lexer) : base(scope, lexer) { // UNARYEXPR * UNARYEXPR ... // UNARYEXPR / UNARYEXPR ... // UNARYEXPR % UNARYEXPR ... _first = GetNext(scope, lexer); while (lexer.TokenType == TokenEnum.ASTERISK || // * lexer.TokenType == TokenEnum.SLASH || // / lexer.TokenType == TokenEnum.PERCENT // % ) { TokenEnum _type = lexer.TokenType; lexer.Next(); //ASTERISK / SLASH / PERCENT _set.Add(GetNext(scope, lexer), _type); } }
internal WhileStatement(ContextScope scope, Lexer lexer) : base(scope, lexer) { // WHILE ( EXPR ) STATEMENT // WHILE ( EXPR ) { STATEMENT STATEMENT STATEMENT ... } // or // if (lexer.TokenType == TokenEnum.WHILE) { lexer.Next(); //WHILE if (lexer.TokenType != TokenEnum.BRACKETOPEN) { throw new ParseException(lexer, TokenEnum.BRACKETOPEN); } lexer.Next(); //BRACKETOPEN _condition = new Expression(scope, lexer).Get(); if (lexer.TokenType != TokenEnum.BRACKETCLOSE) { throw new ParseException(lexer, TokenEnum.BRACKETCLOSE); } lexer.Next(); //BRACKETCLOSE if (lexer.TokenType == TokenEnum.BRACEOPEN) { lexer.Next(); //BRACEOPEN while (lexer.TokenType != TokenEnum.BRACECLOSE) { _actions.Add(new Statement(scope, lexer).Get()); } lexer.Next(); //BRACECLOSE } else { _actions.Add(new Statement(scope, lexer).Get()); } } else { _actions.Add(GetNext(scope, lexer)); } }
private static string GetScope(ContextScope scope, MethodBase method) { var stringBuilder = new StringBuilder(); var declaringType = method.DeclaringType; switch (scope) { case ContextScope.Type: return(declaringType.Name); case ContextScope.Namespace: return(declaringType.Namespace); case ContextScope.NamespaceWithType: return(declaringType.ToString()); default: throw new NotSupportedException($"{scope}"); } }
/// <inheritdoc cref="ITaskRunner.StartTask(Func{CancellationToken, Task})"/> /// <param name="logger">Optional logger to output diagnostic messages to.</param> public Task StartTask( Func <CancellationToken, Task> taskCreator, IDiagnosticLogger logger) { if (taskCreator is null) { throw new ArgumentNullException(nameof(taskCreator)); } if (this.isDisposed) { throw new ObjectDisposedException(nameof(LocalTaskRunner)); } // Activate our context and wrap the task. using (var contextScope = ContextScope.WithContext(this.context)) { var diagTracer = logger is null ? null : DiagTaskTracer.Create(logger, taskCreator); diagTracer?.LogInvoked(); return(this.WrapTask(taskCreator.Invoke(this.cancelSource.Token), diagTracer)); } }
public UnitOfWork() { _scope = new ContextScope(); Instances().Push(this); }
public DefaultContextualStorageFactory(ContextScope contextScope) { this.contextScope = contextScope; }
WorkflowCompilationContext(ContextScope scope) { this.scope = scope; }
public override Node VisitQueryDelete(QueryDelete delete){ if (delete == null) return null; delete.Source = this.VisitExpression(delete.Source); if (delete.Source == null || delete.Source.Type == null) return delete; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(delete.Source, this.TypeViewer); delete.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType); delete.Target = this.VisitExpression(delete.Target); this.contextScope = this.contextScope.Previous; delete.Type = SystemTypes.Int32; return delete; }
/// <summary> /// Initializes a new instance of the ContextWrapperDependencyResolution class. /// </summary> /// <param name="contextScope"> The context scope being requested. </param> /// <param name="innerDependencyResolution"> The chained dependency resolution which is called only once. </param> public ContextWrapperDependencyResolution(ContextScope contextScope, IDependencyResolution innerDependencyResolution) : this(new DefaultContextualStorageFactory(contextScope).GetContextualStorage(), innerDependencyResolution) { }
public override Node VisitQueryUpdate( QueryUpdate update ){ if (update == null) return null; update.Source = this.VisitExpression(update.Source); if (update.Source == null || update.Source.Type == null) return update; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(update.Source, this.TypeViewer); update.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType); update.UpdateList = this.VisitExpressionList(update.UpdateList); this.contextScope = this.contextScope.Previous; update.Type = SystemTypes.Int32; return update; }
public override Node VisitQueryFilter(QueryFilter filter){ if (filter == null) return null; filter.Source = this.VisitExpression(filter.Source); if (filter.Source == null || filter.Source.Type == null) return filter; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(filter.Source, this.TypeViewer); if (sourceElementType != null){ filter.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType); filter.Expression = this.VisitExpression(filter.Expression); this.contextScope = this.contextScope.Previous; if (filter.Expression != null && filter.Expression.Type != null){ filter.Type = this.GetResultType(filter.Source, null, Cardinality.ZeroOrOne); } } return filter; }
public override Node VisitQueryProject(QueryProject project){ if (project == null) return null; project.Source = this.VisitExpression(project.Source); if (project.Source == null || project.Source.Type == null) return project; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(project.Source, this.TypeViewer); project.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType); ExpressionList list = new ExpressionList(); for (int i=0; i < project.ProjectionList.Count; i++){ QueryAxis axis = project.ProjectionList[i] as QueryAxis; if (axis != null && axis.Name == Identifier.Empty){ axis.Source = this.VisitExpression(axis.Source); this.ResolveAxis(axis); this.GetProjectionList(axis.AccessPlan, axis.Source, list); } else{ list.Add(this.VisitExpression(project.ProjectionList[i])); } } project.ProjectionList = list; this.contextScope = this.contextScope.Previous; if (project.ProjectedType == null){ int len = project.ProjectionList.Count; if (len == 1 && this.GetExpressionName(project.ProjectionList[0]) == null){ Expression x = project.ProjectionList[0]; if (x != null && x.Type != null) project.ProjectedType = x.Type; } else{ FieldList fields = new FieldList(); for( int i = 0, cn = 0; i < len; i++ ){ Expression x = project.ProjectionList[i]; if (x != null && x.Type != null){ Identifier name = this.GetExpressionName(x); Field f = new Field(null, new AttributeList(1), FieldFlags.Public, name, x.Type, null); if (name == null || name == Identifier.Empty){ f.Name = Identifier.For("Item"+cn); cn++; f.Attributes.Add(new AttributeNode(new MemberBinding(null, SystemTypes.AnonymousAttribute.GetConstructor()), null)); } fields.Add(f); } } if (fields.Count == len){ project.ProjectedType = TupleType.For(fields, this.currentType); project.Members = this.typeSystem.GetDataMembers(project.ProjectedType); } } } if (project.ProjectedType != null){ project.Type = this.GetResultType(project.Source, project.ProjectedType, Cardinality.One); } return project; }
public override Node VisitQueryOrderBy(QueryOrderBy orderby){ if (orderby == null) return null; orderby.Source = this.VisitExpression(orderby.Source); if (orderby.Source == null || orderby.Source.Type == null) return orderby; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(orderby.Source, this.TypeViewer); orderby.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType); orderby.OrderList = this.VisitExpressionList(orderby.OrderList); this.contextScope = this.contextScope.Previous; orderby.Type = this.GetResultType(orderby.Source, null, Cardinality.One); return orderby; }
public override Node VisitQueryJoin(QueryJoin join){ if (join == null) return null; join.LeftOperand = this.VisitExpression(join.LeftOperand); join.RightOperand = this.VisitExpression(join.RightOperand); TypeNode leftType = this.typeSystem.GetStreamElementType(join.LeftOperand, this.TypeViewer); TypeNode rightType = this.typeSystem.GetStreamElementType(join.RightOperand, this.TypeViewer); if (join.LeftOperand != null && leftType != null && join.RightOperand != null && rightType != null){ if (join.JoinType == QueryJoinType.RightOuter || join.JoinType == QueryJoinType.FullOuter){ leftType = SystemTypes.GenericBoxed.GetTemplateInstance(this.currentType, leftType); } if (join.JoinType == QueryJoinType.LeftOuter || join.JoinType == QueryJoinType.FullOuter){ rightType = SystemTypes.GenericBoxed.GetTemplateInstance(this.currentType, rightType); } Field leftField = this.NewField(Identifier.For("Item0"), leftType, Anonymity.Full); Field rightField = this.NewField(Identifier.For("Item1"), rightType, Anonymity.Full); TypeNode joinedType = TupleType.For(new FieldList(leftField, rightField), this.currentType); if (join.JoinExpression != null){ join.JoinContext = this.contextScope = new ContextScope(this.contextScope, joinedType); join.JoinExpression = this.VisitExpression(join.JoinExpression); this.contextScope = this.contextScope.Previous; } join.Type = SystemTypes.GenericIEnumerable.GetTemplateInstance(this.currentType, joinedType); } return join; }
public override Node VisitQueryInsert(QueryInsert insert){ if (insert == null) return null; insert.Location = this.VisitExpression(insert.Location); if (insert.Location == null || insert.Location.Type == null) return insert; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(insert.Location, this.TypeViewer); insert.Context = this.contextScope = new ContextScope(this.contextScope, sourceElementType); this.VisitExpressionList(insert.InsertList); this.contextScope = this.contextScope.Previous; insert.Type = SystemTypes.Int32; insert.HintList = this.VisitExpressionList(insert.HintList); return insert; }
public override Node VisitQueryGroupBy(QueryGroupBy groupby){ if (groupby == null) return null; groupby.Source = this.VisitExpression(groupby.Source); if (groupby.Source == null || groupby.Source.Type == null) return groupby; TypeNode sourceElementType = this.typeSystem.GetStreamElementType(groupby.Source, this.TypeViewer); groupby.GroupContext = this.contextScope = new ContextScope(this.contextScope, sourceElementType); groupby.GroupList = this.VisitExpressionList(groupby.GroupList); this.contextScope = this.contextScope.Previous; // create result type FieldList fields = new FieldList(); int cn = 0; for (int i = 0, n = groupby.GroupList.Count; i < n; i++){ Expression x = groupby.GroupList[i]; if (x != null && x.Type != null){ Identifier name = this.GetExpressionName(x); Field f = new Field(null, new AttributeList(1), FieldFlags.Public, name, x.Type, null); if (name == null || name == Identifier.Empty){ f.Name = Identifier.For("Item"+cn); cn++; f.Attributes.Add(new AttributeNode(new MemberBinding(null, SystemTypes.AnonymousAttribute.GetConstructor()), null)); } fields.Add(f); } } for (int i = 0, n = groupby.AggregateList.Count; i < n; i++){ QueryAggregate qa = groupby.AggregateList[i] as QueryAggregate; if (qa != null){ qa.Group = groupby; this.contextScope = groupby.GroupContext; TypeNode aggType = null; QueryDistinct qd = qa.Expression as QueryDistinct; if (qd != null){ qd.Group = groupby; qd.Source = this.VisitExpression(qd.Source); if (qd.Source == null) continue; qd.Type = this.GetResultType(qd.Source, null, Cardinality.ZeroOrMore); aggType = this.GetAggregateSubType(qa.AggregateType, this.typeSystem.GetStreamElementType(qd.Source, this.TypeViewer)); } else{ qa.Expression = this.VisitExpression(qa.Expression); if (qa.Expression == null) continue; aggType = this.GetAggregateSubType(qa.AggregateType, this.typeSystem.GetStreamElementType(qa.Expression, this.TypeViewer)); } this.contextScope = this.contextScope.Previous; if (aggType == null) continue; qa.AggregateType = aggType; Method mgetval = this.GetTypeView(aggType).GetMethod(StandardIds.GetValue); if (mgetval != null){ qa.Type = mgetval.ReturnType; } Identifier name = Identifier.For("Item"+cn); cn++; Field f = new Field(null, new AttributeList(1), FieldFlags.Public, name, qa.Type, null); f.Attributes.Add(new AttributeNode(new MemberBinding(null, SystemTypes.AnonymousAttribute.GetConstructor()), null)); fields.Add(f); } } if (fields.Count == groupby.GroupList.Count + groupby.AggregateList.Count){ TypeNode groupType = TupleType.For(fields, this.currentType); if (groupby.Having != null){ groupby.HavingContext = this.contextScope = new ContextScope(this.contextScope, groupType); groupby.Having = this.VisitExpression(groupby.Having); this.contextScope = this.contextScope.Previous; } groupby.Type = this.GetResultType(groupby.Source, groupType, Cardinality.One); } return groupby; }