public JsonSettingsProvider(ILog log, IFileSystem fileSystem, ICommandLineArgumentsProvider argumentsProvider) { this.settings = new Lazy <InternalSettings>(() => { log.Info("Resolving command line arguments"); var args = argumentsProvider.GetArguments(); var indexOfConfig = args.IndexOf("--config"); var overrides = args .Select((x, i) => new { Name = x.StartsWith(OverridePrefix) ? x.Substring(OverridePrefix.Length) : null, ValueIndex = i + 1 }) .Where(x => x.Name != null) .Select(x => new { x.Name, Value = args[x.ValueIndex] }) .ToList(); var defaultConfigLocation = Path.Combine(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location), "config.json"); var configFileName = indexOfConfig != -1 && indexOfConfig + 1 < args.Count ? args[indexOfConfig + 1] : defaultConfigLocation; log.Info($"Using configuration file: '{configFileName}'"); var configFile = JObject.Parse(fileSystem.ReadFile(configFileName)); foreach (var item in overrides) { if (configFile.Properties().All(x => !x.Name.Equals(item.Name, StringComparison.OrdinalIgnoreCase))) { log.Info($"Unknown setting: {item.Name}, ignoring"); } else { log.Info($"overriding setting {item.Name}"); configFile[item.Name] = item.Value; } } return(JsonConvert.DeserializeObject <InternalSettings>(configFile.ToString())); }); }
public WorkspaceProjectContextHostInstance(ConfiguredProject project, IProjectThreadingService threadingService, IUnconfiguredProjectTasksService tasksService, IProjectSubscriptionService projectSubscriptionService, IWorkspaceProjectContextProvider workspaceProjectContextProvider, IActiveEditorContextTracker activeWorkspaceProjectContextTracker, IActiveConfiguredProjectProvider activeConfiguredProjectProvider, ExportFactory <IApplyChangesToWorkspaceContext> applyChangesToWorkspaceContextFactory, IDataProgressTrackerService dataProgressTrackerService, ICommandLineArgumentsProvider commandLineArgumentsProvider) : base(threadingService.JoinableTaskContext) { _project = project; _projectSubscriptionService = projectSubscriptionService; _tasksService = tasksService; _workspaceProjectContextProvider = workspaceProjectContextProvider; _activeWorkspaceProjectContextTracker = activeWorkspaceProjectContextTracker; _activeConfiguredProjectProvider = activeConfiguredProjectProvider; _applyChangesToWorkspaceContextFactory = applyChangesToWorkspaceContextFactory; _dataProgressTrackerService = dataProgressTrackerService; _commandLineArgumentsProvider = commandLineArgumentsProvider; }