Exemplo n.º 1
0
        private static void FillMethodsTable(ValueTable.ValueTable result, IEnumerable <MethodInfo> methods)
        {
            var nameColumn        = result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var countColumn       = result.Columns.Add("КоличествоПараметров", TypeDescription.IntegerType(), "Количество параметров");
            var isFunctionColumn  = result.Columns.Add("ЭтоФункция", TypeDescription.BooleanType(), "Это функция");
            var annotationsColumn = result.Columns.Add("Аннотации", new TypeDescription(), "Аннотации");
            var paramsColumn      = result.Columns.Add("Параметры", new TypeDescription(), "Параметры");

            foreach (var methInfo in methods)
            {
                if (!methInfo.IsExport)
                {
                    continue;
                }

                ValueTableRow new_row = result.Add();
                new_row.Set(nameColumn, ValueFactory.Create(methInfo.Name));
                new_row.Set(countColumn, ValueFactory.Create(methInfo.ArgCount));
                new_row.Set(isFunctionColumn, ValueFactory.Create(methInfo.IsFunction));

                if (methInfo.AnnotationsCount != 0)
                {
                    new_row.Set(annotationsColumn, CreateAnnotationTable(methInfo.Annotations));
                }

                var paramTable             = new ValueTable.ValueTable();
                var paramNameColumn        = paramTable.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
                var paramByValue           = paramTable.Columns.Add("ПоЗначению", TypeDescription.BooleanType(), "По значению");
                var paramHasDefaultValue   = paramTable.Columns.Add("ЕстьЗначениеПоУмолчанию", TypeDescription.BooleanType(), "Есть значение по-умолчанию");
                var paramAnnotationsColumn = paramTable.Columns.Add("Аннотации", new TypeDescription(), "Аннотации");

                new_row.Set(paramsColumn, paramTable);

                if (methInfo.ArgCount != 0)
                {
                    var index = 0;
                    foreach (var param in methInfo.Params)
                    {
                        var name     = string.Format("param{0}", ++index);
                        var paramRow = paramTable.Add();
                        paramRow.Set(paramNameColumn, ValueFactory.Create(name));
                        paramRow.Set(paramByValue, ValueFactory.Create(param.IsByValue));
                        paramRow.Set(paramHasDefaultValue, ValueFactory.Create(param.HasDefaultValue));
                        if (param.AnnotationsCount != 0)
                        {
                            paramRow.Set(paramAnnotationsColumn, CreateAnnotationTable(param.Annotations));
                        }
                    }
                }
            }
        }
Exemplo n.º 2
0
        private static void FillMethodsTable(ValueTable.ValueTable result, IEnumerable <MethodInfo> methods)
        {
            var nameColumn       = result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var countColumn      = result.Columns.Add("КоличествоПараметров", TypeDescription.IntegerType(), "Количество параметров");
            var isFunctionColumn = result.Columns.Add("ЭтоФункция", TypeDescription.BooleanType(), "Это функция");

            foreach (var methInfo in methods)
            {
                ValueTableRow new_row = result.Add();
                new_row.Set(nameColumn, ValueFactory.Create(methInfo.Name));
                new_row.Set(countColumn, ValueFactory.Create(methInfo.ArgCount));
                new_row.Set(isFunctionColumn, ValueFactory.Create(methInfo.IsFunction));
            }
        }
Exemplo n.º 3
0
        public ValueTable.ValueTable GetMethodsTable(IRuntimeContextInstance target)
        {
            ValueTable.ValueTable Result = new ValueTable.ValueTable();

            var NameColumn       = Result.Columns.Add("Имя", ValueFactory.Create(""), "Имя");                                    // TODO: Доработать после увеличения предела количества параметров
            var CountColumn      = Result.Columns.Add("КоличествоПараметров", ValueFactory.Create(""), "Количество параметров"); // TODO: Доработать после увеличения предела количества параметров
            var IsFunctionColumn = Result.Columns.Add("ЭтоФункция", ValueFactory.Create(""), "Это функция");                     // TODO: Доработать после увеличения предела количества параметров

            foreach (var methInfo in target.GetMethods())
            {
                ValueTableRow new_row = Result.Add();
                new_row.Set(NameColumn, ValueFactory.Create(methInfo.Name));
                new_row.Set(CountColumn, ValueFactory.Create(methInfo.ArgCount));
                new_row.Set(IsFunctionColumn, ValueFactory.Create(methInfo.IsFunction));
            }

            return(Result);
        }
Exemplo n.º 4
0
        public ValueTable.ValueTable GetMethodsTable(IRuntimeContextInstance target)
        {
            ValueTable.ValueTable Result = new ValueTable.ValueTable();

            var NameColumn       = Result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var CountColumn      = Result.Columns.Add("КоличествоПараметров", TypeDescription.IntegerType(), "Количество параметров");
            var IsFunctionColumn = Result.Columns.Add("ЭтоФункция", TypeDescription.BooleanType(), "Это функция");

            foreach (var methInfo in target.GetMethods())
            {
                ValueTableRow new_row = Result.Add();
                new_row.Set(NameColumn, ValueFactory.Create(methInfo.Name));
                new_row.Set(CountColumn, ValueFactory.Create(methInfo.ArgCount));
                new_row.Set(IsFunctionColumn, ValueFactory.Create(methInfo.IsFunction));
            }

            return(Result);
        }
