public static bool IsContentTypeValid(string contentType, ContentTypeCategory desiredContentType) { if (!string.IsNullOrEmpty(contentType)) { // ContentType header may be returned in the format "text/html; ...." string ct = contentType.IndexOf(';') == -1 ? contentType.Trim().ToLower() : contentType.Substring(0, contentType.IndexOf(';')).Trim().ToLower(); switch (desiredContentType) { case ContentTypeCategory.HTML: { if (ct.CompareTo("text/html") == 0 || ct.CompareTo("text/xhtml") == 0 || ct.CompareTo("application/xhtml+xml") == 0 || ct.CompareTo("text/plain") == 0 || ct.CompareTo("text/sgml") == 0 || ct.CompareTo("text/xml") == 0) { return(true); } break; } } } return(false); }
public string CreateContentTypeIdentifier(string typeName, ContentTypeCategory category, out string groupName) { if (string.IsNullOrEmpty(typeName)) { groupName = null; return(typeName); } // Check for names that includes a group name, e.g. "[Group name] Page name" typeName = RemoveGroupName(typeName, out groupName); // Ensure that the type name end with provided suffix string suffix = null; switch (category) { case ContentTypeCategory.Page: suffix = _options.PageSuffix; break; case ContentTypeCategory.Block: suffix = _options.BlockSuffix; break; case ContentTypeCategory.BlockFolder: case ContentTypeCategory.Undefined: default: break; } if (!string.IsNullOrEmpty(suffix) && !typeName.EndsWith(suffix, StringComparison.InvariantCultureIgnoreCase)) { typeName += suffix; } // Create name that is valid code typeName = _memberNameValidator.CreateIdentifier(typeName); return(typeName); }
public string CreateContentTypeIdentifier(string typeName, ContentTypeCategory category, out string groupName) { if (string.IsNullOrEmpty(typeName)) { groupName = null; return typeName; } // Check for names that includes a group name, e.g. "[Group name] Page name" typeName = RemoveGroupName(typeName, out groupName); // Ensure that the type name end with provided suffix string suffix = null; switch (category) { case ContentTypeCategory.Page: suffix = _options.PageSuffix; break; case ContentTypeCategory.Block: suffix = _options.BlockSuffix; break; case ContentTypeCategory.BlockFolder: case ContentTypeCategory.Undefined: default: break; } if (!string.IsNullOrEmpty(suffix) && !typeName.EndsWith(suffix, StringComparison.InvariantCultureIgnoreCase)) { typeName += suffix; } // Create name that is valid code typeName = _memberNameValidator.CreateIdentifier(typeName); return typeName; }
public string CreateContentTypeIdentifier(string typeName, ContentTypeCategory category) { string groupName; return CreateContentTypeIdentifier(typeName, category, out groupName); }
public string CreateContentTypeIdentifier(string typeName, ContentTypeCategory category) { string groupName; return(CreateContentTypeIdentifier(typeName, category, out groupName)); }
public static bool IsContentTypeValid(string contentType, ContentTypeCategory desiredContentType) { if (!string.IsNullOrEmpty(contentType)) { // ContentType header may be returned in the format "text/html; ...." string ct = contentType.IndexOf(';') == -1 ? contentType.Trim().ToLower() : contentType.Substring(0, contentType.IndexOf(';')).Trim().ToLower(); switch (desiredContentType) { case ContentTypeCategory.HTML: { if (ct.CompareTo("text/html") == 0 || ct.CompareTo("text/xhtml") == 0 || ct.CompareTo("application/xhtml+xml") == 0 || ct.CompareTo("text/plain") == 0 || ct.CompareTo("text/sgml") == 0 || ct.CompareTo("text/xml") == 0) return true; break; } } } return false; }