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


C# JsonArray.Put方法代码示例

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


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

示例1: FromException

        public static JsonObject FromException(Exception e, bool includeStackTrace)
        {
            if (e == null)
                throw new ArgumentNullException("e");

            JsonObject error = new JsonObject();
            error.Put("name", "JSONRPCError");
            error.Put("message", e.GetBaseException().Message);

            if (includeStackTrace)
                error.Put("stackTrace", e.StackTrace);

            JsonArray errors = new JsonArray();
                
            do
            {
                errors.Put(ToLocalError(e));
                e = e.InnerException;
            }
            while (e != null);
            
            error.Put("errors", errors);
            
            return error;
        }
开发者ID:db48x,项目名称:KeeFox,代码行数:25,代码来源:JsonRpcError.cs

示例2: Files

 private static JsonObject Files(int id, bool includePriorities)
 {
     JsonObject request = CreateBasicObject(ProtocolConstants.METHOD_TORRENTGET, ResponseTag.UpdateFiles);
     JsonObject arguments = GetArgObject(request);
     JsonArray ids = new JsonArray();
     ids.Push(id);
     arguments.Put(ProtocolConstants.KEY_IDS, ids);
     JsonArray fields = new JsonArray();
     fields.Put(ProtocolConstants.FIELD_FILES);
     fields.Put(ProtocolConstants.FIELD_ID);
     if (includePriorities)
     {
         fields.Put(ProtocolConstants.FIELD_PRIORITIES);
         fields.Put(ProtocolConstants.FIELD_WANTED);
     }
     arguments.Put(ProtocolConstants.KEY_FIELDS, fields);
     return request;
 }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:18,代码来源:Requests.cs

示例3: process

        public JsonObject process(String feedUrl, String feedXml,
                                  bool getSummaries, int numEntries)
        {
            JsonObject json = new JsonObject();
            XmlReader reader = XmlReader.Create(feedUrl);
            SyndicationFeed feed = SyndicationFeed.Load(reader);
            if (feed == null)
            {
                throw new GadgetException(GadgetException.Code.FAILED_TO_RETRIEVE_CONTENT,
                                          "Unable to retrieve feed xml.");
            }
            json.Put("Title", feed.Title);
            json.Put("URL", feedUrl);
            json.Put("Description", feed.Description);
            json.Put("Link", feed.Links);

            var authors = feed.Authors;
            String jsonAuthor = null;
            if (authors.Count != 0)
            {
                SyndicationPerson author = authors[0];
                if (!String.IsNullOrEmpty(author.Name))
                {
                    jsonAuthor = author.Name;
                }
                else if (!String.IsNullOrEmpty(author.Email))
                {
                    jsonAuthor = author.Email;
                }
            }

            JsonArray entries = new JsonArray();
            json.Put("Entry", entries);

            int entryCnt = 0;
            foreach(var obj in feed.Items) 
            {
                SyndicationItem e = obj;
                if (entryCnt >= numEntries)
                {
                    break;
                }
                entryCnt++;

                JsonObject entry = new JsonObject();
                entry.Put("Title", e.Title);
                entry.Put("Link", e.Links);
                if (getSummaries) 
                {
                    entry.Put("Summary", e.Summary);
                }
                if (e.LastUpdatedTime == e.PublishDate)
                {
                    entry.Put("Date", e.PublishDate.LocalDateTime.ToShortDateString());
                }
                else
                {
                    entry.Put("Date", e.LastUpdatedTime.LocalDateTime.ToShortDateString());
                }

                // if no author at feed level, use the first entry author
                if (jsonAuthor == null && e.Authors.Count != 0) 
                {
                    jsonAuthor = e.Authors[0].Name;
                }

                entries.Put(entry);
            }

            json.Put("Author", jsonAuthor ?? "");
            reader.Close();
            return json;
        }
开发者ID:s7loves,项目名称:pesta,代码行数:73,代码来源:FeedProcessor.cs

