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


C# Dream.DreamMessage类代码示例

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


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

示例1: GetPageRating

 public Yield GetPageRating(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     UserBE user = DekiContext.Current.User;
     PageBE page = PageBL.AuthorizePage(user, Permissions.READ, false);
     XDoc ret = RatingBL.GetRatingXml(page, user);
     response.Return(DreamMessage.Ok(ret));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Ratings.cs

示例2: Authenticate

        protected user Authenticate(DreamContext context, DreamMessage request, DekiUserLevel level) {
            user result = null;

            // get username and password
            string user;
            string password;
            if (!DreamUtil.GetAuthentication(context, request, out user, out password)) {

                // anonymous access is always granted
                if (level == DekiUserLevel.Anonymous) {

                    // TODO (steveb): missing code
                    throw new NotImplementedException("return anonymous user");
                } else {
                    throw new DreamAbortException(DreamMessage.AccessDenied(AuthenticationRealm, "authentication failed"));
                }
            }

            // validate username and password
            result = MindTouch.Deki.user.GetUserByName(user);
            if (result == null) {
                throw new DreamAbortException(DreamMessage.AccessDenied(AuthenticationRealm, "authentication failed"));
            }
            if (!result.checkPassword(password)) {
                throw new DreamAbortException(DreamMessage.AccessDenied(AuthenticationRealm, "authentication failed"));
            }
            if ((level == DekiUserLevel.Admin) && !result.isSysop()) {
                throw new DreamAbortException(DreamMessage.AccessDenied(AuthenticationRealm, "authentication failed"));
            }
            return result;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:31,代码来源:DekiWikiBaseService.cs

示例3: PostBans

 public Yield PostBans(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
     BanBE ban = BanningBL.SaveBan(request.ToDocument());
     DekiContext.Current.Instance.EventSink.BanCreated(context.StartTime, ban);
     response.Return(DreamMessage.Ok(BanningBL.GetBanXml(ban)));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Banning.cs

示例4: CallbackHandler

 //--- Methods ---
 private void CallbackHandler(Plug plug, string verb, XUri uri, DreamMessage request, Result<DreamMessage> response) {
     if(uri.Segments.Length == 0) {
         response.Return(DreamMessage.Ok());
         return;
     }
     var segments = uri.Segments;
     var wikiId = segments[0];
     if(wikiId.StartsWith("=")) {
         var id = (HostLookupOverride == null) ? DefaultWikiId : HostLookupOverride(wikiId.Substring(1));
         response.Return(DreamMessage.Ok(new XDoc("wiki").Attr("id", id)));
         return;
     }
     if(segments.Length == 2 && segments[1] == "license") {
         XDoc license;
         if(LicenseOverride == null) {
             _log.Debug("returning license from disk");
             license = XDocFactory.LoadFrom(Utils.Settings.LicensePath, MimeType.TEXT_XML);
         } else {
             _log.Debug("returning license from override callback");
             license = LicenseOverride(wikiId);
         }
         response.Return(DreamMessage.Ok(license));
         return;
     }
     var config = (ConfigOverride == null) ? DefaultConfig : ConfigOverride(wikiId);
     response.Return(DreamMessage.Ok(config));
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:28,代码来源:RemoteInstanceService.cs

示例5: SubscribeToChange

 public Yield SubscribeToChange(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     uint pageId = context.GetParam<uint>("pageid");
     string depth = context.GetParam("depth", "0");
     Result<UserInfo> userResult;
     yield return userResult = Coroutine.Invoke(GetUserInfo, true, request, new Result<UserInfo>()).Catch();
     if(userResult.HasException) {
         ReturnUserError(userResult.Exception, response);
         yield break;
     }
     UserInfo userInfo = userResult.Value;
     DreamMessage pageAuth = null;
     yield return _deki
         .At("pages", pageId.ToString(), "allowed")
         .With("permissions", "read,subscribe")
         .WithHeaders(request.Headers)
         .Post(new XDoc("users").Start("user").Attr("id", userInfo.Id).End(), new Result<DreamMessage>())
         .Set(x => pageAuth = x);
     if(!pageAuth.IsSuccessful || pageAuth.ToDocument()["user/@id"].AsText != userInfo.Id.ToString()) {
         throw new DreamForbiddenException("User not permitted to subscribe to page");
     }
     userInfo.AddResource(pageId, depth);
     userInfo.Save();
     response.Return(DreamMessage.Ok());
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:25,代码来源:DekiChangeSubscriptionService.cs

示例6: GetTags

        public Yield GetTags(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
            string type = DreamContext.Current.GetParam("type", "");
            string fromStr = DreamContext.Current.GetParam("from", "");
            string toStr = DreamContext.Current.GetParam("to", "");
            bool showPages = DreamContext.Current.GetParam("pages", false);
            string partialName = DreamContext.Current.GetParam("q", "");

            // parse type
            TagType tagType = TagType.ALL;
            if(!string.IsNullOrEmpty(type) && !SysUtil.TryParseEnum(type, out tagType)) {
                throw new DreamBadRequestException("Invalid type parameter");
            }

            // check and validate from date
            DateTime from = (tagType == TagType.DATE) ? DateTime.Now : DateTime.MinValue;
            if(!string.IsNullOrEmpty(fromStr) && !DateTime.TryParse(fromStr, out from)) {
                throw new DreamBadRequestException("Invalid from date parameter");
            }

            // check and validate to date
            DateTime to = (tagType == TagType.DATE) ? from.AddDays(30) : DateTime.MaxValue;
            if(!string.IsNullOrEmpty(toStr) && !DateTime.TryParse(toStr, out to)) {
                throw new DreamBadRequestException("Invalid to date parameter");
            }

            // execute query
            var tags = TagBL.GetTags(partialName, tagType, from, to);
            XDoc doc = TagBL.GetTagListXml(tags, "tags", null, showPages);
            response.Return(DreamMessage.Ok(doc));
            yield break;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:31,代码来源:DekiWiki-Tags.cs

示例7: GetGroup

 public Yield GetGroup(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.READ);
     GroupBE group = GetGroupFromUrl();
     DreamMessage responseMsg = DreamMessage.Ok(GroupBL.GetGroupXmlVerbose(group, null));
     response.Return(responseMsg);
     yield break;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:7,代码来源:DekiWiki-Groups.cs

示例8: Register

        public Yield Register(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
            string servicePath = context.GetParam("service-path");
            string location = StringUtil.CreateAlphaNumericKey(8);

            // register the script
            XDoc config = new XDoc("config")
                .Elem("manifest", servicePath)
                .Elem("debug", true);

            //create the script service
            Result<Plug> res;
            yield return res = CreateService(location, "sid://mindtouch.com/2007/12/dekiscript", config, new Result<Plug>());
            Plug service = res.Value;

            // register script functions in environment
            XDoc manifest = service.Get().ToDocument();
            string ns = manifest["namespace"].AsText;
            foreach(XDoc function in manifest["function"]) {
                string name = function["name"].AsText;
                if(string.IsNullOrEmpty(ns)) {
                    _env.Vars.AddNativeValueAt(name, function["uri"].AsUri);
                } else {
                    _env.Vars.AddNativeValueAt(ns + "." + name, function["uri"].AsUri);
                }
            }
            response.Return(DreamMessage.Ok(MimeType.XML, manifest));
        }
开发者ID:heran,项目名称:DekiWiki,代码行数:27,代码来源:ScriptTestService.cs

示例9: GetPage

 public Yield GetPage(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     CheckResponseCache(context, false);
     PageBE page = PageBL.GetPageFromUrl(true);
     page = PageBL.AuthorizePage(DekiContext.Current.User, Permissions.READ, page, false);
     response.Return(DreamMessage.Ok(PageBL.GetPageXmlVerbose(page, null)));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Pages.cs

示例10: GetSearchDescription

        public Yield GetSearchDescription(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
            XDoc description = new XDoc("OpenSearchDescription", "http://a9.com/-/spec/opensearch/1.1/");
            description.Elem("ShortName", string.Format(DekiResources.OPENSEARCH_SHORTNAME, DekiContext.Current.Instance.SiteName))
                       .Elem("Description", DekiResources.OPENSEARCH_DESCRIPTION)
                       .Start("Query")
                            .Attr("role", "example")
                            .Attr("searchTerms", "Wiki")
                       .End();

            // HACK HACK HACK: we can't use XUri because it encodes the "{}" characters
            string uri = DekiContext.Current.ApiUri.At("site", "opensearch").ToString();
            uri += "?q={searchTerms}&offset={startIndex}&limit={count?}&";

            description.Start("Url")
                 .Attr("type", "text/html")
                 .Attr("indexOffset", 0)
                 .Attr("template", DekiContext.Current.UiUri.At("Special:Search").ToString() + "?search={searchTerms}&offset=0&limit={count?}&format=html")
            .End()
            .Start("Url")
                 .Attr("type", "application/atom+xml")
                 .Attr("indexOffset", 0)
                 .Attr("template", uri + "format=atom")
            .End()
            .Start("Url")
                 .Attr("type", "application/rss+xml")
                 .Attr("indexOffset", 0)
                 .Attr("template", uri + "format=rss")
            .End()
            .Start("Url")
                 .Attr("type", "application/x-suggestions+json")
                 .Attr("template", DekiContext.Current.ApiUri.At("site", "opensearch", "suggestions").ToString() + "?q={searchTerms}")
             .End();
            response.Return(DreamMessage.Ok(description));
            yield break;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:35,代码来源:DekiWiki-Search.cs

示例11: GetPageTags

 public Yield GetPageTags(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PageBE page = PageBL.AuthorizePage(DekiContext.Current.User, Permissions.READ, false);
     XUri href = DekiContext.Current.ApiUri.At("pages", page.ID.ToString(), "tags");
     XDoc doc = TagBL.GetTagListXml(TagBL.GetTagsForPage(page), "tags", href, false);
     response.Return(DreamMessage.Ok(doc));
     yield break;
 } 
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-Tags.cs

示例12: GetServiceById

        public Yield GetServiceById(DreamContext context, DreamMessage request, Result<DreamMessage> response) {

            bool privateDetails = PermissionsBL.IsUserAllowed(DekiContext.Current.User, Permissions.ADMIN);

            //Private feature requires api-key
            var identifier = context.GetParam("id");
            uint serviceId = 0;
            if(identifier.StartsWith("=")) {
                var serviceInfo = DekiContext.Current.Instance.RunningServices[XUri.Decode(identifier.Substring(1))];
                if(serviceInfo != null) {
                    serviceId = serviceInfo.ServiceId;
                }
            } else {
                if(!uint.TryParse(identifier, out serviceId)) {
                    throw new DreamBadRequestException(string.Format("Invalid id '{0}'", identifier));
                }
            }
            ServiceBE service = ServiceBL.GetServiceById(serviceId);
            DreamMessage responseMsg = null;
            if(service == null) {
                responseMsg = DreamMessage.NotFound(string.Format(DekiResources.SERVICE_NOT_FOUND, identifier));
            } else {
                responseMsg = DreamMessage.Ok(ServiceBL.GetServiceXmlVerbose(DekiContext.Current.Instance, service, null, privateDetails));
            }
            response.Return(responseMsg);
            yield break;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:27,代码来源:DekiWiki-Services.cs

示例13: PostNewComment

        public static CommentBE PostNewComment(PageBE page, DreamMessage request, DreamContext context) {
            ValidateCommentText(request.ContentType, request.AsText());

            CommentBE comment = new CommentBE();
            comment.Title = context.GetParam("title", string.Empty);
            comment.PageId = page.ID;
            comment.Content = request.AsText();
            comment.ContentMimeType = request.ContentType.ToString();
            comment.PosterUserId = DekiContext.Current.User.ID;
            comment.CreateDate = DateTime.UtcNow;

            //Note (MaxM): Replytoid/replies not yet exposed
            //ulong replyToId = context.GetParam<ulong>("replyto", 0);
            //if (replyToId == 0)
            //    newComment.ReplyToId = null;
            //else
            //    newComment.ReplyToId = replyToId;

            ushort commentNumber;
            uint commentId = DbUtils.CurrentSession.Comments_Insert(comment, out commentNumber);
            if (commentId == 0) {
                return null;
            } else {
                comment.Id = commentId;
                comment.Number = commentNumber;
                PageBL.Touch(page, comment.CreateDate);
                RecentChangeBL.AddCommentCreateRecentChange(comment.CreateDate, page, DekiContext.Current.User, string.Format(DekiResources.COMMENT_ADDED, comment.Number.ToString()), comment);
                return comment;
            } 
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:30,代码来源:CommentBL.cs

示例14: GetArchiveFiles

 public Yield GetArchiveFiles(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PermissionsBL.CheckUserAllowed(DekiContext.Current.User, Permissions.ADMIN);
     IList<AttachmentBE> removedFiles = AttachmentBL.Instance.GetResources(DeletionFilter.DELETEDONLY, null, null);
     XDoc responseXml = AttachmentBL.Instance.GetFileXml(removedFiles, true, "archive", null, null);            
     response.Return(DreamMessage.Ok(responseXml));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:7,代码来源:DekiWiki-RecycleBin.cs

示例15: GetCommentContent

 public Yield GetCommentContent(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     PageBE page = null;
     CommentBE comment = null;
     GetCommentFromRequest(context, Permissions.READ, out page, out comment);
     response.Return(DreamMessage.Ok(new MimeType(comment.ContentMimeType), comment.Content));
     yield break;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:7,代码来源:DekiWiki-Comments.cs


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