コード例 #1
0
ファイル: TableContext.cs プロジェクト: resonancellc/nquery
        public override void Enumerate(IMemberCompletionAcceptor acceptor)
        {
            if (acceptor == null)
            {
                throw ExceptionBuilder.ArgumentNull("acceptor");
            }

            // Report all columns accessible by the table ref.

            TableRefBinding tableRefBinding = new TableRefBinding(null, _tableBinding, _correlationName);

            foreach (ColumnBinding columnBinding in _tableBinding.Columns)
            {
                ColumnRefBinding columnRefBinding = new ColumnRefBinding(tableRefBinding, columnBinding);
                acceptor.AcceptColumnRef(columnRefBinding);
            }

            // Now contribute any methods accessible by the row type.

            IMethodProvider methodProvider = _scope.DataContext.MetadataContext.MethodProviders[_tableBinding.RowType];

            if (methodProvider != null)
            {
                MethodBinding[] methods = methodProvider.GetMethods(_tableBinding.RowType);
                foreach (MethodBinding methodBinding in  methods)
                {
                    acceptor.AcceptMethod(methodBinding);
                }
            }
        }
コード例 #2
0
ファイル: TableContext.cs プロジェクト: chenzuo/nquery
		public override void Enumerate(IMemberCompletionAcceptor acceptor)
		{
			if (acceptor == null)
				throw ExceptionBuilder.ArgumentNull("acceptor");
			
			// Report all columns accessible by the table ref.
							
			TableRefBinding tableRefBinding = new TableRefBinding(null, _tableBinding, _correlationName);
			foreach (ColumnBinding columnBinding in _tableBinding.Columns)
			{
				ColumnRefBinding columnRefBinding = new ColumnRefBinding(tableRefBinding, columnBinding);
				acceptor.AcceptColumnRef(columnRefBinding);
			}
							
			// Now contribute any methods accessible by the row type.

			IMethodProvider methodProvider = _scope.DataContext.MetadataContext.MethodProviders[_tableBinding.RowType];
				
			if (methodProvider != null)
			{
				MethodBinding[] methods = methodProvider.GetMethods(_tableBinding.RowType);
				foreach (MethodBinding methodBinding in  methods)
					acceptor.AcceptMethod(methodBinding);
			}
		}
コード例 #3
0
		public override void Enumerate(IMemberCompletionAcceptor acceptor)
		{
			List<TableBinding> joinTargetList = new List<TableBinding>();

			TableRefBinding[] tableRefBindings = _queryScope.GetAllTableRefBindings();
			foreach (TableRefBinding tableRefBinding in tableRefBindings)
			{
				TableBinding joinSource = tableRefBinding.TableBinding;
				IList<TableRelation> tableRelations = _scope.DataContext.TableRelations.GetRelations(joinSource);
				
				foreach (TableRelation tableRelation in tableRelations)
				{
					TableBinding joinTarget;

					if (tableRelation.ParentTable == joinSource)
						joinTarget = tableRelation.ChildTable;
					else
						joinTarget = tableRelation.ParentTable;

					if (!joinTargetList.Contains(joinTarget))
						joinTargetList.Add(joinTarget);
				}
			}

			if (joinTargetList.Count > 0)
			{
				foreach (TableBinding joinTarget in joinTargetList)
					acceptor.AcceptTable(joinTarget);
			}
			else
			{
				foreach (TableBinding joinTarget in _scope.DataContext.Tables)
					acceptor.AcceptTable(joinTarget);
			}
		}