示例4: DispatchFilesUpdate

        private void DispatchFilesUpdate(string datatype, JsonArray FileList)
        {
            Torrent t;
            lock (torrentListView)
            {
                if (torrentListView.SelectedItems.Count != 1)
                    return;

                t = (Torrent)torrentListView.SelectedItems[0];
            }
            JsonObject request = new JsonObject();
            request.Put(ProtocolConstants.KEY_METHOD, ProtocolConstants.METHOD_TORRENTSET);
            JsonObject arguments = new JsonObject();
            JsonArray ids = new JsonArray();
            ids.Put(t.Id);
            arguments.Put(ProtocolConstants.KEY_IDS, ids);
            if (FileList.Count == t.Files.Count)
                arguments.Put(datatype, new JsonArray());
            else if (FileList.Count > 0)
                arguments.Put(datatype, FileList);

            request.Put(ProtocolConstants.KEY_ARGUMENTS, arguments);
            request.Put(ProtocolConstants.KEY_TAG, (int)ResponseTag.DoNothing);
            Program.Form.SetupAction(CommandFactory.RequestAsync(request)).Completed +=
                delegate (object sender, ResultEventArgs e)
                {
                    if (e.Result.GetType() != typeof(ErrorCommand))
                        Program.Form.SetupAction(CommandFactory.RequestAsync(Requests.FilesAndPriorities(t.Id)));
                };
        }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:30,代码来源:MainWindow.cs

示例5: BuildIdArray

 private JsonArray BuildIdArray()
 {
     JsonArray ids = new JsonArray();
     lock (torrentListView)
     {
         foreach (Torrent t in torrentListView.SelectedItems)
         {
             ids.Put(t.Id);
         }
     }
     return ids;
 }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:12,代码来源:MainWindow.cs

示例6: createPipelinedProxyRequest

        /**
        * Creates a proxy request by fetching pipelined data and adding it to an existing request.
        *
        */
        private sRequest createPipelinedProxyRequest(Gadget gadget, sRequest original) 
        {
            sRequest request = new sRequest(original);
            request.setIgnoreCache(true);
            GadgetSpec spec = gadget.getSpec();
            GadgetContext context = gadget.getContext();
            IPreloads proxyPreloads = preloader.preload(context, spec,
                                PreloaderService.PreloadPhase.PROXY_FETCH);
            // TODO: Add current url to GadgetContext to support transitive proxying.

            // POST any preloaded content
            if ((proxyPreloads != null) && proxyPreloads.getData().Count != 0) 
            {
                JsonArray array = new JsonArray();

                foreach(PreloadedData preload in proxyPreloads.getData()) 
                {
                    Dictionary<String, Object> dataMap = preload.toJson();
                    foreach(var entry in dataMap) 
                    {
                        // TODO: the existing, supported content is JSONObjects that contain the
                        // key already.  Discarding the key is odd.
                        array.Put(entry.Value);
                    }
                }

                String postContent = array.ToString();
                // POST the preloaded content, with a method override of GET
                // to enable caching
                request.setMethod("POST")
                  .setPostBody(Encoding.UTF8.GetBytes(postContent))
                  .setHeader("Content-Type", "text/json;charset=utf-8");
            }
            return request;
        }
开发者ID:s7loves,项目名称:pesta,代码行数:39,代码来源:HtmlRenderer.cs

示例7: ListViewSelectionToIdArray

 public static JsonArray ListViewSelectionToIdArray(ListView.SelectedListViewItemCollection selections)
 {
     JsonArray ids = new JsonArray();
     foreach (Torrent item in selections)
     {
         ids.Put(item.Id);
     }
     return ids;
 }
开发者ID:bacobart,项目名称:transmission-remote-dotnet,代码行数:9,代码来源:Toolbox.cs

示例8: submitRpc

  /**
   * Collects all of the queued requests and encodes them into a single JSON
   * string before creating a new HTTP request, attaching this string to the
   * request body, signing it, and sending it to the container.
   * 
   * @param  client OpenSocialClient object with RPC_ENDPOINT property set
   * @return Object encapsulating the data requested from the container
   * @throws OpenSocialRequestException
   * @throws JSONException
   * @throws OAuthException
   * @throws IOException
   * @throws URISyntaxException
   */
  private OpenSocialResponse submitRpc(OpenSocialClient client)
  {

    String rpcEndpoint =
      client.getProperty(OpenSocialClient.Properties.RPC_ENDPOINT);

    JsonArray requestArray = new JsonArray();
    foreach(OpenSocialRequest r in this.requests) {
        requestArray.Put(JsonConvert.Import(r.getJsonEncoding()));
    }

    OpenSocialUrl requestUrl = new OpenSocialUrl(rpcEndpoint);

    OpenSocialHttpRequest request = new OpenSocialHttpRequest(requestUrl);
    request.setPostBody(requestArray.ToString());

    OpenSocialRequestSigner.signRequest(request, client);

    String responseString = getHttpResponse(request);
    return OpenSocialJsonParser.getResponse(responseString);
  }
开发者ID:s7loves,项目名称:pesta,代码行数:34,代码来源:OpenSocialBatch.cs


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