Exemplo n.º 5
0
        private static void FillPropertiesTable(ValueTable.ValueTable result, IEnumerable <VariableInfo> properties)
        {
            var nameColumn        = result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var annotationsColumn = result.Columns.Add("Аннотации", new TypeDescription(), "Аннотации");
            var systemVarNames    = new string[] { "этотобъект", "thisobject" };

            foreach (var propInfo in properties)
            {
                if (systemVarNames.Contains(propInfo.Identifier.ToLower()))
                {
                    continue;
                }

                ValueTableRow new_row = result.Add();
                new_row.Set(nameColumn, ValueFactory.Create(propInfo.Identifier));

                new_row.Set(annotationsColumn, propInfo.AnnotationsCount != 0 ? CreateAnnotationTable(propInfo.Annotations) : EmptyAnnotationsTable());
            }
        }
Exemplo n.º 6
0
        private void FillPropertiesTable(ValueTable.ValueTable result, IEnumerable <VariableInfo> properties)
        {
            var nameColumn     = result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");
            var systemVarNames = new string[] { "этотобъект", "thisobject" };

            foreach (var propInfo in properties)
            {
                if (systemVarNames.Contains(propInfo.Identifier.ToLower()))
                {
                    continue;
                }

                ValueTableRow newRow = result.Add();
                newRow.Set(nameColumn, ValueFactory.Create(propInfo.Identifier));
            }
        }
Exemplo n.º 7
0
        public ValueTable.ValueTable GetPropertiesTable(IRuntimeContextInstance target)
        {
            ValueTable.ValueTable Result = new ValueTable.ValueTable();

            var NameColumn = Result.Columns.Add("Имя", TypeDescription.StringType(), "Имя");

            var SystemVarNames = new string[] { "этотобъект", "thisobject" };

            foreach (var propInfo in target.GetProperties())
            {
                if (SystemVarNames.Contains(propInfo.Identifier.ToLower()))
                {
                    continue;
                }

                ValueTableRow new_row = Result.Add();
                new_row.Set(NameColumn, ValueFactory.Create(propInfo.Identifier));
            }

            return(Result);
        }
        public QueryResult(DbDataReader reader)
        {
            for (int ColIdx = 0; ColIdx < reader.FieldCount; ColIdx++)
            {
                _resultTable.Columns.Add(reader.GetName(ColIdx));
            }

            using (reader)
            {
                foreach (DbDataRecord record in reader)
                {
                    ValueTableRow row = _resultTable.Add();

                    for (int ColIdx = 0; ColIdx < reader.FieldCount; ColIdx++)
                    {
                        if (record.IsDBNull(ColIdx))
                        {
                            row.Set(ColIdx, ValueFactory.Create());
                            continue;
                        }

                        if (record.GetFieldType(ColIdx) == typeof(Int32))
                        {
                            row.Set(ColIdx, ValueFactory.Create((int)record.GetValue(ColIdx)));
                        }
                        if (record.GetFieldType(ColIdx) == typeof(Int64))
                        {
                            row.Set(ColIdx, ValueFactory.Create(record.GetInt64(ColIdx)));
                        }
                        if (record.GetFieldType(ColIdx) == typeof(Boolean))
                        {
                            row.Set(ColIdx, ValueFactory.Create(record.GetBoolean(ColIdx)));
                        }
                        if (record.GetFieldType(ColIdx) == typeof(UInt64))
                        {
                            row.Set(ColIdx, ValueFactory.Create(record.GetValue(ColIdx).ToString()));
                        }

                        if (record.GetFieldType(ColIdx) == typeof(System.Double))
                        {
                            double val = record.GetDouble(ColIdx);
                            row.Set(ColIdx, ValueFactory.Create(val.ToString()));
                        }
                        if (record.GetFieldType(ColIdx) == typeof(Single))
                        {
                            float val = record.GetFloat(ColIdx);
                            row.Set(ColIdx, ValueFactory.Create(val.ToString()));
                        }
                        if (record.GetFieldType(ColIdx) == typeof(Decimal))
                        {
                            row.Set(ColIdx, ValueFactory.Create(record.GetDecimal(ColIdx)));
                        }
                        if (record.GetFieldType(ColIdx) == typeof(System.String))
                        {
                            row.Set(ColIdx, ValueFactory.Create(record.GetString(ColIdx)));
                        }
                        if (record.GetFieldType(ColIdx) == typeof(System.DateTime))
                        {
                            row.Set(ColIdx, ValueFactory.Create(record.GetDateTime(ColIdx)));
                        }
                        if (record.GetFieldType(ColIdx) == typeof(System.Byte[]))
                        {
                            var data    = (byte[])record[ColIdx];
                            var newData = new BinaryDataContext(data);
                            row.Set(ColIdx, ValueFactory.Create(newData));
                        }
                    }
                }
            }
        }
