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


C# JsonArray.ToString方法代码示例

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


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

示例1: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath == Url)
            {
                ThreadStore.UpdateThreadStoreStats();
                ThreadStoreStats stats = ThreadStore.StoreStats;

                JsonArray ja = new JsonArray();

                IEnumerable<string> boards = Program.ValidBoards.Keys;

                for (int i = 0, j = boards.Count(); i < j; i++)
                {
                    string boardName = boards.ElementAt(i);
                    int threadCount = stats[boardName];

                    if (threadCount > 0)
                    {
                        JsonArray inner = new JsonArray();

                        inner.Add(boardName);
                        inner.Add(threadCount);

                        ja.Add(inner);
                    }
                }

                WriteJsonResponse(response, ja.ToString());
                return true;
            }

            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:33,代码来源:GetThreadsStatisticsJsonApiHandler.cs

示例2: GetString

        public override string GetString(IEnumerable<IFreeDocument> datas)
        {
            var nodeGroup = new JsonArray();

            foreach (IFreeDocument data in datas)
            {

                nodeGroup.Add(GetJsonObject(data));
            }
            return nodeGroup.ToString();
        }
开发者ID:CHERRISHGRY,项目名称:Hawk,代码行数:11,代码来源:FileConnectorJson.cs

示例3: Process

        public override bool Process(HttpServer.IHttpRequest request, HttpServer.IHttpResponse response, HttpServer.Sessions.IHttpSession session)
        {
            if (request.UriPath.StartsWith(Url))
            {
                string day_number = request.QueryString[UrlParameters.DayNumber].Value;

                int dayNumber = 0;

                DateTime day = DateTime.Now;

                if (Int32.TryParse(day_number, out dayNumber))
                {
                    day = new DateTime(day.Year, 1, 1);

                    dayNumber--;

                    if (!DateTime.IsLeapYear(day.Year) && dayNumber == 365)
                    {
                        dayNumber--;
                    }

                    day = day.AddDays(dayNumber);
                }

                var sdata = NetworkUsageCounter.GetDayStats(day);

                JsonArray ja = new JsonArray();

                for (int i = 0; i < sdata.Length; i++)
                {
                    double t = sdata[i].Value / 1024 / 1024;

                    JsonArray inner = new JsonArray();

                    inner.Add(sdata[i].Key);
                    inner.Add(Math.Round(t, 2, MidpointRounding.AwayFromZero));

                    ja.Add(inner);
                }

                WriteJsonResponse(response, ja.ToString());
                return true;
            }

            return false;
        }
开发者ID:tyzmodo,项目名称:chan-archiver,代码行数:46,代码来源:GetDailyNetworkStatisticsJsonApiHandler.cs

示例4: SaveListViewProperties

 public void SaveListViewProperties(ListView listView)
 {
     JsonArray widths = new JsonArray();
     JsonArray indexes = new JsonArray();
     foreach (ColumnHeader column in listView.Columns)
     {
         widths.Add(column.Width);
         indexes.Add(column.DisplayIndex);
     }
     LocalSettings settings = Program.Settings;
     settings.SetObject(CONFKEYPREFIX_LISTVIEW_WIDTHS + listView.Name, widths.ToString());
     settings.SetObject(CONFKEYPREFIX_LISTVIEW_INDEXES + listView.Name, indexes.ToString());
     lock (listView)
     {
         IListViewItemSorter listViewItemSorter = (IListViewItemSorter)listView.ListViewItemSorter;
         settings.SetObject(CONFKEYPREFIX_LISTVIEW_SORTINDEX + listView.Name, listViewItemSorter.Order == SortOrder.Descending ? -listViewItemSorter.SortColumn : listViewItemSorter.SortColumn);
     }
 }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:18,代码来源:MainWindow.cs

示例5: InvokeArray

 public virtual object InvokeArray(Type returnType, string[] method, object[] args)
 {
     if (method == null)
         throw new ArgumentNullException("method");
     if (method.Length == 0)
         throw new ArgumentException(null, "method");
     if (returnType == null)
         throw new ArgumentNullException("returnType");
     try
     {
         var request = GetWebRequest(new Uri(Url));
         request.Method = "POST";
         var utf8EmitBom = new UTF8Encoding(false);
         using (var stream = request.GetRequestStream())
         using (var writer = new StreamWriter(stream, utf8EmitBom))
         {
             var calls = new JsonArray();
             var i = 0;
             foreach (var meth in method)
             {
                 var call = new JsonObject();
                 call["id"] = ++_id;
                 call["jsonrpc"] = "2.0";
                 call["method"] = method[i];
                 if (args[i] != null)
                     call["params"] = args[i];
                 calls.Add(call);
                 i++;
             }
             Logger.Instance().Log("RPC",calls.ToString());
             JsonConvert.Export(calls, writer);
         }
         object ret;
         using (var response = GetWebResponse(request))
         using (var stream = response.GetResponseStream())
         using (var reader = new StreamReader(stream, Encoding.UTF8))
             ret = OnResponseArray(JsonText.CreateReader(reader), returnType);
         return ret;
     }
     catch (WebException ex)
     {
         throw new JsonException("Invalid JSON-RPC response. It contains neither a result nor error : " + ex.Message);
     }
 }
