Esempio n. 1
0
        public static string EnterValue(string promptLabel, string defaultValue, EnterValueOption valueOption)
        {
            string result = defaultValue;

            PromptHelper.ShowPromptHighlight(promptLabel);
            string valueEntered = EnterString();

            if (!string.IsNullOrEmpty(valueEntered))
            {
                result = valueEntered.Trim();
            }

            switch (valueOption)
            {
            case EnterValueOption.UpperCase:
                if (!string.IsNullOrEmpty(result))
                {
                    result = result.ToUpper();
                }
                break;

            case EnterValueOption.None:
            default:
                break;
            }
            return(result);
        }
Esempio n. 2
0
        private void CreateNewConfiguration()
        {
            List <IConfigService> configServiceResult = new List <IConfigService>();

            foreach (var item in ProgramUI.GetConfigs())
            {
                Type           serviceType   = Type.GetType(item.AssemblyQualifiedName);
                IConfigService configService = Activator.CreateInstance(serviceType) as IConfigService;
                configServiceResult.Add(configService);
                PromptHelper.ShowPromptHighlight($"{configService.GetConfigPrefixFilename()} \t {configService.GetTitle()}");
            }

            string         serviceFileName = PromptHelper.EnterValue($"Enter the config name you want to create: ");
            IConfigService selectedService = configServiceResult.FirstOrDefault(item => item.GetConfigPrefixFilename() == serviceFileName);

            Type   promptType      = Type.GetType($"{selectedService.GetPromptToolFullName()}, {typeof(IConfigService).Assembly.GetName()}");
            var    control         = Activator.CreateInstance(promptType) as ControlConfig;
            string defaultFilename = control.GetDefaultWorkspaceFilename();
            string newFilename     = Path.Combine(Path.GetDirectoryName(defaultFilename),
                                                  $"{Path.GetFileNameWithoutExtension(defaultFilename)}{serviceFileName}{Path.GetExtension(defaultFilename)}");

            control.CreateWS(new FileInfo(newFilename));
        }
Esempio n. 3
0
        private static void ConnectConfiguration(FileInfo[] files, string jsonFilename)
        {
            FileInfo fileFound = null;

            while (fileFound == null)
            {
                if (!jsonFilename.EndsWith(".json", StringComparison.InvariantCultureIgnoreCase))
                {
                    jsonFilename += ".json";
                }
                fileFound = files.ToList().SingleOrDefault(p => p.Name == jsonFilename);

                if (fileFound == null)
                {
                    PromptHelper.ShowPromptHighlight($"{jsonFilename} doesn't exist.");
                    jsonFilename = PromptHelper.EnterValue("Please, enter your choice, or the solution you want to open : ");
                }
            }

            var content = GetControlInstance(fileFound);

            content.CreateWS(fileFound);
        }