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


C# DreamContext.GetParam方法代码示例

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


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

示例1: DeleteSource

		public Yield DeleteSource(DreamContext context, DreamMessage request, Result<DreamMessage> response)
		{
			Result<bool> result = new Result<bool>();
			yield return Context.Current.Instance.SourceController.Delete(context.GetParam("id"), context.GetParam("rev",null), result);

			response.Return(DreamMessage.Ok(MimeType.JSON, result.Value.ToString()));
		} 
开发者ID:willemda,项目名称:FoireMuses,代码行数:7,代码来源:SourceService.cs

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

示例3: SubscribeToChange

 public Yield SubscribeToChange(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     var wikiId = GetWikiIdFromRequest(request);
     var pageId = context.GetParam<uint>("pageid");
     var depth = context.GetParam("depth", "0") == "0" ? false : true;
     Result<PageSubscriptionUser> userResult;
     yield return userResult = Coroutine.Invoke(GetRequestUser, request, new Result<PageSubscriptionUser>()).Catch();
     if(userResult.HasException) {
         ReturnUserError(userResult.Exception, response);
         yield break;
     }
     var 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");
     }
     var dataSession = GetDataSession(wikiId);
     dataSession.Subscribe(userInfo.Id, pageId, depth);
     response.Return(DreamMessage.Ok());
     yield break;
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:26,代码来源:DekiChangeSubscriptionService.cs

示例4: UpdateUser

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

			Result<IUser> result = new Result<IUser>();
			yield return Context.Current.Instance.UserController.Update(context.GetParam("id"), context.GetParam("rev"), Context.Current.Instance.UserController.FromJson(request.ToText()), result);

			response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.UserController.ToJson(result.Value)));
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:8,代码来源:UserService.cs

示例5: UpdateSource

		public Yield UpdateSource(DreamContext context, DreamMessage request, Result<DreamMessage> response)
		{
			ISource source = Context.Current.Instance.SourceController.FromJson(request.ToText());
			Result<ISource> result = new Result<ISource>();
			yield return Context.Current.Instance.SourceController.Update(context.GetParam("id"), context.GetParam("rev", null), source, result);

			response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.SourceController.ToJson(result.Value)));
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:8,代码来源:SourceService.cs

示例6: GetSources

		public Yield GetSources(DreamContext context, DreamMessage request, Result<DreamMessage> response)
		{
			Result<SearchResult<ISourceSearchResult>> result = new Result<SearchResult<ISourceSearchResult>>();
			int limit = context.GetParam("max", 20);
			int offset = context.GetParam("offset", 0);

			yield return Context.Current.Instance.IndexController.GetAllSources(limit, offset, result);

			response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.IndexController.ToJson(result.Value)));
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:10,代码来源:SourceService.cs

示例7: GetPlaysFromSource

		public Yield GetPlaysFromSource(DreamContext context, DreamMessage request, Result<DreamMessage> response)
		{
			Result<SearchResult<IPlay>> result = new Result<SearchResult<IPlay>>();
			int limit = context.GetParam("max", 20);
			int offset = context.GetParam("offset", 0);
			string id = context.GetParam("id");

			yield return Context.Current.Instance.PlayController.GetPlaysFromSource(offset, limit, id, result);

			response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.PlayController.ToJson(result.Value)));
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:11,代码来源:PlayService.cs

