Example #1
0
        public bool Validate(string script)
        {
            //Loading in data
            if (_fileSystem.FileExist("data.json"))
            {
                var data =
                    JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, string> > >(
                        _fileSystem.ReadFile("data.json"));

                foreach (var key in data.Keys)
                {
                    _dataStore.Write(key, data[key], true);
                }
            }

            try
            {
                _console.Information("Executing configuration script... This can take awhile if there are a lot of packages to load...");
                _runner.ExecuteFile(script).Wait();
            }
            catch (Exception e)
            {
                _console.Error("There was an error while running script! Error: {error}", e);
                return(false);
            }

            try
            {
                _graphManager.Validate();
            }
            catch (GraphValidationException e)
            {
                _console.Error("Validation Error! Error: {details}", e);
                return(false);
            }

            return(true);
        }