Neco/LandView/LandViewUtils.cs
/// <summary>Validates a Points string for use on a <see cref="Plot"/>,<see cref="District"/>, or a <see cref="Road"/></summary>
/// <param name="Points"></param>
/// <param name="MinLength">Minimum number of points. 2 for roads, 3 for plots and districts</param>
/// <returns></returns>
Validates a Points string for use on a ,, or a
Validates a Points string for use on a or a
public static bool ValidatePoints(string Points, int MinLength) {
            if (string.IsNullOrWhiteSpace(Points)) { return false; }
            if (Points.Length == 0) { return true; }
            if (Points.Length < MinLength) { return false; }
            foreach (string ppair in Points.Split(";")) {
                string[] ppairsplit = ppair.Split(",");
                if (ppairsplit.Length != 2) { return false; } 
                if (!int.TryParse(ppairsplit[0], out int _)) { return false; } 
                if (!int.TryParse(ppairsplit[1], out int _)) { return false; } 
            }
            return true;
        }
public static bool ValidatePoints ( string Points , int MinLength ) { if ( string . IsNullOrWhiteSpace ( Points ) ) { return false ; } if ( Points . Length == 0 ) { return true ; } if ( Points . Length < MinLength ) { return false ; } foreach ( string ppair in Points . Split ( " " ) ) { string [ ] ppairsplit = ppair . Split ( " " ) ; if ( ppairsplit . Length != 2 ) { return false ; } if ( ! int . TryParse ( ppairsplit [ 0 ] , out int _ ) ) { return false ; } if ( ! int . TryParse ( ppairsplit [ 1 ] , out int _ ) ) { return false ; } } return true ; }
Validates a Points string for use on a ,, or a
Validates a Points string for use on a or a
//Ensure blank ones can be actually saved. //First let's split this by semicolon //Split it again by colon //If we have more than three coords then no //Test to ensure both can be //parsed as ints
None
Points
string
None
MinLength
int
Minimum number of points. 2 for roads, 3 for plots and districts
Minimum number of points . 2 for roads 3 for plots and districts