/// <summary> /// Initializes a new instance of the <see cref="PathElementDto"/> class. /// </summary> public PathElementDto(InspectionPlanEntityDto type = InspectionPlanEntityDto.Part, string value = "") { Type = type; Value = value ?? string.Empty; }
private static PathInformationDto ColloquialString2PathInformationInternal([NotNull] string path, InspectionPlanEntityDto entity) { if (string.IsNullOrEmpty(path)) { throw new ArgumentException("The path string must not be null or empty.", nameof(path)); } // fast code path for root path if (path == DelimiterString) { if (entity != InspectionPlanEntityDto.Part) { throw new ArgumentException("The root path must always be of type part.", nameof(entity)); } return(PathInformationDto.Root); } // convert to database format by prepending a delimiter if it is not already present if (!path.StartsWith(DelimiterString)) { path = DelimiterString + path; } // convert to database format by appending a delimiter if it is not already present (beware of escaping) if (!path.EndsWith(DelimiterString) || path.EndsWith(EscapedDelimiter)) { path += DelimiterString; } return(String2PathInformationInternal(path, null, i => entity)); }