private static Exception GetInvalidPathException(PathResult result, string path)
{
switch (result)
{
default:
case PathResult.Correct:
return null;
case PathResult.Empty:
// Name cannot be empty.
return new InvalidPathException(EmptyNameMessage);
case PathResult.TooLong:
// Path too long. Max length is {0}.
return new InvalidPathException(string.Format(PathTooLongMessage, Data.DataProvider.Current.PathMaxLength));
case PathResult.InvalidPathChar:
// Content path may only contain alphanumeric characters or '.', '(', ')', '[', ']', '/'!
return new InvalidPathException(String.Concat(InvalidPathMessage, ". Path: ", path));
case PathResult.InvalidNameChar:
// Content name may only contain alphanumeric characters or '.', '(', ')', '[', ']'!
return new InvalidPathException(String.Concat(InvalidNameMessage, ". Path: ", path));
case PathResult.StartsWithSpace:
// Name cannot start with whitespace.
return new InvalidPathException(NameStartsWithWhitespaceMessage);
case PathResult.EndsWithSpace:
// Name cannot end with whitespace.
return new InvalidPathException(NameEndsWithWhitespaceMessage);
case PathResult.InvalidFirstChar:
// Path must start with '/' character.
return new InvalidPathException(PathFirstCharMessage);
case PathResult.EndsWithDot:
// Path cannot end with '.' character.
return new InvalidPathException(PathEndsWithDotMessage);
}
}