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

C# Dream.MimeType类代码示例

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

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



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

示例1: SendNoticeToAdmin

        public static void SendNoticeToAdmin(string subject, string content, MimeType mime) {

            UserBE adminUser = UserBL.GetAdmin(); ;

            if (adminUser == null) {
                throw new DreamAbortException(DreamMessage.InternalError(DekiResources.CANNOT_RETRIEVE_ADMIN_ACCOUNT));
            }
            
            string smtphost = string.Empty;
            int smtpport = 0;

            if (smtphost == string.Empty)
                throw new DreamAbortException(DreamMessage.Conflict(DekiResources.SMTP_SERVER_NOT_CONFIGURED));


            if (string.IsNullOrEmpty(adminUser.Email))
                throw new DreamAbortException(DreamMessage.Conflict(DekiResources.ADMIN_EMAIL_NOT_SET));

            System.Net.Mail.SmtpClient smtpclient = new System.Net.Mail.SmtpClient();
            System.Net.Mail.MailMessage msg = new System.Net.Mail.MailMessage();
            msg.To.Add(adminUser.Email);
            msg.From = new System.Net.Mail.MailAddress(DekiContext.Current.User.Email, DekiContext.Current.User.Name);
            msg.Subject = DekiContext.Current.Instance.SiteName + ": " + subject;
            msg.Body = content;

            smtpclient.Host = smtphost;
            if (smtpport != 0)
                smtpclient.Port = smtpport;

            smtpclient.Send(msg);
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:31,代码来源:SiteBL.cs


示例2: SendNoticeToAdmin

        //--- Methods ---
        public void SendNoticeToAdmin(string subject, string content, MimeType mime) {

            // TODO (arnec): should this be using the email service?
            UserBE adminUser = UserBL.GetAdmin();
            if(adminUser == null) {
                throw new SiteNoAdminFatalException();
            }
            string smtphost = string.Empty;
            int smtpport = 0;
            if(smtphost == string.Empty) {
                throw new SiteConflictException(DekiResources.SMTP_SERVER_NOT_CONFIGURED());
            }
            if(string.IsNullOrEmpty(adminUser.Email)) {
                throw new SiteConflictException(DekiResources.ADMIN_EMAIL_NOT_SET());
            }
            var smtpclient = new SmtpClient();
            var msg = new MailMessage();
            msg.To.Add(adminUser.Email);
            msg.From = new MailAddress(_user.Email, _user.Name);
            msg.Subject = _dekiInstance.SiteName + ": " + subject;
            msg.Body = content;
            smtpclient.Host = smtphost;
            if(smtpport != 0) {
                smtpclient.Port = smtpport;
            }
            smtpclient.Send(msg);
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:28,代码来源:SiteBL.cs


示例3: ResourceContentBE

 public ResourceContentBE(string value, MimeType mimeType)
     : this(true) {
     if(value == null) {
         throw new ArgumentNullException("value");
     }
     if(mimeType == null) {
         throw new ArgumentNullException("mimeType");
     }
     _mimeType = mimeType;
     _stream = new ChunkedMemoryStream();
     _stream.Write(mimeType.CharSet, value);
     _size = (uint)_stream.Length;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:13,代码来源:ResourceContentBE.cs


示例4: AddAttachment

        /* =========================================================================
         * Asynchronous methods
         * =======================================================================*/
        /// <summary>
        /// <para>Adds an attachment to a document. The document revision must be 
        /// specified when using this method.</para>
        /// <para>(This method is asynchronous.)</para>
        /// </summary>
        /// <param name="id">ID of the CouchDB document.</param>
        /// <param name="rev">Revision of the CouchDB document.</param>
        /// <param name="attachment">Stream of the attachment. Will be closed once
        /// the request is sent.</param>
        /// <param name="attachmentLength">Length of the attachment stream.</param>
        /// <param name="fileName">Filename of the attachment.</param>
        /// <param name="contentType">Content type of the document.</param>
        /// <param name="result"></param>
        /// <returns></returns>
        public Result<JObject> AddAttachment(
      string id, 
      string rev, 
      Stream attachment, 
      long attachmentLength, 
      string fileName, 
      MimeType contentType, 
      Result<JObject> result)
        {
            if (String.IsNullOrEmpty(id))
            throw new ArgumentNullException("id");
              if (String.IsNullOrEmpty(rev))
            throw new ArgumentNullException("rev");
              if (attachment == null)
            throw new ArgumentNullException("attachment");
              if (attachmentLength < 0)
            throw new ArgumentOutOfRangeException("attachmentLength");
              if (String.IsNullOrEmpty(fileName))
            throw new ArgumentNullException("fileName");
              if (contentType == null)
            throw new ArgumentNullException("contentType");
              if (result == null)
            throw new ArgumentNullException("result");

              BasePlug
            .AtPath(XUri.EncodeFragment(id))
            .At(XUri.EncodeFragment(fileName))
            .With(Constants.REV, rev)
            .Put(DreamMessage.Ok(contentType, attachmentLength, attachment),
             new Result<DreamMessage>())
            .WhenDone(
              a =>
              {
            if (a.Status == DreamStatus.Created)
              result.Return(JObject.Parse(a.ToText()));
            else
              result.Throw(new CouchException(a));
              },
              result.Throw
            );

              return result;
        }
开发者ID:jvdgeest,项目名称:chesterfield,代码行数:60,代码来源:CouchDatabase.Attachments.cs


示例5: StreamInfo

 public StreamInfo(Stream stream, long size, MimeType type, DateTime? modified) {
     if(stream == null) {
         throw new ArgumentNullException("stream");
     }
     this.Stream = stream;
     this.Length = size;
     this.Type = type ?? MimeType.BINARY;
     this.Modified = modified;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:9,代码来源:types.cs


示例6: BuildRevForContentUpdate

 public virtual ResourceBE BuildRevForContentUpdate(ResourceBE currentResource, MimeType mimeType, uint size, string description, string name, ResourceContentBE newContent) {
     ResourceBE newRev = BuildRevForExistingResource(currentResource, mimeType, size, description);
     newRev.Content = newContent;
     newRev.ContentId = 0;
     newRev.ChangeMask |= ResourceBE.ChangeOperations.CONTENT;
     if(name != null && !StringUtil.EqualsInvariant(name, newRev.Name)) {
         newRev.ChangeMask |= ResourceBE.ChangeOperations.NAME;
         newRev.Name = name;
     }
     return newRev;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:11,代码来源:ResourceBL.cs


示例7: BuildRevForNewResource

 private ResourceBE BuildRevForNewResource(string resourcename, MimeType mimeType, uint size, string description, ResourceBE.Type resourceType, uint userId, ResourceContentBE content) {
     ResourceBE newResource = new ResourceBE(resourceType);
     newResource.Name = resourcename;
     newResource.ChangeMask = newResource.ChangeMask | ResourceBE.ChangeOperations.NAME;
     newResource.Size = size;
     newResource.MimeType = mimeType;
     newResource.ChangeDescription = description;
     newResource.ResourceCreateUserId = newResource.ResourceUpdateUserId = newResource.UserId = userId;
     newResource.ChangeSetId = 0;
     newResource.Timestamp = newResource.ResourceCreateTimestamp = newResource.ResourceUpdateTimestamp = DateTime.UtcNow;
     newResource.Content = content;
     newResource.ChangeMask = newResource.ChangeMask | ResourceBE.ChangeOperations.CONTENT;
     newResource.ResourceHeadRevision = ResourceBE.TAILREVISION;
     newResource.Revision = ResourceBE.TAILREVISION;
     newResource.IsHidden = false;
     return newResource;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:17,代码来源:ResourceBL.cs


示例8: GetFileInternal

        private StreamInfo GetFileInternal(string filename, MimeType type, bool allowFileLink) {

            if(allowFileLink && _allowRedirects) {
                return new StreamInfo(BuildS3Uri(Verb.GET, _s3.AtPath(filename), _redirectTimeout));
            }

            // check if file is cached
            var entry = GetCachedEntry(filename);
            if(entry != null) {
                Stream filestream = File.Open(entry.Item1, FileMode.Open, FileAccess.Read, FileShare.Read);
                return new StreamInfo(filestream, filestream.Length, type, entry.Item3);
            }

            // get file from S3
            var result = new Result<DreamMessage>();
            _s3.AtPath(filename).InvokeEx(Verb.GET, DreamMessage.Ok(), result);
            var response = result.Wait();
            try {
                if(response.IsSuccessful) {
                    return new StreamInfo(response.AsStream(), response.ContentLength, response.ContentType, GetLastModifiedTimestampFromResponse(response));
                }
                if(response.Status == DreamStatus.NotFound) {
                    response.Close();
                    return null;
                }
                throw new DreamInternalErrorException(string.Format("S3 unable to fetch file (status {0}, message {1})", response.Status, response.AsText()));
            } catch {
                if(response != null) {
                    response.Close();
                }
                throw;
            }
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:33,代码来源:S3Storage.cs


示例9: From

 /// <summary>
 /// Create a document from a text reader.
 /// </summary>
 /// <param name="reader">Document text reader.</param>
 /// <param name="mime">Document mime-type.</param>
 /// <returns>New document instance.</returns>
 public static XDoc From(TextReader reader, MimeType mime)
 {
     if(reader == null) {
         throw new ArgumentNullException("reader");
     }
     if(mime == null) {
         throw new ArgumentNullException("mime");
     }
     if(mime.Match(MimeType.VCAL)) {
         return VersitUtil.FromVersit(reader, "vcal");
     }
     if(mime.Match(MimeType.VERSIT)) {
         return VersitUtil.FromVersit(reader, "vcard");
     }
     if(mime.Match(MimeType.HTML)) {
         return FromHtml(reader);
     }
     if(mime.IsXml) {
         return FromXml(reader);
     }
     if(mime.Match(MimeType.FORM_URLENCODED)) {
         return XPostUtil.FromXPathValuePairs(XUri.ParseParamsAsPairs(reader.ReadToEnd()), "form");
     }
     throw new ArgumentException("unsupported mime-type: " + mime.FullType, "mime");
 }
开发者ID:yurigorokhov,项目名称:DReAM,代码行数:31,代码来源:XDocFactory.cs


示例10: GetResoucePlug

        private Plug GetResoucePlug(string graph, string app, string format, MimeType mime) {
            string hash = StringUtil.ComputeHashString(graph);
            string key = string.Format("{0}.{1}.{2}", hash, Path.GetFileNameWithoutExtension(app), format);
            Plug location = Storage.At(key);

            // check if the target resource needs to be generated
            if(!location.InvokeAsync("HEAD", DreamMessage.Ok()).Wait().IsSuccessful) {
                Stream data;
                using(Stream input = new MemoryStream(Encoding.UTF8.GetBytes(graph))) {

                    // execute process
                    Stream output;
                    Stream error;
                    Tuplet<int, Stream, Stream> exitValues = Async.ExecuteProcess(app, "-T" + format, input, new Result<Tuplet<int, Stream, Stream>>(TimeSpan.FromSeconds(30))).Wait();
                    int status = exitValues.Item1;
                    using(output = exitValues.Item2) {
                        using(error = exitValues.Item3) {
                            if(status != 0) {
                                string message;
                                using(StreamReader reader = new StreamReader(error, Encoding.ASCII)) {
                                    message = reader.ReadToEnd();
                                }
                                throw new DreamInternalErrorException(string.Format("graphviz failed with status {0}:\n{1}", status, message));
                            }
                            data = output.ToChunkedMemoryStream(-1, new Result<ChunkedMemoryStream>()).Wait();
                        }
                    }
                }

                // create result
                location.With("ttl", TimeSpan.FromDays(7).TotalSeconds).Put(DreamMessage.Ok(mime, data.Length, data));
            }
            return Self.At("images", key);
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:34,代码来源:GraphvizService.cs


示例11: ValidateCommentText

 private static void ValidateCommentText(MimeType mimetype, string content) {
     if (!MimeType.TEXT.Match(mimetype))
         throw new DreamBadRequestException(string.Format(DekiResources.COMMENT_MIMETYPE_UNSUPPORTED, mimetype.ToString(), MimeType.HTML.ToString(), MimeType.TEXT.ToString()));
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:4,代码来源:CommentBL.cs


示例12: From

 /// <summary>
 /// Create a document from a stream.
 /// </summary>
 /// <param name="stream">Document stream.</param>
 /// <param name="mime">Document mime-type.</param>
 /// <param name="detectEncoding">Detect character encoding in stream.</param>
 /// <returns>New document instance.</returns>
 public static XDoc From(Stream stream, MimeType mime, bool detectEncoding)
 {
     if(stream == null) {
         throw new ArgumentNullException("stream");
     }
     if(mime == null) {
         throw new ArgumentNullException("mime");
     }
     if(!stream.CanSeek && !(stream is BufferedStream)) {
         stream = new BufferedStream(stream);
     }
     var encoding = detectEncoding ? stream.DetectEncoding() : mime.CharSet;
     using(TextReader reader = new StreamReader(stream, encoding ?? mime.CharSet)) {
         return From(reader, mime);
     }
 }
开发者ID:nataren,项目名称:DReAM,代码行数:23,代码来源:XDocFactory.cs


示例13: TryParse

 /// <summary>
 /// Try to parse a mime-type from a content-type string.
 /// </summary>
 /// <param name="contentTypeWithParameters">Content type string.</param>
 /// <param name="result">Mime-type instance return value.</param>
 /// <returns><see langword="True"/> if a mime-type could be parsed.</returns>
 public static bool TryParse(string contentTypeWithParameters, out MimeType result)
 {
     string type;
     string subtype;
     Dictionary<string, string> parameters;
     if(!TryParse(contentTypeWithParameters, out type, out subtype, out parameters)) {
         result = null;
         return false;
     }
     result = new MimeType(type, subtype, parameters);
     return true;
 }
开发者ID:nataren,项目名称:DReAM,代码行数:18,代码来源:mimetype.cs


示例14: Match

        //--- Methods ---
        /// <summary>
        /// Try to match instance against another instance.
        /// </summary>
        /// <param name="other">Other mime-type.</param>
        /// <returns><see langword="True"/> if the two types match.</returns>
        public bool Match(MimeType other)
        {
            // match main type
            if((MainType != "*") && (other.MainType != "*") && (MainType != other.MainType)) {
                return false;
            }

            // match subtype
            if((SubType != "*") && (other.SubType != "*") && (SubType != other.SubType)) {
                return false;
            }
            return true;
        }
开发者ID:nataren,项目名称:DReAM,代码行数:19,代码来源:mimetype.cs


示例15: AddLink

 /// <summary>
 /// Add a link to the document.
 /// </summary>
 /// <param name="href">Uri to the linked resource.</param>
 /// <param name="relation">Relationship of the linked resource to the current document.</param>
 /// <param name="type">Type of resource being linked.</param>
 /// <param name="length">Size in bytes.</param>
 /// <param name="title">Title of the linked resource.</param>
 /// <returns>Returns the current document instance.</returns>
 public XAtomBase AddLink(XUri href, LinkRelation relation, MimeType type, long? length, string title)
 {
     Start("link");
     Attr("href", href);
     Attr("rel", relation.ToString().ToLowerInvariant());
     if(type != null) {
         Attr("type", type.FullType);
     }
     if(length != null) {
         Attr("length", length ?? 0);
     }
     if(!string.IsNullOrEmpty(title)) {
         Attr("title", title);
     }
     End();
     return this;
 }
开发者ID:sdether,项目名称:DReAM,代码行数:26,代码来源:XAtom.cs


示例16: AddText

 /// <summary>
 /// Add text to the document.
 /// </summary>
 /// <param name="tag">Enclosing tag for the text.</param>
 /// <param name="mime">Mime type of the enclosed text.</param>
 /// <param name="data">The text body as a byte array.</param>
 /// <returns>Returns the current document instance.</returns>
 public XAtomBase AddText(string tag, MimeType mime, byte[] data)
 {
     Start(tag).Attr("type", mime.FullType).Value(data).End();
     return this;
 }
开发者ID:sdether,项目名称:DReAM,代码行数:12,代码来源:XAtom.cs


示例17: LoadFrom

 //--- Class Methods ---
 /// <summary>
 /// Load a document from a file.
 /// </summary>
 /// <param name="filename">Path to document.</param>
 /// <param name="mime">Document mime-type.</param>
 /// <returns>New document instance.</returns>
 public static XDoc LoadFrom(string filename, MimeType mime)
 {
     if(string.IsNullOrEmpty(filename)) {
         throw new ArgumentNullException("filename");
     }
     if(mime == null) {
         throw new ArgumentNullException("mime");
     }
     using(TextReader reader = new StreamReader(filename, mime.CharSet, true)) {
         return From(reader, mime);
     }
 }
开发者ID:yurigorokhov,项目名称:DReAM,代码行数:19,代码来源:XDocFactory.cs


示例18: AddContent

 /// <summary>
 /// Add a subdocument as content to the entry.
 /// </summary>
 /// <param name="mime">Mime type of the document to be added.</param>
 /// <param name="xml">Document to add.</param>
 /// <returns>Returns the current document instance.</returns>
 public XAtomEntry AddContent(MimeType mime, XDoc xml)
 {
     AddText("content", mime, xml);
     return this;
 }
开发者ID:sdether,项目名称:DReAM,代码行数:11,代码来源:XAtom.cs


示例19: BuildRevForExistingResource

 private ResourceBE BuildRevForExistingResource(ResourceBE currentResource, MimeType mimeType, uint size, string description) {
     ResourceBE newRev = BuildResourceRev(currentResource);
     newRev.MimeType = mimeType;
     newRev.Size = size;
     newRev.ChangeDescription = description;
     newRev.Content = currentResource.Content;
     newRev.ContentId = currentResource.ContentId;
     return newRev;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:9,代码来源:ResourceBL.cs


示例20: AddSummary

 /// <summary>
 /// Add an entry summary document.
 /// </summary>
 /// <param name="mime">Mime type of the summary document to be added.</param>
 /// <param name="xml">Summary document.</param>
 /// <returns>Returns the current document instance.</returns>
 public XAtomEntry AddSummary(MimeType mime, XDoc xml)
 {
     AddText("summary", mime, xml);
     return this;
 }
开发者ID:sdether,项目名称:DReAM,代码行数:11,代码来源:XAtom.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Dream.Plug类代码示例发布时间:2022-05-26
下一篇:
C# Dream.DreamMessage类代码示例发布时间: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