コード例 #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);
            }
        }
コード例 #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");
 }
コード例 #3
0
 internal RelativeFilePath(FileName name, RelativeDirectoryPath basePath = null)
 {
     BasePath = basePath;
     Name     = name;
 }
コード例 #4
0
ファイル: DirectoryPath.cs プロジェクト: yongaru/fuse-studio
 public static IDirectoryPath Parse(string relativeOrAbsolutePath)
 {
     return(Path.IsPathRooted(relativeOrAbsolutePath)
                         ? (IDirectoryPath)AbsoluteDirectoryPath.Parse(relativeOrAbsolutePath)
                         : (IDirectoryPath)RelativeDirectoryPath.Parse(relativeOrAbsolutePath));
 }