Exemplo n.º 9
0
        public ValueTable RunQuery()
        {
            ValueTable  tbl       = new ValueTable();
            OdbcCommand dbCommand = (OdbcCommand)dbСonnection.CreateCommand();

            // Добавляем параметры в запрос
            string pattern = @"@[A-z0-9]*";
            Regex  regex   = new Regex(pattern);
            Match  match   = regex.Match(QueryText);

            while (match.Success)
            {
                string currParam = match.Value;
                var    currValue = parameters[currParam];
                dbCommand.Parameters.AddWithValue(currParam, currValue);
                match = match.NextMatch();
            }
            string prepareQuery = regex.Replace(QueryText, "?");

            dbCommand.CommandText = prepareQuery;
            // Выполняем запрос
            IDataReader dbReader = dbCommand.ExecuteReader();

            // Создаем ТаблицуЗначений в которую будем выводить результат запроса

            for (int i = 0; i < dbReader.FieldCount; i++)
            {
                string ColumnName = dbReader.GetName(i);
                tbl.Columns.Add(ColumnName);
            }


            while (dbReader.Read())
            {
                for (int i = 0; i < dbReader.FieldCount; i++)
                {
                    string        ColumnName = dbReader.GetName(i);
                    ValueTableRow row        = tbl.Add();
                    var           value      = dbReader[ColumnName];
                    System.Type   valueType  = value.GetType();
                    if (valueType == typeof(int))
                    {
                        row.Set(i, ValueFactory.Create((int)value));
                    }
                    else if (valueType == typeof(Int16))
                    {
                        row.Set(i, ValueFactory.Create((Int16)value));
                    }
                    else if (valueType == typeof(Int32))
                    {
                        row.Set(i, ValueFactory.Create((Int32)value));
                    }
                    else if (valueType == typeof(string))
                    {
                        row.Set(i, ValueFactory.Create((string)value));
                    }
                    else if (valueType == typeof(DateTime))
                    {
                        row.Set(i, ValueFactory.Create((DateTime)value));
                    }
                }
            }

            dbReader.Close();
            dbReader = null;
            dbCommand.Dispose();
            dbCommand = null;
            return(tbl);
        }
Exemplo n.º 10
0
        public ValueTable Unload()
        {
            ValueTable resultTable = new ValueTable();

            for (int ColIdx = 0; ColIdx < _reader.FieldCount; ColIdx++)
            {
                resultTable.Columns.Add(_reader.GetName(ColIdx));
            }

            foreach (DbDataRecord record in _reader)
            {
                ValueTableRow row = resultTable.Add();

                for (int ColIdx = 0; ColIdx < _reader.FieldCount; ColIdx++)
                {
                    if (record.IsDBNull(ColIdx))
                    {
                        row.Set(ColIdx, ValueFactory.Create());
                        continue;
                    }

                    //Console.WriteLine("queryresult-col-type:" + record.GetFieldType(ColIdx).ToString() + "::" + record.GetDataTypeName(ColIdx));

                    if (record.GetFieldType(ColIdx) == typeof(Int32))
                    {
                        row.Set(ColIdx, ValueFactory.Create((int)record.GetValue(ColIdx)));
                    }
                    if (record.GetFieldType(ColIdx) == typeof(Int64))
                    {
                        row.Set(ColIdx, ValueFactory.Create(record.GetInt64(ColIdx)));
                    }
                    if (record.GetFieldType(ColIdx) == typeof(Boolean))
                    {
                        row.Set(ColIdx, ValueFactory.Create(record.GetBoolean(ColIdx)));
                    }
                    if (record.GetFieldType(ColIdx) == typeof(UInt64))
                    {
                        row.Set(ColIdx, ValueFactory.Create(record.GetValue(ColIdx).ToString()));
                    }

                    if (record.GetFieldType(ColIdx).ToString() == "System.Double")
                    {
                        double val = record.GetDouble(ColIdx);
                        row.Set(ColIdx, ValueFactory.Create(val.ToString()));
                    }
                    if (record.GetFieldType(ColIdx) == typeof(Single))
                    {
                        float val = record.GetFloat(ColIdx);
                        row.Set(ColIdx, ValueFactory.Create(val.ToString()));
                    }
                    if (record.GetFieldType(ColIdx) == typeof(Decimal))
                    {
                        row.Set(ColIdx, ValueFactory.Create(record.GetDecimal(ColIdx)));
                    }
                    if (record.GetFieldType(ColIdx).ToString() == "System.String")
                    {
                        row.Set(ColIdx, ValueFactory.Create(record.GetString(ColIdx)));
                    }
                    if (record.GetFieldType(ColIdx).ToString() == "System.DateTime")
                    {
                        row.Set(ColIdx, ValueFactory.Create(record.GetDateTime(ColIdx)));
                    }
                    if (record.GetFieldType(ColIdx).ToString() == "System.Byte[]")
                    {
                        var data    = (byte[])record[ColIdx];
                        var newData = new BinaryDataContext(data);
                        row.Set(ColIdx, ValueFactory.Create(newData));
                    }
                }
            }
            _reader.Close();
            return(resultTable);
        }