コード例 #4
0
        public override void Enumerate(IMemberCompletionAcceptor acceptor)
        {
            if (acceptor == null)
            {
                throw ExceptionBuilder.ArgumentNull("acceptor");
            }

            NamedConstantExpression namedConstantExpression = _expressionBeforeDot as NamedConstantExpression;
            ParameterExpression     parameterExpression     = _expressionBeforeDot as ParameterExpression;

            IList <PropertyBinding> properties = null;

            if (namedConstantExpression == null && parameterExpression == null)
            {
                // The properties must be provided by a regular property provider.

                IPropertyProvider propertyProvider = _scope.DataContext.MetadataContext.PropertyProviders[_expressionBeforeDot.ExpressionType];

                if (propertyProvider != null)
                {
                    properties = propertyProvider.GetProperties(_expressionBeforeDot.ExpressionType);
                }
            }
            else
            {
                // The expression before the dot is named constant or a parameter. In both cases, the properties
                // could be contributed as custom properties.

                if (namedConstantExpression != null)
                {
                    properties = namedConstantExpression.Constant.CustomProperties;
                }
                else
                {
                    properties = parameterExpression.Parameter.CustomProperties;
                }
            }

            if (properties != null)
            {
                foreach (PropertyBinding propertyBinding in properties)
                {
                    acceptor.AcceptProperty(propertyBinding);
                }
            }

            // Now contribute any methods

            IMethodProvider methodProvider = _scope.DataContext.MetadataContext.MethodProviders[_expressionBeforeDot.ExpressionType];

            if (methodProvider != null)
            {
                MethodBinding[] methods = methodProvider.GetMethods(_expressionBeforeDot.ExpressionType);
                foreach (MethodBinding methodBinding in  methods)
                {
                    acceptor.AcceptMethod(methodBinding);
                }
            }
        }
コード例 #5
0
ファイル: MemberContext.cs プロジェクト: chenzuo/nquery
		public override void Enumerate(IMemberCompletionAcceptor acceptor)
		{
			if (acceptor == null)
				throw ExceptionBuilder.ArgumentNull("acceptor");
			
			NamedConstantExpression namedConstantExpression = _expressionBeforeDot as NamedConstantExpression;
			ParameterExpression parameterExpression = _expressionBeforeDot as ParameterExpression;

			IList<PropertyBinding> properties = null;

			if (namedConstantExpression == null && parameterExpression == null)
			{
				// The properties must be provided by a regular property provider.

				IPropertyProvider propertyProvider = _scope.DataContext.MetadataContext.PropertyProviders[_expressionBeforeDot.ExpressionType];

				if (propertyProvider != null)
					properties = propertyProvider.GetProperties(_expressionBeforeDot.ExpressionType);
			}
			else
			{
				// The expression before the dot is named constant or a parameter. In both cases, the properties 
				// could be contributed as custom properties.

				if (namedConstantExpression != null)
					properties = namedConstantExpression.Constant.CustomProperties;
				else
					properties = parameterExpression.Parameter.CustomProperties;
			}

			if (properties != null)
				foreach (PropertyBinding propertyBinding in properties)
					acceptor.AcceptProperty(propertyBinding);
				
			// Now contribute any methods

			IMethodProvider methodProvider = _scope.DataContext.MetadataContext.MethodProviders[_expressionBeforeDot.ExpressionType];
				
			if (methodProvider != null)
			{
				MethodBinding[] methods = methodProvider.GetMethods(_expressionBeforeDot.ExpressionType);
				foreach (MethodBinding methodBinding in  methods)
					acceptor.AcceptMethod(methodBinding);
			}
		}
コード例 #6
0
        public override void Enumerate(IMemberCompletionAcceptor acceptor)
        {
            List <TableBinding> joinTargetList = new List <TableBinding>();

            TableRefBinding[] tableRefBindings = _queryScope.GetAllTableRefBindings();
            foreach (TableRefBinding tableRefBinding in tableRefBindings)
            {
                TableBinding          joinSource     = tableRefBinding.TableBinding;
                IList <TableRelation> tableRelations = _scope.DataContext.TableRelations.GetRelations(joinSource);

                foreach (TableRelation tableRelation in tableRelations)
                {
                    TableBinding joinTarget;

                    if (tableRelation.ParentTable == joinSource)
                    {
                        joinTarget = tableRelation.ChildTable;
                    }
                    else
                    {
                        joinTarget = tableRelation.ParentTable;
                    }

                    if (!joinTargetList.Contains(joinTarget))
                    {
                        joinTargetList.Add(joinTarget);
                    }
                }
            }

            if (joinTargetList.Count > 0)
            {
                foreach (TableBinding joinTarget in joinTargetList)
                {
                    acceptor.AcceptTable(joinTarget);
                }
            }
            else
            {
                foreach (TableBinding joinTarget in _scope.DataContext.Tables)
                {
                    acceptor.AcceptTable(joinTarget);
                }
            }
        }
