public static string GetUniqueKey(this IFactorioInstance instance) { if (instance.IsExternal()) { // We use the full path of the instance as unique key string result = instance.Directory.FullName.Trim().ToLower(); // We have to sanitize the path to make sure it's a proper unique key result = result.Replace('/', '_'); result = result.Replace('\\', '_'); if (result.EndsWith("_")) { result = result[0..^ 1];
public static string GetUniqueKey(this IFactorioInstance instance) { if (instance.IsExternal()) { // We use the full path of the instance as unique key string result = instance.Directory.FullName.Trim().ToLower(); // We have to sanitize the path to make sure it's a proper unique key result = result.Replace('/', '_'); result = result.Replace('\\', '_'); if (result.EndsWith("_")) { result = result.Substring(0, result.Length - 1); } return(result); } else { // The directory name is already a unique key, no need to use the full path return(instance.Directory.Name); } }