当前位置: 首页>>代码示例>>C#>>正文


C# MimeType.Match方法代码示例

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


在下文中一共展示了MimeType.Match方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AppendDiff


//.........这里部分代码省略.........
                        diffXml.Start("hr").Attr("width", "100%").Attr("size", "2").End();
                        diffXml.AddNodes(diff);
                        diffXml.Start("hr").Attr("width", "100%").Attr("size", "2").End();

                        // check if there are invisible changes as well to show
                        if(!invisibleDiff.IsEmpty) {
                            diffXml.Start("p").Elem("strong", resources.Localize(DekiResources.PAGE_DIFF_OTHER_CHANGES())).End();
                            diffXml.Add(invisibleDiff);
                        }
                    } else if(!invisibleDiff.IsEmpty) {

                        // only show invisible changes
                        diffXml.Start("hr").Attr("width", "100%").Attr("size", "2").End();
                        diffXml.Start("p").Elem("strong", resources.Localize(DekiResources.PAGE_DIFF_OTHER_CHANGES())).End();
                        diffXml.Add(invisibleDiff);
                    } else if(beforeDoc.IsEmpty && afterDoc.IsEmpty) {

                        // show message that page contents were not available anymore
                        diffXml.Elem("p", resources.Localize(DekiResources.PAGE_NOT_AVAILABLE()));
                    }
                    diffXml.End();

                    // store diff in cache
                    if(diffCacheEnabled && !afterDoc.IsEmpty) {
                        store.With("ttl", TimeSpan.FromDays(30).TotalSeconds).Put(diffXml, new Result<DreamMessage>(TimeSpan.MaxValue)).Block();
                    }
                }
                body.AddNodes(diffXml);
            }

            // check if we have a comment text
            if(Utils.IsPageComment(type)) {
                string text = change.CmntContent;
                if(!string.IsNullOrEmpty(text) && !change.CmntDeleted) {
                    MimeType mime = new MimeType(change.CmntMimetype ?? MimeType.TEXT_UTF8.ToString());
                    if(mime.Match(MimeType.HTML)) {
                        XDoc html = XDocFactory.From(string.Format("<html><body>{0}</body></html>", text), MimeType.HTML);
                        body.Start("blockquote").AddNodes(html["body"]).End();
                    } else {

                        // anything else should be consider to be text
                        body.Start("blockquote").Elem("p", text).End();
                    }
                } else {

                    // anything else should be consider to be text
                    body.Start("blockquote").Elem("p", resources.Localize(DekiResources.COMMENT_NOT_AVAILABLE())).End();
                }
            }

            // adds links
            body.Start("table").Attr("border", 0).Attr("padding", "5").Attr("width", "80%").Start("tr");

            // add link for viewing the page
            if(change.PageExists) {
                Title view = new Title(title);
                body.Start("td").Start("a").Attr("href", Utils.AsPublicUiUri(view, true)).Value(resources.Localize(DekiResources.VIEW_PAGE())).End().End();
            }

            // check if we need to add link for editing the page
            if(after.HasValue && before.HasValue && (after != before)) {
                Title edit = new Title(title) { Query = "action=edit" };
                body.Start("td").Start("a").Attr("href", Utils.AsPublicUiUri(edit)).Value(resources.Localize(DekiResources.EDIT_PAGE())).End().End();
            }

            // check if we need to add link for viewing the complete diff
            if(after.HasValue && before.HasValue && (after != before)) {
                Title show = new Title(title) { Query = string.Format("diff={0}&revision={1}", after.Value, before.Value) };
                body.Start("td").Start("a").Attr("href", Utils.AsPublicUiUri(show, true)).Value(resources.Localize(DekiResources.VIEW_PAGE_DIFF())).End().End();
            }

            // check if we need to add link for seeing full page history
            if(after.HasValue && before.HasValue && (after != before)) {
                Title history = new Title(title) { Query = "action=history" };
                body.Start("td").Start("a").Attr("href", Utils.AsPublicUiUri(history)).Value(resources.Localize(DekiResources.VIEW_PAGE_HISTORY())).End().End();
            }

            // check if we need to add link for banning the user
            List<KeyValuePair<string, string>> authors = change.SortedAuthors;
            if((authors == null) || (authors.Count == 0)) {
                authors = new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>(change.Username, change.Fullname) };
            }
            for(int i = 0; i < authors.Count; ++i) {
                string username = authors[i].Key;
                string fullname = authors[i].Value;
                if(!string.IsNullOrEmpty(username)) {

                    // don't put up ban link for admins.
                    UserBE user = DbUtils.CurrentSession.Users_GetByName(username);
                    if(!UserBL.IsAnonymous(user) && !PermissionsBL.IsUserAllowed(user, Permissions.ADMIN)) {
                        Title ban = Title.FromUIUri(null, "Special:Userban");
                        ban.Query += string.Format("username={0}", username);
                        body.Start("td").Start("a").Attr("href", Utils.AsPublicUiUri(ban)).Value(resources.Localize(DekiResources.BAN_USER(string.IsNullOrEmpty(fullname) ? username : fullname))).End().End();
                    }
                }
            }

            // close HTML
            body.End().End();
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:101,代码来源:DekiWiki-News.cs