コード例 #7
0
        public override void Enumerate(IMemberCompletionAcceptor acceptor)
        {
            List <TableRelationData> tableRelationDataList = new List <TableRelationData>();

            TableRefBinding[] tableRefBindings = _queryScope.GetAllTableRefBindings();
            Array.Reverse(tableRefBindings);

            foreach (TableRefBinding joinSourceTableRef in tableRefBindings)
            {
                TableBinding          joinSource     = joinSourceTableRef.TableBinding;
                IList <TableRelation> tableRelations = _scope.DataContext.TableRelations.GetRelations(joinSource);

                foreach (TableRelation tableRelation in tableRelations)
                {
                    TableBinding joinTarget;

                    if (tableRelation.ParentTable == joinSource)
                    {
                        joinTarget = tableRelation.ChildTable;
                    }
                    else
                    {
                        joinTarget = tableRelation.ParentTable;
                    }

                    foreach (TableRefBinding joinTargetTableRef in tableRefBindings)
                    {
                        if (joinTargetTableRef.TableBinding == joinTarget)
                        {
                            TableRelationData tableRelationData = new TableRelationData();
                            tableRelationData.Relation = tableRelation;
                            tableRelationData.Child    = joinTargetTableRef;
                            tableRelationData.Parent   = joinSourceTableRef;
                            tableRelationDataList.Add(tableRelationData);
                        }
                    }
                }
            }

            foreach (TableRelationData tableRelationData in tableRelationDataList)
            {
                acceptor.AcceptRelation(tableRelationData.Parent, tableRelationData.Child, tableRelationData.Relation);
            }
        }
コード例 #8
0
		public override void Enumerate(IMemberCompletionAcceptor acceptor)
		{
			List<TableRelationData> tableRelationDataList = new List<TableRelationData>();

			TableRefBinding[] tableRefBindings = _queryScope.GetAllTableRefBindings();
			Array.Reverse(tableRefBindings);

			foreach (TableRefBinding joinSourceTableRef in tableRefBindings)
			{
				TableBinding joinSource = joinSourceTableRef.TableBinding;
                IList<TableRelation> tableRelations = _scope.DataContext.TableRelations.GetRelations(joinSource);
				
				foreach (TableRelation tableRelation in tableRelations)
				{
					TableBinding joinTarget;

					if (tableRelation.ParentTable == joinSource)
						joinTarget = tableRelation.ChildTable;
					else
						joinTarget = tableRelation.ParentTable;

					foreach (TableRefBinding joinTargetTableRef in tableRefBindings)
					{
						if (joinTargetTableRef.TableBinding == joinTarget)
						{
							TableRelationData tableRelationData = new TableRelationData();
							tableRelationData.Relation = tableRelation;
							tableRelationData.Child = joinTargetTableRef;
							tableRelationData.Parent = joinSourceTableRef;
							tableRelationDataList.Add(tableRelationData);
						}
					}
				}
			}

			foreach (TableRelationData tableRelationData in tableRelationDataList)
				acceptor.AcceptRelation(tableRelationData.Parent, tableRelationData.Child, tableRelationData.Relation);
		}
コード例 #9
0
 public void Enumerate(IMemberCompletionAcceptor acceptor)
 {
 }
コード例 #10
0
		public void Enumerate(IMemberCompletionAcceptor acceptor)
		{
		}
コード例 #11
0
		public abstract void Enumerate(IMemberCompletionAcceptor acceptor);
コード例 #12
0
		public override void Enumerate(IMemberCompletionAcceptor acceptor)
		{
			if (acceptor == null)
				throw ExceptionBuilder.ArgumentNull("acceptor");
			
			// Enumerate the complete global scope
			//
			// 1.	Enumerate all table refs and column refs as they are part
			//		of the query scope.

			foreach (TableRefBinding tableRefBinding in _queryScope.GetAllTableRefBindings())
				acceptor.AcceptTableRef(tableRefBinding);

			foreach (ColumnRefBinding columnRefBinding in _queryScope.GetAllColumnRefBindings())
				acceptor.AcceptColumnRef(columnRefBinding);

			// 2. Enumerate all tables, constants, aggregates and functions

			foreach (TableBinding table in _scope.DataContext.Tables)
				acceptor.AcceptTable(table);

			foreach (ConstantBinding constant in _scope.DataContext.Constants)
				acceptor.AcceptConstant(constant);

			foreach (AggregateBinding aggregateBinding in _scope.DataContext.Aggregates)
				acceptor.AcceptAggregate(aggregateBinding);

			foreach (FunctionBinding functionBinding in _scope.DataContext.Functions)
				acceptor.AcceptFunction(functionBinding);

			// 3. Enumerate parameters
			
			foreach (ParameterBinding parameter in _scope.Parameters)
				acceptor.AcceptParameter(parameter);

			// 4. Enumerate keywords

			TokenId[] tokenIDs = (TokenId[]) Enum.GetValues(typeof (TokenId));

			foreach (TokenId tokenID in tokenIDs)
			{
				TokenInfo info = TokenInfo.FromTokenId(tokenID);

				if (info.IsKeyword)
					acceptor.AcceptKeyword(info.Text);
			}
			
			// 5. Enumerate relations
			
			TableRefBinding[] tableRefBindings = _queryScope.GetAllTableRefBindings();
			
			foreach (TableRefBinding parentTableRef in tableRefBindings)
			{
                IList<TableRelation> relations = _scope.DataContext.TableRelations.GetChildRelations(parentTableRef.TableBinding);
				
				foreach (TableRelation relation in relations)
				{
					TableBinding childTable = (relation.ParentTable == parentTableRef.TableBinding) ? relation.ChildTable : relation.ParentTable;
					TableRefBinding childTableRef = null;
					
					foreach (TableRefBinding tableRefBinding in tableRefBindings)
					{
						if (tableRefBinding.TableBinding == childTable)
						{
							childTableRef = tableRefBinding;
							break;
						}
					}
					
					if (childTableRef != null)
					{
						acceptor.AcceptRelation(parentTableRef, childTableRef, relation);
					}
				}
			}
		}
コード例 #13
0
 public abstract void Enumerate(IMemberCompletionAcceptor acceptor);
コード例 #14
0
        public override void Enumerate(IMemberCompletionAcceptor acceptor)
        {
            if (acceptor == null)
            {
                throw ExceptionBuilder.ArgumentNull("acceptor");
            }

            // Enumerate the complete global scope
            //
            // 1.	Enumerate all table refs and column refs as they are part
            //		of the query scope.

            foreach (TableRefBinding tableRefBinding in _queryScope.GetAllTableRefBindings())
            {
                acceptor.AcceptTableRef(tableRefBinding);
            }

            foreach (ColumnRefBinding columnRefBinding in _queryScope.GetAllColumnRefBindings())
            {
                acceptor.AcceptColumnRef(columnRefBinding);
            }

            // 2. Enumerate all tables, constants, aggregates and functions

            foreach (TableBinding table in _scope.DataContext.Tables)
            {
                acceptor.AcceptTable(table);
            }

            foreach (ConstantBinding constant in _scope.DataContext.Constants)
            {
                acceptor.AcceptConstant(constant);
            }

            foreach (AggregateBinding aggregateBinding in _scope.DataContext.Aggregates)
            {
                acceptor.AcceptAggregate(aggregateBinding);
            }

            foreach (FunctionBinding functionBinding in _scope.DataContext.Functions)
            {
                acceptor.AcceptFunction(functionBinding);
            }

            // 3. Enumerate parameters

            foreach (ParameterBinding parameter in _scope.Parameters)
            {
                acceptor.AcceptParameter(parameter);
            }

            // 4. Enumerate keywords

            TokenId[] tokenIDs = (TokenId[])Enum.GetValues(typeof(TokenId));

            foreach (TokenId tokenID in tokenIDs)
            {
                TokenInfo info = TokenInfo.FromTokenId(tokenID);

                if (info.IsKeyword)
                {
                    acceptor.AcceptKeyword(info.Text);
                }
            }

            // 5. Enumerate relations

            TableRefBinding[] tableRefBindings = _queryScope.GetAllTableRefBindings();

            foreach (TableRefBinding parentTableRef in tableRefBindings)
            {
                IList <TableRelation> relations = _scope.DataContext.TableRelations.GetChildRelations(parentTableRef.TableBinding);

                foreach (TableRelation relation in relations)
                {
                    TableBinding    childTable    = (relation.ParentTable == parentTableRef.TableBinding) ? relation.ChildTable : relation.ParentTable;
                    TableRefBinding childTableRef = null;

                    foreach (TableRefBinding tableRefBinding in tableRefBindings)
                    {
                        if (tableRefBinding.TableBinding == childTable)
                        {
                            childTableRef = tableRefBinding;
                            break;
                        }
                    }

                    if (childTableRef != null)
                    {
                        acceptor.AcceptRelation(parentTableRef, childTableRef, relation);
                    }
                }
            }
        }