• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Mime.ContentType类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Net.Mime.ContentType的典型用法代码示例。如果您正苦于以下问题:C# ContentType类的具体用法?C# ContentType怎么用?C# ContentType使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ContentType类属于System.Net.Mime命名空间,在下文中一共展示了ContentType类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SupportsContentType

 public static bool SupportsContentType(ContentType contentType)
 {
     for(int i = 0; i != SupportedContentTypes.Length; ++i)
         if(SupportedContentTypes[i].Equals(contentType.MediaType))
             return true;
     return false;
 }
开发者ID:drunkcod,项目名称:Xlnt.Stuff,代码行数:7,代码来源:XmlResult.cs


示例2: Index

        public ActionResult Index()
        {
            var outParam = new SqlParameter
            {
                ParameterName = "@result",
                Direction = ParameterDirection.Output,
                SqlDbType = SqlDbType.Int
            };

            List<Boolean> _BUEvent = db.Database.SqlQuery<Boolean>("sp_InsertIntoBuEventLog @result OUT", outParam).ToList();

            using (TransactionScope transaction = new TransactionScope())
            {

                bool result = _BUEvent.FirstOrDefault();
                if (result)
                {
                    var _vwSendEmail = (db.vwSendEmails.Where(a => a.CREATEDDATE == CurrentDate).Select(a => new { a.KDKC, a.email, a.NMKC,a.TAHUN,a.BULAN,a.MINGGU })).Distinct();
                    int count = 0;
                    foreach(var sending in _vwSendEmail)
                    {
                        MemoryStream memory = new MemoryStream();
                        PdfDocument document = new PdfDocument() { Url = string.Format("http://localhost:1815/AutoMail/PreviewPage?kdkc={0}", sending.KDKC) };
                        PdfOutput output = new PdfOutput() { OutputStream = memory };

                        PdfConvert.ConvertHtmlToPdf(document, output);
                        memory.Position = 0;
                        var SubjectName = string.Format("Reminder Masa Habis PKS Badan Usaha T{0} B{1} M{2}", sending.TAHUN, sending.BULAN, sending.MINGGU);
                        var attchName = string.Format("ReminderMasaHabisPKSBadanUsahaT{0}B{1}M{2}", sending.TAHUN, sending.BULAN, sending.MINGGU);
                        ContentType ct = new ContentType(MediaTypeNames.Application.Pdf);
                        Attachment data = new Attachment(memory, ct);
                        data.Name = attchName;
                        MailMessage message = new MailMessage();
                        message.To.Add(new MailAddress(sending.email));
                        message.From = new MailAddress("[email protected]", "Legal-InHealth Reminder ");
                        message.Subject = SubjectName;
                        message.Attachments.Add(data);
                        message.Body = sending.NMKC;
                        SmtpClient client = new SmtpClient();

                        try
                        {
                            client.Send(message);
                        }
                        catch (Exception ex)
                        {

                            ViewData["SendingException"] = string.Format("Exception caught in SendErrorLog: {0}",ex.ToString());
                            return View("ErrorSending", ViewData["SendingException"]);
                        }
                        data.Dispose();
                        // Close the log file.
                        memory.Close();
                        count += 1;
                    }
                }
                transaction.Complete();
            }
            return View();
        }
开发者ID:kacrut,项目名称:Legal,代码行数:60,代码来源:AutoMailController.cs


