PropertiesEditorWindow(string file) { InitializeComponent(); this.file = file; svProperties = ServerProperties.FromFile(file); LoadProperties(); }
/// <summary> /// Gets a server properties from a given server.properties string /// </summary> /// <param name="str">The server.properties contents</param> /// <returns>The server properties representing the contents of the server.properties file</returns> public static ServerProperties FromString(string str) { var svProperties = new ServerProperties(); var lines = str.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries); foreach (var line in lines) { if (line.StartsWith("#") || !line.Contains("=")) { continue; // ignore comment } var spl = line.Split(new char[] { '=' }, StringSplitOptions.None); if (spl.Length < 2) { continue; // ignore invalid line } // add property svProperties.Properties.Add(new ServerProperty(spl[0], spl[1])); } return(svProperties); }