Bloom.Api.ApiRequest.ReplyWithJson C# (CSharp) Method

ReplyWithJson() public method

public ReplyWithJson ( object objectToMakeJson ) : void
objectToMakeJson object
return void
        public void ReplyWithJson(object objectToMakeJson)
        {
            //Debug.WriteLine(this.Requestinfo.LocalPathWithoutQuery + ": " + json);
            _requestInfo.ContentType = "application/json";
            _requestInfo.WriteCompleteOutput(JsonConvert.SerializeObject(objectToMakeJson));
        }

Same methods

ApiRequest::ReplyWithJson ( string json ) : void

Usage Example

 /// <summary>
 /// Get a json of the book's settings.
 /// </summary>
 private void HandleBookSettings(ApiRequest request)
 {
     switch (request.HttpMethod)
     {
         case HttpMethods.Get:
             dynamic settings = new ExpandoObject();
             settings.isRecordedAsLockedDown = _bookSelection.CurrentSelection.RecordedAsLockedDown;
             settings.unlockShellBook = _bookSelection.CurrentSelection.TemporarilyUnlocked;
             settings.currentToolBoxTool = _bookSelection.CurrentSelection.BookInfo.CurrentTool;
             settings.isTemplateBook = GetIsBookATemplate();
             request.ReplyWithJson((object)settings);
             break;
         case HttpMethods.Post:
             //note: since we only have this one value, it's not clear yet whether the panel involved here will be more of a
             //an "edit settings", or a "book settings", or a combination of them.
             settings = DynamicJson.Parse(request.RequiredPostJson());
             _bookSelection.CurrentSelection.TemporarilyUnlocked = settings["unlockShellBook"];
             _pageRefreshEvent.Raise(PageRefreshEvent.SaveBehavior.SaveBeforeRefresh);
             if(((DynamicJson)settings).IsDefined("isTemplateBook"))
             {
                 UpdateBookTemplateMode(settings.isTemplateBook);
             }
             request.Succeeded();
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
All Usage Examples Of Bloom.Api.ApiRequest::ReplyWithJson