private static bool ParseStartingLine(string startingLine, LoadedTrack loadedTrack) { int searchIndex = 0; double parseResult; bool parseFlag; string subString; string trimString; int resultIndex = startingLine.IndexOf(SEPARATOR_NUMBER, searchIndex); if (resultIndex == -1) { return(false); } subString = startingLine.Substring(0, resultIndex); parseFlag = Double.TryParse(subString, out parseResult); if (parseFlag == false) { return(false); } loadedTrack.widthLeftStartingPoint = parseResult; searchIndex = resultIndex + 1; // length of SEPARATOR subString = startingLine.Substring(searchIndex); trimString = subString.Trim(TRIM_CHARS); parseFlag = Double.TryParse(trimString, out parseResult); if (parseFlag == false) { return(false); } loadedTrack.widthRightStartingPoint = parseResult; return(true); }
private static ITrack CreateTrack(string completeContent, string filePath) { LoadedTrack loadedTrack = new LoadedTrack(filePath); // split into segments: Starting line, outer curve, inner curve string[] segments = completeContent.Split(SEPARATOR_SEGMENT); if (segments == null) { return(null); } if (segments.Length != 3) { return(null); } // parse starting line bool segmentResult = ParseStartingLine(segments[0], loadedTrack); if (segmentResult == false) { return(null); } segmentResult = ParseOuterCurve(segments[1], loadedTrack); if (segmentResult == false) { return(null); } segmentResult = ParseInnerCurve(segments[2], loadedTrack); if (segmentResult == false) { return(null); } return(loadedTrack); }
private static bool ParseInnerCurve(string innerCurve, LoadedTrack loadedTrack) { loadedTrack.innerPoints = new List <Point>(); return(ParseCurve(innerCurve, loadedTrack.innerPoints)); }
private static bool ParseOuterCurve(string outerCurve, LoadedTrack loadedTrack) { loadedTrack.outerPoints = new List <Point>(); return(ParseCurve(outerCurve, loadedTrack.outerPoints)); }