/// <exception cref="InvalidPath"></exception> public static RelativeFilePath Parse(string nativePath) { if (string.IsNullOrEmpty(nativePath)) { return(null); } try { return(new RelativeFilePath( new FileName(Path.GetFileName(nativePath)), RelativeDirectoryPath.Parse(Path.GetDirectoryName(nativePath)))); } catch (Exception e) { throw new InvalidPath(nativePath, e); } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { if (objectType == typeof(AbsoluteFilePath)) { return(AbsoluteFilePath.Parse((string)reader.Value)); } if (objectType == typeof(RelativeFilePath)) { return(RelativeFilePath.Parse((string)reader.Value)); } if (objectType == typeof(AbsoluteDirectoryPath)) { return(AbsoluteDirectoryPath.Parse((string)reader.Value)); } if (objectType == typeof(RelativeDirectoryPath)) { return(RelativeDirectoryPath.Parse((string)reader.Value)); } throw new ArgumentException("The type '" + objectType.FullName + "' was not recognized by this converter"); }
internal RelativeFilePath(FileName name, RelativeDirectoryPath basePath = null) { BasePath = basePath; Name = name; }
public static IDirectoryPath Parse(string relativeOrAbsolutePath) { return(Path.IsPathRooted(relativeOrAbsolutePath) ? (IDirectoryPath)AbsoluteDirectoryPath.Parse(relativeOrAbsolutePath) : (IDirectoryPath)RelativeDirectoryPath.Parse(relativeOrAbsolutePath)); }