public Task <LocalScheme> Create(LocalSchemeCreateParameters parameters)
        {
            var scheme = _schemeTextReader.GetModel(parameters.Definition);
            var path   = _fileSystem.Path.Combine(parameters.Folder, parameters.Name + ".wsc");

            _wscWriter.Write(scheme, path);

            return(Task.FromResult(new LocalScheme(path, parameters.Name, scheme)));
        }
示例#2
0
        public Task <int> OnExecuteAsync(IConsole console)
        {
            string name;
            string definition;
            string source;
            var    outputFolder = ResourceFolder;

            try
            {
                name = ValidateName();
                (definition, source) = ValidateSchemeDefinition(console);
                outputFolder         = ValidateOutputFolder(outputFolder);
            }
            catch (ConfigurationException exception)
            {
                Logger.Error(exception.Message);
                return(Task.FromResult(1));
            }

            Scheme scheme;

            try
            {
                Logger.Verbose($"Reading Scheme definition from {source}");
                scheme = _schemeTextReader.GetModel(definition);
            }
            catch (FormatException exception)
            {
                Logger.Error("Failed to read Scheme definition: " + exception.Message);
                return(Task.FromResult(1));
            }

            var outputFilePath = _fileSystem.Path.Combine(outputFolder, name + ".wsc");

            Logger.Information($"Writing Scheme to {outputFilePath}");
            _wscWriter.Write(scheme, outputFilePath);

            return(Task.FromResult(0));
        }