示例3: XmlSerializationResult

        public XmlSerializationResult(object model,
                                      string contentType)
        {
            if (null == model)
            {
                throw new ArgumentNullException("model");
            }

            if (null == contentType)
            {
                throw new ArgumentNullException("contentType");
            }

            if (0 == contentType.Length)
            {
                throw new ArgumentOutOfRangeException("contentType");
            }

            ContentEncoding = Encoding.UTF8;
            ContentType = new ContentType(contentType).MediaType;

            var xml = model.XmlSerialize() as XmlDocument;
            if (null == xml)
            {
                return;
            }

            xml.CreateXmlDeclaration("1.0", "utf-8", null);
            xml.PreserveWhitespace = false;

            Content = xml.OuterXml;
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:32,代码来源:XmlSerializationResult.cs


示例4: Deserialize

 public object Deserialize(ControllerContext controllerContext, ModelBindingContext bindingContext, ContentType requestFormat)
 {
     string input = new StreamReader(controllerContext.HttpContext.Request.InputStream).ReadToEnd();
     MethodInfo deserialize = typeof(JavaScriptSerializer).GetMethod("Deserialize", new Type[] { typeof(string) });
     MethodInfo deserializeForType = deserialize.MakeGenericMethod(bindingContext.ModelType);
     return deserializeForType.Invoke(new JavaScriptSerializer(), new object[] { input });
 }
开发者ID:pruiz,项目名称:AspMvc2,代码行数:7,代码来源:JavaScriptSerializerFormatHandler.cs


示例5: SignedEntity

        /// <summary>
        /// Creates an entity from the <paramref name="parts"/> of which the first part must be the content and the second
        /// part the signature..
        /// </summary>
        /// <param name="contentType">The content type header for the new entity.</param>
        /// <param name="parts">The body parts, which must consist of two parts, of which the first must be the content and the second part the signature</param>
        public SignedEntity(ContentType contentType, IEnumerable<MimeEntity> parts)
            : base(contentType)
        {
            if (parts == null)
            {
                throw new ArgumentNullException("parts");
            }
            
            int count = 0;

            foreach(MimeEntity part in parts)
            {
                switch(count)
                {
                    default:
                        throw new SignatureException(SignatureError.InvalidSignedEntity);
                    
                    case 0:
                        Content = part;
                        break;
                    
                    case 1:
                        Signature = part;
                        break;
                }                
                ++count;
            }
        }
开发者ID:DM-TOR,项目名称:nhin-d,代码行数:34,代码来源:SignedEntity.cs


示例6: CreateAttachmentFromString

 public static Attachment CreateAttachmentFromString(string content, ContentType contentType)
 {
     Attachment attachment = new Attachment();
     attachment.SetContentFromString(content, contentType);
     attachment.Name = contentType.Name;
     return attachment;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:7,代码来源:Attachment.cs


示例7: Main

        static void Main(string[] args)
        {
            HttpWebRequest request = WebRequest.Create("https://www.baidu.com/") as HttpWebRequest;
            request.Method = "GET";
            request.AddRange("bytes", 0, 1000);
            HttpWebResponse response = request.GetResponse() as HttpWebResponse;
            ContentType content = new ContentType();
            foreach (string header in response.Headers)
            {
                Console.WriteLine("{0}:{1}", header, response.Headers[header]);
            }
            var stream = response.GetResponseStream();
            //int count = (int)response.ContentLength;
            //byte[] bytes = new byte[count];
            //stream.Read(bytes, 0, count);
            //var str = Encoding.UTF8.GetString(bytes);

            using (StreamReader reader = new StreamReader(stream))
            {
                StreamWriter writer = new StreamWriter("index.html");
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    writer.WriteLine(line);
                }
            }

            Console.WriteLine("ok");
            Console.ReadKey();
        }
开发者ID:youtao,项目名称:WebAPI-Learn,代码行数:30,代码来源:Program.cs


示例8: MessageHeader

        /// <summary>
        /// Parses a <see cref="NameValueCollection"/> to a MessageHeader
        /// </summary>
        /// <param name="headers">The collection that should be traversed and parsed</param>
        /// <returns>A valid MessageHeader object</returns>
        /// <exception cref="ArgumentNullException">If <paramref name="headers"/> is <see langword="null"/></exception>
        internal MessageHeader(NameValueCollection headers)
        {
            if (headers == null)
                throw new ArgumentNullException("headers");

            // Create empty lists as defaults. We do not like null values
            // List with an initial capacity set to zero will be replaced
            // when a corrosponding header is found
            To = new List<RfcMailAddress>(0);
            Cc = new List<RfcMailAddress>(0);
            Bcc = new List<RfcMailAddress>(0);
            Received = new List<Received>();
            Keywords = new List<string>();
            InReplyTo = new List<string>(0);
            References = new List<string>(0);
            DispositionNotificationTo = new List<RfcMailAddress>();
            UnknownHeaders = new NameValueCollection();

            // Default importancetype is Normal (assumed if not set)
            Importance = MailPriority.Normal;

            // 7BIT is the default ContentTransferEncoding (assumed if not set)
            ContentTransferEncoding = ContentTransferEncoding.SevenBit;

            // text/plain; charset=us-ascii is the default ContentType
            ContentType = new ContentType("text/plain; charset=us-ascii");

            // Now parse the actual headers
            ParseHeaders(headers);
        }
开发者ID:naingyelin,项目名称:msgreader,代码行数:36,代码来源:MessageHeader.cs


示例9: Validate

		public async Task<ValidateResult> Validate(HttpRequestBase request, HttpResponseBase response)
		{
			request.ThrowIfNull("request");
			response.ThrowIfNull("response");

			if (!String.IsNullOrEmpty(request.ContentType))
			{
				try
				{
					var contentType = new ContentType(request.ContentType);

					if (String.Equals(contentType.MediaType, "application/x-www-form-urlencoded", StringComparison.OrdinalIgnoreCase) || String.Equals(contentType.MediaType, "multipart/form-data", StringComparison.OrdinalIgnoreCase))
					{
						ValidationResult validationResult = await _antiCsrfNonceValidator.ValidateAsync(request);
						ResponseResult responseResult = await _antiCsrfResponseGenerator.GetResponseAsync(validationResult);

						if (responseResult.ResultType == ResponseResultType.ResponseGenerated)
						{
							return ValidateResult.ResponseGenerated(responseResult.Response);
						}
					}
				}
				catch (FormatException)
				{
				}
			}

			await _antiCsrfCookieManager.ConfigureCookieAsync(request, response);

			return ValidateResult.RequestValidated();
		}
开发者ID:nathan-alden,项目名称:junior-route,代码行数:31,代码来源:AntiCsrfRequestValidator.cs


示例10: MailAttachment

 public MailAttachment(ContentType contentType, string fileName, MemoryStream fileStream)
 {
     this._ContentType = contentType;
     this._FileStream = fileStream;
     this._Name = fileName;
     this._ByteArray = CommonHelper.StreamToByteArray(fileStream);
 }
开发者ID:surifoll,项目名称:git-test,代码行数:7,代码来源:Attachment.cs


示例11: NewApplication

        public ActionResult NewApplication(TestInfo testInfo)
        {
            string response = "";
            if (ModelState.IsValid)
            {
                response = new RegisterRepository().RegisterTest(testInfo);

                MailMessage message = new MailMessage();
                string username = "[email protected]";
                string password = "1ndustries";
                string receiverEmail = testInfo.StudentInfo.AddressInfo.Email;
                ContentType mimeType = new ContentType("text/html");
                AlternateView alternate = AlternateView.CreateAlternateViewFromString("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"> <html><head><META http-equiv=Content-Type content=\"text/html; charset=iso-8859-1\"></head><body><b>Dear " + testInfo.StudentInfo.FirstName + testInfo.StudentInfo.LastName + "</b>, <br /><br /><br />Greetings from IELTS !!! <br/><br/><br/> Your registration was successful. Thank You for registering IELTS Examination. <br/> <br/> <br/> Please see below the registration details <br/> <b>&nbsp;&nbsp;&nbsp;&nbsp;Your Receipt Number  :</b> " + testInfo.ReceiptNumber + ".<br /><b>&nbsp;&nbsp;&nbsp;&nbsp;Registered Date Time  :</b> " + testInfo.CreatedDate.ToString() + "<br /><br /> <b>Note: </b> Receipt Number and Passport or National Identity Card is mandatory to check your test results. <br /><br /><br /> Thank You,<br/><br/><br/> IELTS Admin</body></html>.", mimeType);
                message.From = new MailAddress(username);
                message.To.Add(receiverEmail);
                message.Subject = "IELTS Registration - Congrats, " + testInfo.StudentInfo.FirstName + " " + testInfo.StudentInfo.LastName + "!";
                //message.Body = "<html><head></head><body><b>Dear " + testInfo.StudentInfo.FirstName + testInfo.StudentInfo.LastName + "</b>, <br /><br /><br />Greetings from IELTS !!! <br/> Your registration was successful. Thank You for registering IELTS Examination. <br/> Please see below the registration details <br/> <dd /><b>Your Receipt Number  :</b> " + testInfo.ReceiptNumber + ".<br /><dd /><b>Registered Date Time  :</b> "+testInfo.CreatedDate.ToString()+"<br /><br /> <b>Note: </b> Receipt Number is mandatory to check your test results. <br /><br /><br /> Thank You, IELTS Admin</body></html>.";
                message.AlternateViews.Add(alternate);
                message.IsBodyHtml = true;
                message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
                SmtpClient smtpClient = new SmtpClient("smtp.gmail.com", 587);
                smtpClient.EnableSsl = true;
                smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
                smtpClient.UseDefaultCredentials = false;
                smtpClient.Credentials = new NetworkCredential(username, password);
                smtpClient.Send(message);
                RedirectToAction("SubmitApplicationForm");
            }
            return View(testInfo);
        }
开发者ID:rodrigodemingo,项目名称:IELTS,代码行数:30,代码来源:RegisterTestController.cs


示例12: HTTPHeader

 public HTTPHeader()
 {
     Headers = new NameValueCollection();
     ContentType = new System.Net.Mime.ContentType(MediaTypeNames.Text.Html);
     CacheControl = "no-cache";
     _ContentLength = 0;
 }
开发者ID:anukat2015,项目名称:sones,代码行数:7,代码来源:HTTPHeader.cs


示例13: ButtonSendClick

        private void ButtonSendClick(object sender, RoutedEventArgs e)
        {
            var teacherChoice = new TeacherChoice
                                    {
                                        Alternatives = GridDays.Children
                                            .OfType<RadioButton>()
                                            .Where(l => l.IsChecked.HasValue)
                                            .Select(l => l.DataContext)
                                            .Cast<Alternative>().ToList(),

                                        Email = Email,
                                        Name = FullName,
                                    };

            Options.IsEnabled = false;
            busyIndicator.IsBusy = true;

            var client = new SmtpClient("smtp.gmail.com", 587)
                             {
                                 Credentials = new NetworkCredential("[email protected]", "admin123."),
                                 EnableSsl = true,
                             };

            var contentType = new ContentType("text/xml") { Name = "teacherChoice.xml" };
            var xmlAttachment = Attachment.CreateAttachmentFromString(teacherChoice.Serialize(), contentType);
            var mail = new MailMessage("[email protected]", "[email protected]")
                           {
                               Subject = "Teste",
                           };
            mail.Attachments.Add(xmlAttachment);

            client.SendCompleted += ClientSendCompleted;
            client.SendAsync(mail, Token);
        }
开发者ID:jimyy,项目名称:school-survey-timetabling,代码行数:34,代码来源:MainWindow.xaml.cs


示例14: AttachmentBase

		protected AttachmentBase (string fileName)
		{
			if (fileName == null)
				throw new ArgumentNullException ();
			contentStream = File.OpenRead (fileName);
			contentType = new ContentType (MimeTypes.GetMimeType (fileName));
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:7,代码来源:AttachmentBase.cs


示例15: SendInstantMessageAsync

 public static Task<SendInstantMessageResult> SendInstantMessageAsync(this 
     InstantMessagingFlow flow, ContentType contentType, 
     byte[] body)
 {
     return Task<SendInstantMessageResult>.Factory.FromAsync(flow.BeginSendInstantMessage,
         flow.EndSendInstantMessage, contentType, body, null);
 }
开发者ID:juancarlosbaezpozos,项目名称:UCMA-IVR-Demo,代码行数:7,代码来源:InstantMessagingFlowMethods.cs


示例16: Content

 public Content(int id, string source, string description, ContentType contentType)
     : base(id)
 {
     Source = source;
     Description = description;
     ContentType = contentType;
 }
开发者ID:JoshuaKaminsky,项目名称:BaseMvc,代码行数:7,代码来源:Content.cs


示例17: op_ToContentType_EncodingNull_string

        public void op_ToContentType_EncodingNull_string()
        {
            var expected = new ContentType("text/example");
            var actual = (null as Encoding).ToContentType("text/example");

            Assert.Equal(expected, actual);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:7,代码来源:Encoding.ExtensionMethods.Facts.cs


示例18: op_ToContentType_Encoding_string

        public void op_ToContentType_Encoding_string()
        {
            var expected = new ContentType("text/example; charset=utf-8");
            var actual = Encoding.UTF8.ToContentType("text/example");

            Assert.Equal(expected, actual);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:7,代码来源:Encoding.ExtensionMethods.Facts.cs


示例19: op_ToContentType_EncodingDefault_string

        public void op_ToContentType_EncodingDefault_string()
        {
            var expected = new ContentType("text/example; charset=Windows-1252");
            var actual = Encoding.Default.ToContentType("text/example");

            Assert.Equal(expected, actual);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:7,代码来源:Encoding.ExtensionMethods.Facts.cs


示例20: DataWebRequest

 internal DataWebRequest(Uri uri, Byte[] data, ContentType contentType)
 {
     //only called internally (from factory) so we trust the params to be valid
     this.uri = uri;
     this.data = data;
     this.contentType = contentType;
 }
开发者ID:jalsco,项目名称:growl-for-windows-branched,代码行数:7,代码来源:DataWebRequest.cs



注:本文中的System.Net.Mime.ContentType类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# NetworkInformation.NetworkInterface类代码示例发布时间:2022-05-26
下一篇:
C# Mime.ContentDisposition类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap