示例#1
0
        public IEnumerable <Type> Scope(ISyntaxNode context, Type scopeType)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            List <Type> scope = new List <Type>();

            ScriptConcept script = context.Ancestor <ScriptConcept>() as ScriptConcept;

            if (script == null)
            {
                return(scope);
            }

            foreach (var statement in script.Statements)
            {
                if (!(statement is UseDatabaseConcept database))
                {
                    continue;
                }
                if (database.Assembly == null)
                {
                    continue;
                }
                foreach (Type type in database.Assembly.GetTypes()
                         .Where(t => t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(ReferenceObject))))
                {
                    scope.Add(type);
                }
            }
            return(scope);
        }
示例#2
0
        public IEnumerable <ISyntaxNode> Scope(ISyntaxNode concept, string propertyName)
        {
            FunctionConcept function = (FunctionConcept)concept.Ancestor <FunctionConcept>();

            if (function.Parameters.HasValue &&
                function.Parameters.Value != null &&
                function.Parameters.Value.Count > 0)
            {
                return(function.Parameters.Value);
            }
            return(null);
        }
示例#3
0
        public IEnumerable <ISyntaxNode> Scope(ISyntaxNode concept, string propertyName)
        {
            List <ISyntaxNode> scope = new List <ISyntaxNode>();

            if (!(concept.Ancestor <SelectConcept>() is SelectConcept select))
            {
                return(scope);
            }
            if (select.FROM == null)
            {
                return(scope);
            }
            if (select.FROM.Expressions == null)
            {
                return(scope);
            }
            if (select.FROM.Expressions.Count == 0)
            {
                return(scope);
            }

            foreach (var expression in select.FROM.Expressions)
            {
                TableConcept table = null;
                if (expression is TableConcept)
                {
                    table = (TableConcept)expression;
                }
                else if (expression is JoinOperatorConcept)
                {
                    table = ((JoinOperatorConcept)expression).TableReference;
                }
                if (table == null)
                {
                    continue;
                }
                if (table.TableDefinition == null)
                {
                    continue;
                }

                foreach (PropertyInfo property in table.TableDefinition.GetProperties())
                {
                    scope.Add(new ColumnConcept()
                    {
                        Parent         = concept,
                        Name           = property.Name,
                        TableReference = table
                    });
                }
            }
            return(scope);
        }