示例2: 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

示例3: ResolvePreviewFormat

        /// <summary>
        /// Given the mimetype of an original file, return the formattype for the preview images to be used by imagemagick
        /// </summary>
        /// <param name="mime"></param>
        /// <returns></returns>
        private static FormatType ResolvePreviewFormat(MimeType mime) {
            if(mime.Match(MimeType.JPEG) || mime.Match(new MimeType("image/x-jpeg"))) {
                return FormatType.JPG;
            }

            if(mime.Match(MimeType.PNG) || mime.Match(new MimeType("image/x-png"))) {
                return FormatType.PNG;
            }

            if(mime.Match(MimeType.BMP) || mime.Match(new MimeType("image/x-bmp"))) {
                return FormatType.BMP;
            }

            if(mime.Match(MimeType.GIF) || mime.Match(new MimeType("image/x-gif"))) {
                return FormatType.GIF;
            }

            return FormatType.JPG;
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:24,代码来源:AttachmentPreviewBL.cs

示例4: 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="xml">The body document to add.</param>
        /// <returns>Returns the current document instance.</returns>
        public XAtomBase AddText(string tag, MimeType mime, XDoc xml)
        {
            if(mime.Match(MimeType.XHTML)) {
                Start(tag).Attr("type", "xhtml");

                // add content and normalize the root node
                XDoc added = xml.Clone().Rename("div");
                if(added["@xmlns"].IsEmpty) {
                    added.Attr("xmlns", "http://www.w3.org/1999/xhtml");
                }
                Add(added);
            } else if(mime.Match(MimeType.HTML)) {
                Start(tag).Attr("type", "html");

                // embed HTML as text
                Value(xml.ToInnerXHtml());
            } else {
                Start(tag).Attr("type", mime.FullType);
                Add(xml);
            }

            // close element
            End();
            return this;
        }
开发者ID:sdether,项目名称:DReAM,代码行数:32,代码来源:XAtom.cs

示例5: MimeTypeCanBeInlined

 public bool MimeTypeCanBeInlined(MimeType mimeType) {
     if(_inlineDispositionBlacklist == null) {
         string[] blackliststrings = ConfigBL.GetInstanceSettingsValue("files/blacklisted-disposition-mimetypes", string.Empty).ToLowerInvariant().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
         List<MimeType> blacklist = new List<MimeType>();
         foreach(string v in blackliststrings) {
             MimeType mt = MimeType.New(v);
             if(mt != null) {
                 blacklist.Add(mt);
             }
         }
         string[] whiteliststrings = ConfigBL.GetInstanceSettingsValue("files/whitelisted-disposition-mimetypes", string.Empty).ToLowerInvariant().Split(new char[] { ',', ' ' }, StringSplitOptions.RemoveEmptyEntries);
         List<MimeType> whitelist = new List<MimeType>();
         foreach(string v in whiteliststrings) {
             MimeType mt = MimeType.New(v);
             if(mt != null) {
                 whitelist.Add(mt);
             }
         }
         _inlineDispositionBlacklist = blacklist;
         _inlineDispositionWhitelist = whitelist;
     }
     foreach(MimeType bad in _inlineDispositionBlacklist) {
         if(mimeType.Match(bad)) {
             return false;
         }
     }
     foreach(MimeType good in _inlineDispositionWhitelist) {
         if(mimeType.Match(good)) {
             return true;
         }
     }
     return false;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:33,代码来源:DekiInstance.cs


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