OpenBve.FileSystem.FromConfigurationFile C# (CSharp) Méthode

FromConfigurationFile() private static méthode

Creates the file system information from the specified configuration file.
private static FromConfigurationFile ( string file ) : FileSystem
file string The configuration file describing the file system.
Résultat FileSystem
		private static FileSystem FromConfigurationFile(string file) {
			string assemblyFile = Assembly.GetExecutingAssembly().Location;
			string assemblyFolder = Path.GetDirectoryName(assemblyFile);
			FileSystem system = new FileSystem();
			try
			{
				string[] lines = File.ReadAllLines(file, Encoding.UTF8);
				foreach (string line in lines)
				{
					int equals = line.IndexOf('=');
					if (equals >= 0)
					{
						string key = line.Substring(0, equals).Trim().ToLowerInvariant();
						string value = line.Substring(equals + 1).Trim();
						switch (key)
						{
							case "data":

								system.DataFolder = GetAbsolutePath(value, true);
								if (!Directory.Exists(system.DataFolder))
								{
									system.DataFolder = OpenBveApi.Path.CombineDirectory(assemblyFolder, "Data");
									if (!Directory.Exists(system.DataFolder))
									{
										//If we are unable to find the data folder, this is a critical error, as it contains all sorts of essential stuff.....
										MessageBox.Show(@"Critical error:" + Environment.NewLine + @"Unable to find the openBVE data folder.....", @"openBVE", MessageBoxButtons.OK, MessageBoxIcon.Hand);
										Environment.Exit(0);
									}
								}
								break;
							case "managedcontent":
								system.ManagedContentFolders = value.Split(',');
								for (int i = 0; i < system.ManagedContentFolders.Length; i++)
								{
									system.ManagedContentFolders[i] = GetAbsolutePath(system.ManagedContentFolders[i].Trim(), true);
								}
								break;
							case "settings":
								system.SettingsFolder = GetAbsolutePath(value, true);
								break;
							case "initialroute":
								system.InitialRouteFolder = GetAbsolutePath(value, true);
								break;
							case "initialtrain":
								system.InitialTrainFolder = GetAbsolutePath(value, true);
								break;
							case "restartprocess":
								system.RestartProcess = GetAbsolutePath(value, true);
								break;
							case "restartarguments":
								system.RestartArguments = GetAbsolutePath(value, false);
								break;
							case "routepackageinstall":
								system.RouteInstallationDirectory = GetAbsolutePath(value, true);
								break;
							case "trainpackageinstall":
								system.TrainInstallationDirectory = GetAbsolutePath(value, true);
								break;
							case "otherpackageinstall":
								system.OtherInstallationDirectory = GetAbsolutePath(value, true);
								break;
						}
					}
				}
			}
			catch { }
			return system;
		}