示例8: GetPageAllowedUsers

 public Yield GetPageAllowedUsers(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     List<uint> userids = new List<uint>();
     if(request.HasDocument) {
         foreach(XDoc userid in request.ToDocument()["user/@id"]) {
             uint? id = userid.AsUInt;
             if(id.HasValue) {
                 userids.Add(id.Value);
             } else {
                 throw new DreamBadRequestException(string.Format("'{0}' is not a valid userid", userid.AsText));
             }
         }
     }
     if(userids.Count == 0) {
         throw new DreamBadRequestException("must provide at least one userid");
     }
     string permissionsList = context.GetParam("permissions");
     bool filterDisabled = context.GetParam("filterdisabled", false);
     if(filterDisabled) {
         List<uint> activeUsers = new List<uint>();
         foreach(UserBE user in DbUtils.CurrentSession.Users_GetByIds(userids)) {
             if(user.UserActive) {
                 activeUsers.Add(user.ID);
             }
         }
         userids = activeUsers;
         if(userids.Count == 0) {
             response.Return(DreamMessage.Ok(new XDoc("users")));
             yield break;
         }
     }
     Permissions permissions = Permissions.READ;
     if(!string.IsNullOrEmpty(permissionsList)) {
         bool first = true;
         foreach(string perm in permissionsList.Split(',')) {
             Permissions p;
             if(!SysUtil.TryParseEnum(perm, out p)) {
                 throw new DreamBadRequestException(string.Format("'{0}' is not a valid permission value", perm));
             }
             if(first) {
                 permissions = p;
             } else {
                 permissions |= p;
             }
             first = false;
         }
     }
     uint[] filteredIds = PermissionsBL.FilterDisallowed(userids.ToArray(), context.GetParam<uint>("pageid"), false, permissions);
     XDoc msg = new XDoc("users");
     foreach(int userid in filteredIds) {
         msg.Start("user").Attr("id", userid).End();
     }
     response.Return(DreamMessage.Ok(msg));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:54,代码来源:DekiWiki-Pages.cs

示例9: GetScores

		public Yield GetScores(DreamContext aContext, DreamMessage aRequest, Result<DreamMessage> aResponse)
		{
			theLogger.Info("GetScores");
			Result<SearchResult<IScoreSearchResult>> result = new Result<SearchResult<IScoreSearchResult>>();
			int limit = aContext.GetParam("max", 20);
			int offset = aContext.GetParam("offset", 0);

			yield return Context.Current.Instance.IndexController.GetAllScores(limit, offset, result);

			aResponse.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.IndexController.ToJson(result.Value)));
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:11,代码来源:ScoreService.cs

示例10: GetScoresFromSource

		public Yield GetScoresFromSource(DreamContext aContext, DreamMessage aRequest, Result<DreamMessage> aResponse)
		{
			theLogger.Info("GetScoresFromSource");
			Result<SearchResult<IScore>> result = new Result<SearchResult<IScore>>();
			int limit = aContext.GetParam("max", 20);
			int offset = aContext.GetParam("offset", 0);
			string id = aContext.GetParam("id");

			yield return Context.Current.Instance.ScoreController.GetScoresFromSource(id, offset, limit, result);

			aResponse.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.ScoreController.ToJson(result.Value)));
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:12,代码来源:ScoreService.cs

示例11: UpdatePlay

		public Yield UpdatePlay(DreamContext context, DreamMessage request, Result<DreamMessage> response)
		{
			string playId = context.GetParam("id");
			string playRev = context.GetParam("rev");

			IPlay play = Context.Current.Instance.PlayController.FromJson(request.ToText());

			Result<IPlay> result = new Result<IPlay>();

			yield return Context.Current.Instance.PlayController.Update(playId,playRev, play, result);

			response.Return(DreamMessage.Ok(MimeType.JSON, Context.Current.Instance.PlayController.ToJson(result.Value)));
		}
开发者ID:willemda,项目名称:FoireMuses,代码行数:13,代码来源:PlayService.cs

示例12: thumb

 public Yield thumb(DreamContext context, DreamMessage request, Result<DreamMessage> response) {
     var slide = context.GetParam<int>("slide");
     var width = context.GetParam<int>("width");
     var height = context.GetParam<int>("height");
     var requestInfo = new RequestInfo { 
         slide=slide,
         width=width,
         height=height
     };
     var image = cache.ContainsKey(requestInfo) ?
         cache[requestInfo] : createImage(requestInfo);
     response.Return(DreamMessage.Ok(MimeType.JPEG, image));
     yield break;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:14,代码来源:ServiceRoot.cs

示例13: ShowXml

 private static bool ShowXml(DreamContext context) {
     switch(context.GetParam("format", null) ?? context.GetParam("output", "cooked")) {
     case "raw":
     case "debug":
         return false;
     case "seared":
     case "xml":
         return true;
     case "cooked":
     case "html":
         return false;
     default:
         throw new OutputParameterInvalidArgumentException();
     }
 }
开发者ID:heran,项目名称:DekiWiki,代码行数:15,代码来源:DekiWiki-Nav.cs

示例14: ShowXml

 private static bool ShowXml(DreamContext context) {
     switch(context.GetParam("format", null) ?? context.GetParam("output", "cooked")) {
     case "raw":
     case "debug":
         return false;
     case "seared":
     case "xml":
         return true;
     case "cooked":
     case "html":
         return false;
     default:
         throw new DreamBadRequestException(DekiResources.OUTPUT_PARAM_INVALID);
     }
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:15,代码来源:DekiWiki-Nav.cs

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


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