Esempio n. 1
0
        private ColumnModel CreateColumnDefinition()
        {
            var colName = UtilConsole.ReadString("Column name");

            var dataType = UtilConsole.SelectFromEnum("Data type", DataType.None);

            if (dataType == DataType.None)
            {
                return(null);
            }

            var sourceDic = new Dictionary <DataType, List <ColumnDefinitionType> >
            {
                {
                    DataType.Integer,
                    new List <ColumnDefinitionType>
                    {
                        ColumnDefinitionType.IntegerRange, ColumnDefinitionType.DatabaseQuery
                    }
                },
                {
                    DataType.Double,
                    new List <ColumnDefinitionType>
                    {
                        ColumnDefinitionType.DoubleRange, ColumnDefinitionType.DatabaseQuery
                    }
                },
                {
                    DataType.DateTime,
                    new List <ColumnDefinitionType>
                    {
                        ColumnDefinitionType.DateRange, ColumnDefinitionType.DateTimeRange,
                        ColumnDefinitionType.DatabaseQuery
                    }
                },
                {
                    DataType.String,
                    new List <ColumnDefinitionType>
                    {
                        ColumnDefinitionType.RandomPattern, ColumnDefinitionType.RandomChars,
                        ColumnDefinitionType.Template, ColumnDefinitionType.DatabaseQuery
                    }
                },
                { DataType.Guid, new List <ColumnDefinitionType> {
                      ColumnDefinitionType.Guid
                  } }
            };
            var sourceList         = sourceDic[dataType];
            var sourceListAsString = sourceList.Select(itm => itm.ToString()).ToList();
            var sourceTypeAsString = UtilConsole.SelectFromList(sourceListAsString, "Select generator source");
            var sourceType         = UtilEnum.Get <ColumnDefinitionType>(sourceTypeAsString);

            var def    = _columnModelFactory.GetInstance(sourceType);
            var loader = _consoleLoaderFactory.GetInstance(sourceType);

            def.Name = colName;
            loader.LoadFromConsole(def);

            return(def);
        }
Esempio n. 2
0
        public override void Read(ConsoleReadContext context, SelectStringTaskParameter param)
        {
            var value = UtilConsole.SelectFromList(param.List, param.Label, param.ExitValue, param.DefaultValue);

            if (string.IsNullOrEmpty(value) && !param.AllowEmpty)
            {
                context.IsCanceled = true;
                return;
            }

            context[param.Name] = value;
        }