public static void DeleteMimeType(MimeMap mimeMap, StaticContentSection section) { if (mimeMap == null) { throw new ArgumentNullException("mimeMap"); } MimeMapCollection collection = section.MimeMaps; MimeMap element = collection[mimeMap.FileExtension]; if (element == null) { return; } try { collection.Remove(mimeMap.FileExtension); } catch (FileLoadException e) { throw new LockedException(section.SectionPath, e); } catch (DirectoryNotFoundException e) { throw new ConfigScopeNotFoundException(e); } }
public static void AddMimeMap(MimeMap mimeMap, StaticContentSection section) { if (mimeMap == null) { throw new ArgumentNullException("mimeMap"); } MimeMapCollection collection = section.MimeMaps; if (collection[mimeMap.FileExtension] != null) { throw new AlreadyExistsException("file_extension"); } try { collection.Add(mimeMap); } catch (FileLoadException e) { throw new LockedException(section.SectionPath, e); } catch (DirectoryNotFoundException e) { throw new ConfigScopeNotFoundException(e); } }