FileSystemRepositoryHelperGetFileSystemName Method (String, String, Int32, Int32) |
Namespace: CMS.ContinuousIntegration
public static string GetFileSystemName( string name, string fullName, int maxNameLength, int hashLength )
Exception | Condition |
---|---|
ArgumentException | Thrown when name is null or empty or fullName is empty. |
ArgumentOutOfRangeException | Thrown when hashLength is not a positive integer or maxNameLengthis not greater than (hash length + 1) - the extra character is for hash delimiter. |
The name processing is similar to code name processing. Diacritics in Latin characters is removed, illegal characters are replaced by '_' (underscore), multiple '.' (dot) are grouped to single '.', leading and trailing '.' and '_' are trimmed.
Specify the fullName parameter to avoid file system name collisions when name is some shortcut or human-readable form of fullName.
string articleFileSystemName1 = FileSystemRepositoryHelper.GetFileSystemName("Article", "/Path/To/Some/Document/Named/Article", 50, 10); string articleFileSystemName2 = FileSystemRepositoryHelper.GetFileSystemName("Article", "/Path/To/Different/Document/Named/Article", 50, 10); // Produces result similar to: // article@1234567890 // article@0987654321
string defaultFileSystemName = FileSystemRepositoryHelper.GetFileSystemName("/", 50, 10); string customFileSystemName = FileSystemRepositoryHelper.GetFileSystemName("root", "/", 50, 10); // Produces result similar to: // @1234567890 // root@1234567890
string customFileSystemName = FileSystemRepositoryHelper.GetFileSystemName("root", "/", 50, 10); string wrongCustomFileSystemName = FileSystemRepositoryHelper.GetFileSystemName("root", 50, 10); // This is wrong. If another object named "root" would exist, its name would collide with the custom name for "/" // Produces result similar to: // root@1234567890 The hash value is computed from "/" // root