开发者ID:GroupXTech,项目名称:Yatse2,代码行数:44,代码来源:JsonRpcClient.cs

示例6: AddDestinationPath

 public void AddDestinationPath(string path)
 {
     if (profileConfMap.ContainsKey(REGKEY_DESTINATION_PATH_HISTORY))
     {
         try
         {
             JsonArray oldArray = (JsonArray)JsonConvert.Import((string)profileConfMap[REGKEY_DESTINATION_PATH_HISTORY]);
             JsonArray newArray = new JsonArray();
             newArray.Add(path);
             for (int i = 0; i < oldArray.Length && newArray.Length < 5; i++)
             {
                 string oldString = (string)oldArray[i];
                 if (oldString != path)
                     newArray.Add(oldString);
             }
             profileConfMap[REGKEY_DESTINATION_PATH_HISTORY] = newArray.ToString();
         }
         catch
         {
             profileConfMap[REGKEY_DESTINATION_PATH_HISTORY] = (new JsonArray(new string[] { path })).ToString();
         }
     }
     else
     {
         profileConfMap.Add(REGKEY_DESTINATION_PATH_HISTORY, (new JsonArray(new string[] { path })).ToString());
     }
 }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:27,代码来源:RegistryLocalSettingsSingleton.cs

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

示例8: InitClientObjects

        /// <summary>
        /// Gets the current city.
        /// </summary>
        public void InitClientObjects()
        {
            PlaceManager pm = new PlaceManager();
            string defaultCity = ConfigurationOptions.Current.GetString("system_default_city");

            if (QueryStringContains("city"))
                defaultCity = GetFromQueryString("city");

            _currentCity = pm.LoadPlaceByRewritedName(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(defaultCity));

            if (_currentCity != null)
            {

            }
            else
            {
                _currentCity = pm.LoadPlace(ConfigurationOptions.Current.GetString("system_default_city"));

                RegisterDocumentReadyFunction("notExistingCity", JsUtils.CreateJsFunction("showNotExistingCityDialog", false, defaultCity));
            }

            JsonObject o = new JsonObject();
            o["name"] = _currentCity.Name;
            o["link"] = _currentCity.Link;
            o["id"] = _currentCity.PlaceID;
            o["lat"] = _currentCity.GeolocationInfo.Location.Latitude;
            o["lng"] = _currentCity.GeolocationInfo.Location.Longitude;
            o["zoom"] = _currentCity.MapZoom;

            ClientScript.RegisterClientScriptBlock(this.GetType(), "clientPageObjects", "var currentCity = " + o.ToString() + ";", true);

            //if (SessionContains("CurrentCity"))
            //{
            //    _currentCity = (Place)GetFromSession("CurrentCity");
            //    if (QueryStringContains("city") && GetFromQueryString("city") != _currentCity.Name)
            //    {

            //        _currentCity = pm.LoadPlace(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(defaultCity));
            //        AddToSession("CurrentCity", _currentCity);
            //    }
            //}
            //else
            //{
            //    _currentCity = pm.LoadPlace(System.Globalization.CultureInfo.CurrentCulture.TextInfo.ToTitleCase(defaultCity));

            //    if (_currentCity != null)
            //        AddToSession("CurrentCity", _currentCity);
            //    else
            //    {
            //        _currentCity = pm.LoadPlace(ConfigurationOptions.Current.GetString("system_default_city"));
            //        RegisterDocumentReadyFunction("notExistingCity", JsUtils.CreateJsFunction("showNotExistingCityDialog", false, defaultCity));
            //    }
            //}

            List<Place> places = pm.GetActivePlaces();

            JsonArray citiesArr = new JsonArray();
            foreach (Place p in places)
            {
                JsonObject c = new JsonObject();
                c["label"] = p.Name;
                c["link"] = p.Link;
                citiesArr.Add(c);
            }

            ClientScript.RegisterClientScriptBlock(this.GetType(), "cities", "var places = " + citiesArr.ToString() + ";", true);
        }
开发者ID:shardick,项目名称:mettiaposto,代码行数:70,代码来源:BasePage.cs

示例9: SaveSettings

 private void SaveSettings()
 {
     using (FileStream outFile = new FileStream(STORAGE_MANAGER_SETTINGS, FileMode.Create, FileAccess.Write))
     {
         using (StreamWriter writer = new StreamWriter(outFile))
         {
             var json = new JsonArray(StorageAliases);
             writer.Write(json.ToString());
         }
     }
 }
开发者ID:miracle091,项目名称:transmission-remote-dotnet,代码行数:11,代码来源:StorageManager.cs


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