Esempio n. 1
0
        /// <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);
            }
        }
Esempio n. 2
0
 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");
 }
Esempio n. 3
0
 internal RelativeFilePath(FileName name, RelativeDirectoryPath basePath = null)
 {
     BasePath = basePath;
     Name     = name;
 }
Esempio n. 4
0
 public static IDirectoryPath Parse(string relativeOrAbsolutePath)
 {
     return(Path.IsPathRooted(relativeOrAbsolutePath)
                         ? (IDirectoryPath)AbsoluteDirectoryPath.Parse(relativeOrAbsolutePath)
                         : (IDirectoryPath)RelativeDirectoryPath.Parse(relativeOrAbsolutePath));
 }