/// <summary> /// Formats the extension whitelist appropriate for storage in the Host setting /// </summary> /// <param name="additionalExtensions">A list of additionalExtensions to add to the current extensions</param> /// <remarks><paramref name="additionalExtensions"/>case and '.' prefix will be corrected, and duplicates will be excluded from the string</remarks> /// <returns>A String of the whitelist extensions formatted for storage as a Host setting</returns> public string ToStorageString(IEnumerable <string> additionalExtensions) { IEnumerable <string> allExtensions = CombineLists(additionalExtensions); var leadingDotRemoved = allExtensions.Select(ext => ext.Substring(1)); return(EscapedString.Combine(leadingDotRemoved)); }
/// <summary> /// Initializes a new instance of the FileExtensionWhiteList class. /// </summary> /// <param name="extensionList">a comma seperated list of file extensions with no '.'</param> /// <remarks><paramref name="extensionList"/>should match the format used in the FileExtensions Host setting specifically it /// should not have an '.' in the extensions (e.g. txt,jpg,png,doc)</remarks> public FileExtensionWhitelist(string extensionList) { _extensions = EscapedString.Seperate(extensionList.ToLowerInvariant()).Select(item => "." + item).ToList(); }