public void Ignores_DefaultTemplate_If_None() { umbracoContentType.SetDefaultTemplate(null); ((DocumentTypeInfo)expected.Info).DefaultTemplate = null; var actual = ContentTypeMapping.Map(umbracoContentType); Assert.AreEqual(expected, actual, Serialize(actual)); }
private string GetContentType(string path) { var extensionName = Path.GetExtension(path); IContentTypeMapping contentTypeMapping = new ContentTypeMapping(); if (!contentTypeMapping.TryGetContentType(extensionName, out string contentType)) { // 如果没有对应的ContentType,就使用.txt对应的ContentType contentType = "text/plain"; } return(contentType); }
/// <summary> /// The main conversion API. Calling this function sends an audio file to AT&T service for translation to text. /// </summary> /// <param name="attachment">Audio filename as it is stored on disk.</param> /// <param name="speechContext">Speech content.</param> /// <returns>Instance of <see cref="SpeechResponse"/> with sent speech response information.</returns> /// <exception cref="System.ArgumentNullException">Throws an exception when attachment is null.</exception> public async Task <SpeechResponse> SpeechToText(StorageFile attachment, XSpeechContext speechContext = XSpeechContext.Generic) { Argument.ExpectNotNull(() => attachment); byte[] audioFileBytes = await BinaryFileUtils.ReadAllBytes(attachment); var restEndPoint = new Uri(Settings.EndPoint, SendRelativeUrl); var content = new ByteArrayContent(audioFileBytes); string contentType = ContentTypeMapping.MapContentTypeFromExtension(attachment.FileType); content.Headers.ContentType = new MediaTypeHeaderValue(contentType); content.Headers.Add("X-SpeechContext", Enum.GetName(typeof(XSpeechContext), speechContext)); string strResponse = await SendContentRequest(HttpMethod.Post, restEndPoint.ToString(), content); return(SpeechResponse.Parse(strResponse)); }
private static string CreateAttachmentPrefix(bool isFirstFile, string textContent, string fileName, string timeStampStr) { var timeStampDelimiter = "--" + timeStampStr + "\r\n"; var attachmentPrefix = new StringBuilder(); if (isFirstFile) { attachmentPrefix.Append(textContent); } attachmentPrefix.Append(timeStampDelimiter); string shortFileName = Path.GetFileName(fileName); attachmentPrefix.Append("Content-Disposition:attachment;name=\"" + shortFileName + "\"\r\n"); string contentType = ContentTypeMapping.MapContentTypeFromExtension(Path.GetExtension(fileName)); attachmentPrefix.Append("Content-Type:" + contentType + "\r\n"); attachmentPrefix.Append("Content-ID:<" + shortFileName + ">\r\n"); attachmentPrefix.Append("Content-Transfer-Encoding:binary\r\n\r\n"); return(attachmentPrefix.ToString()); }
public void Maps_Metadata() { var actual = ContentTypeMapping.Map(umbracoContentType); Assert.AreEqual(expected, actual, Serialize(actual)); }
private void DefaultContentTypes_Click(object sender, RoutedEventArgs e) { ContentTypes = new ObservableCollection <ContentTypeMapping>(ContentTypeMapping.DefaultValues()); ContentTypesGrid.ItemsSource = null; ContentTypesGrid.ItemsSource = ContentTypes; }