當前位置: 首頁>>代碼示例>>C#>>正文


C# JObject.ToString方法代碼示例

本文整理匯總了C#中Newtonsoft.Json.Linq.JObject.ToString方法的典型用法代碼示例。如果您正苦於以下問題:C# JObject.ToString方法的具體用法?C# JObject.ToString怎麽用?C# JObject.ToString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Newtonsoft.Json.Linq.JObject的用法示例。


在下文中一共展示了JObject.ToString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ItemListStatic

 public ItemListStatic(JObject basicO,
     JObject dataO,
     JArray groupsA,
     JArray treeA,
     string type,
     string version,
     JObject originalObject)
 {
     data = new Dictionary<string, ItemStatic>();
     groups = new List<GroupStatic>();
     tree = new List<ItemTreeStatic>();
     if (basicO != null)
     {
         basic = HelperMethods.LoadBasicDataStatic(basicO);
     }
     if (dataO != null)
     {
         LoadData(dataO.ToString());
     }
     if (groupsA != null)
     {
         LoadGroups(groupsA);
     }
     if (treeA != null)
     {
         LoadTree(treeA);
     }
     this.type = type;
     this.version = version;
     this.originalObject = originalObject;
 }
開發者ID:mattregul,項目名稱:CreepScore,代碼行數:31,代碼來源:ItemListStatic.cs

示例2: BetRequest

		public static int BetRequest(JObject jsonState)
		{
			int bet = 0;
			var gameState = JsonConvert.DeserializeObject<GameState>(jsonState.ToString());
            try
			{
				string actualDecision = "none";
				Logger.LogHelper.Log("type=bet_begin action=bet_request request_id={0} game_id={1}", requestId, gameState.GameId);

				foreach (IDecisionLogic decisionLogic in Decisions.DecisionFactory.GetDecisions())
                {
                    //végigpróbáljuk a lehetőségeket
                    int? possibleBet = decisionLogic.MakeADecision(gameState);
                    if (possibleBet.HasValue)
                    {
                        bet = possibleBet.Value;
						actualDecision = decisionLogic.GetName();
                        break;
                    }
				}

				string cards = String.Join(",", gameState.OwnCards);
				Logger.LogHelper.Log("type=bet action=bet_request request_id={0} game_id={1} bet={2} cards={3} decision={4}",
					requestId, gameState.GameId, bet, cards, actualDecision);
            }
            catch (Exception ex)
            {
				Logger.LogHelper.Error("type=error action=bet_request request_id={0} game_id={1} error_message={2}",requestId, gameState.GameId, ex);
            }

			return bet;
		}
開發者ID:kronomanta,項目名稱:poker-player-smart-fox,代碼行數:32,代碼來源:PokerPlayer.cs

示例3: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     Response.Clear();
     var obj = new JObject(new JProperty("machineName", ServerManager.MachineName), new JProperty("servers", JArray.FromObject(ServerManager.GetActiveServerList())));
     Response.BinaryWrite(Encoding.UTF8.GetBytes(obj.ToString()));
     Response.End();
 }
開發者ID:nasimsvce,項目名稱:planning-poker,代碼行數:7,代碼來源:ServerList.aspx.cs

示例4: VerifyEnum

        public void VerifyEnum()
        {
            Type typeToTest = typeof(Duplex);
            var typeExpected = new JObject(new JProperty("type", "#/Duplex")).ToString();
            var schemaExpected = new JObject(
                    new JProperty("Duplex", 
                        new JObject(
                            new JProperty("id", "#/Duplex"),
                            new JProperty("type", "number"),
                            new JProperty("enum", new JArray(1, 2, 3, -1)),
                            new JProperty("options", new JArray(
                                new JObject(new JProperty("value", 1), new JProperty("label", "Simplex")),
                                new JObject(new JProperty("value", 2), new JProperty("label", "Vertical")),
                                new JObject(new JProperty("value", 3), new JProperty("label", "Horizontal")),
                                new JObject(new JProperty("value", -1), new JProperty("label", "Default"))
                        ))))

                    ).ToString();

            const bool flatten = false;
            var schema = new JObject();
            string actual = GetActual(typeToTest, typeExpected, flatten, schema);

            Assert.AreEqual(typeExpected, actual);

            Console.WriteLine("SCHEMA\n" + schema.ToString(Formatting.Indented));
            Assert.AreEqual(schemaExpected, schema.ToString(Formatting.Indented));
        }
開發者ID:sopel,項目名稱:Salient.ReliableHttpClient,代碼行數:28,代碼來源:EnumTypeConversionFixture.cs

示例5: DismissShow

        public virtual DismissMovieResult DismissShow(string apiKey, string username, string passwordHash, string imdbId = null, int? tvdbId = null, string title = null, int? year = null)
        {
            var url = String.Format("{0}{1}", Url.RecommendationsShowsDismiss, apiKey);

            var postJson = new JObject();
            postJson.Add(new JProperty("username", username));
            postJson.Add(new JProperty("password", passwordHash));

            if (imdbId != null)
                postJson.Add(new JProperty("imdb_id", imdbId));

            if (tvdbId != null)
                postJson.Add(new JProperty("tvdb_id", tvdbId));

            if (title != null)
                postJson.Add(new JProperty("title", title));

            if (year != null)
                postJson.Add(new JProperty("year", year));

            var responseJson = _httpProvider.DownloadString(url, postJson.ToString());

            if (String.IsNullOrWhiteSpace(responseJson))
                return null;

            return JsonConvert.DeserializeObject<DismissMovieResult>(responseJson);
        }
開發者ID:markus101,項目名稱:Trakter,代碼行數:27,代碼來源:RecommendationsProvider.cs

示例6: VerifyFlagsEnum

        public void VerifyFlagsEnum()
        {
            Type typeToTest = typeof(PaletteFlags);
            var typeExpected = new JObject(
                new JProperty("type", "#/PaletteFlags")
                ).ToString();

            var schemaExpected = new JObject(
                new JProperty("PaletteFlags",
                    new JObject(new JProperty("id", "#/PaletteFlags"),
                        new JProperty("type", "number"),
                        new JProperty("format", "bitmask"),
                        new JProperty("enum", new JArray(1, 2, 4)),
                        new JProperty("options", new JArray(
                            new JObject(new JProperty("value", 1), new JProperty("label", "HasAlpha")),
                            new JObject(new JProperty("value", 2), new JProperty("label", "GrayScale")),
                            new JObject(new JProperty("value", 4), new JProperty("label", "Halftone"))
                    ))))
                ).ToString();

            const bool flatten = false;
            var schema = new JObject();
            string actual = GetActual(typeToTest, typeExpected, flatten, schema);

            Assert.AreEqual(typeExpected, actual);

            Console.WriteLine("SCHEMA\n" + schema.ToString(Formatting.Indented));
            Assert.AreEqual(schemaExpected, schema.ToString(Formatting.Indented));
        }
開發者ID:sopel,項目名稱:Salient.ReliableHttpClient,代碼行數:29,代碼來源:EnumTypeConversionFixture.cs

示例7: ReadJson

        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            string[] props = new string[] { "EntryId", "DateCreated", "CreatedBy", "DateUpdated", "UpdatedBy" };

            JObject orig = JObject.Load(reader);
            JObject result = new JObject();
            JObject responses = new JObject();

            foreach (string p in props)
            {
                result[p] = orig[p];
                orig.Remove(p);
            }

            foreach (var prop in orig.Properties())
            {
                responses[prop.Name] = prop.Value;
            }
            result.Add("Fields", responses);

            var outString = result.ToString();
            Entry e = new Entry();
            JsonConvert.PopulateObject(result.ToString(), e);

            return e;
        }
開發者ID:nxgo,項目名稱:WufooSharp,代碼行數:26,代碼來源:EntryConverter.cs

示例8: ProcessRequestAsyncSuccessfully

		public void ProcessRequestAsyncSuccessfully()
		{
			JObject returnValue = new JObject { { "Name", "TestName" } };

			Uri requestUri =
				new Uri(
					string.Format(
						"http://bla.com/api/{0}/{1}?{2}=TestValue1",
						WebApiConfiguration.Instance.Apis[0].Name,
						WebApiConfiguration.Instance.Apis[0].WebMethods[0].Name,
						WebApiConfiguration.Instance.Apis[0].WebMethods[0].Parameters[0].Name));

			Mock<IRunner> runnerMock = new Mock<IRunner>(MockBehavior.Strict);
			runnerMock.Setup(
				m => m.ExecuteAsync(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<string>(), It.IsAny<IList<KeyValuePair<string, string>>>(), It.IsAny<bool>()))
				.ReturnsAsync(new PowershellReturn
				{
					PowerShellReturnedValidData = true,
					ActualPowerShellData = returnValue.ToString()
				});

			var ioc = createContainer(cb => cb.RegisterInstance(runnerMock.Object));

			var genericController = ioc.Resolve<GenericController>();
			genericController.Request = new HttpRequestMessage(HttpMethod.Get, requestUri);
			var res = genericController.ProcessRequestAsync().Result;

			Assert.AreEqual(
				returnValue.ToString(),
				res.Content.ReadAsStringAsync().Result,
				"Return value from process request is incorrect");
		}
開發者ID:sunnyc7,項目名稱:PowerShell.REST.API,代碼行數:32,代碼來源:GenericControllerTests.cs

示例9: Button_Click_1

 //post方式調用服務器接口
 private void Button_Click_1(object sender, RoutedEventArgs e)
 {
     //填寫查尋密鑰
     string queryKey = "abc";
     //定義要訪問的雲平台接口--接口詳見服務器開發文檔
     string uri="/api/20140928/management";
     DateTime Jan1st1970 = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
     long Sticks = (long)(DateTime.UtcNow - Jan1st1970).TotalMilliseconds;
     string timeStamp = Sticks.ToString();
     //填寫服務器提供的服務碼
     string queryString = "service_code=TESTING";
     WoanSignature.Signature Signature = new WoanSignature.Signature();
     //定義請求數據,以下json是一個刪除文件的json請求
     JObject json = new JObject(
         new JProperty("function", "delete_video"),
         new JProperty("params",
             new JObject(
             new JProperty("service_code", "TESTING"),
             new JProperty("file_name", "1.m3u8")
             )
          )
     );
     string signature = Signature.SignatureForPost(uri, queryKey, queryString, json.ToString(), timeStamp);
      WoanSignature.HttpTool HttpTool = new WoanSignature.HttpTool();
      string response = HttpTool.post("http://c.zhiboyun.com/api/20140928/management?" + queryString, signature, timeStamp, json.ToString());
     MessageBox.Show(response);
 }
開發者ID:WoAnTech,項目名稱:zby-api-signature-cs-demo,代碼行數:28,代碼來源:MainWindow.xaml.cs

示例10: SendMessage

 public void SendMessage(string targetId, string senderId, JObject jobj, ConversationType type)
 {
     if (type == ConversationType.PRIVATE)
     {
         int messageId = Rcsdk.SaveMessage(targetId, 1, "RC:TxtMsg", senderId, jobj.ToString(), "", "", false, 0);
         Rcsdk.sendMessage(targetId, 1, 2, "RC:TxtMsg", jobj.ToString(), "", "", messageId, _sendCallBack);
     }
     else if (type == ConversationType.DISCUSSION)
     {
         int messageId1 = Rcsdk.SaveMessage(targetId, 2, "RC:TxtMsg", senderId, jobj.ToString(), "", "", false, 0);
         Rcsdk.sendMessage(targetId, 2, 3, "RC:TxtMsg", jobj.ToString(), "", "", messageId1, _sendCallBack);
     }
 }
開發者ID:GavinHome,項目名稱:REVOLUTION,代碼行數:13,代碼來源:MessagingService.cs

示例11: invalidParams_platform

	    public void invalidParams_platform() {
            JObject payload = new JObject();
	        payload.Add("platform", JToken.FromObject("all_platform"));
            payload.Add("audience", JToken.FromObject(JsonConvert.SerializeObject(Audience.all(), new AudienceConverter())));
            payload.Add("notification", JToken.FromObject(new  Notification().setAlert(ALERT)));

            Console.WriteLine("json string: " + payload.ToString());
	        
	        try {
                var result = _client.SendPush(payload.ToString());
	        } catch (APIRequestException e) {
                 Assert.AreEqual(INVALID_PARAMS, e.ErrorCode);
	        }
	    }
開發者ID:wcgh,項目名稱:Zichanguanli-Server-for-C-code,代碼行數:14,代碼來源:ExceptionTest.cs

示例12: GetItemRankings

        public List<ItemRecommendation> GetItemRankings(string userId, string[] itemIds)
        {
            if (!itemIds.Any())
            {
                throw new InvalidOperationException("Must have at least one itemId");
            }
            var request = new JObject();
            request[Constants.UserId] = userId;
            var jItems = new JArray();
            foreach (var itemId in itemIds)
            {
                jItems.Add(itemId);
            }
            request[Constants.ItemIds] = jItems;
            var body = request.ToString(Formatting.None);
            var response = (JObject)Execute(Constants.EngineResource, Method.POST, body);
            if (response[Constants.IsOriginal].Value<bool>())
            {
                return new List<ItemRecommendation>();
            }
            var recommendations = new List<ItemRecommendation>();
            foreach (var item in response[Constants.Items])
            {
                var property = item.First.Value<JProperty>();
                var recommendation = new ItemRecommendation
                {
                    ItemId = property.Name,
                    Score = item.First.First.Value<float>()
                };
                recommendations.Add(recommendation);
            }
            return recommendations;

        }   
開發者ID:vinhdang,項目名稱:Sensible.PredictionIO.NET,代碼行數:34,代碼來源:EngineClient.cs

示例13: makeRequestForm

        public RequestForm makeRequestForm(JObject json)
        {
            string currManagerName = (string)json["current"]["bazookaInfo"]["managerId"];
            string futureManagerName = (string)json["future"]["bazookaInfo"]["managerId"];
            int managerID = GetIDFromName(currManagerName);
            int f_managerID = GetIDFromName(futureManagerName);
            json["current"]["bazookaInfo"]["managerId"] = managerID;
            json["current"]["ultiproInfo"]["supervisor"] = managerID;
            json["future"]["bazookaInfo"]["managerId"] = f_managerID;
            json["future"]["ultiproInfo"]["supervisor"] = f_managerID;

            UserController uc = new UserController();
            string[] name = uc.GetUserName().Split('.');
            string creatorName = name[0] + " " + name[1];
            int creatorID = GetIDFromName(creatorName);

            RequestForm obj = null;
            using (var sr = new StringReader(json.ToString()))
            using (var jr = new JsonTextReader(sr))
            {
                var js = new JsonSerializer();
                obj = (RequestForm)js.Deserialize<RequestForm>(jr);
            }
            obj.EmployeeId = GetIDFromName((string)json["name"]);
            obj.CreatedByID = creatorID;
            obj.Current.BazookaInfo.SecurityItemRights = "";
            obj.ReviewInfo.FilesToBeRemovedFrom = "(" + obj.Current.BazookaInfo.Group + ")" + currManagerName.Replace(" ", ".")+" "+obj.ReviewInfo.FilesToBeRemovedFrom;
            obj.ReviewInfo.FilesToBeAddedTo = "(" + obj.Future.BazookaInfo.Group + ")" + futureManagerName.Replace(" ", ".")+" "+obj.ReviewInfo.FilesToBeAddedTo;

            return obj;
        }
開發者ID:jakemmarsh,項目名稱:coyote-moves,代碼行數:31,代碼來源:RequestformController.cs

示例14: DataReceived

        public void DataReceived(JObject data)
        {
            if (data["msg"] != null)
            {

                switch (data["msg"].ToString())
                {
                    case "connected":
                        // stuff that occurs on connection such as subscription if desired
                        //this.Subscribe("requests");
                        break;

                    case "added":
                        Console.WriteLine("Document Added: " + data["id"]);

                        break;
                    case "ready":
                        Console.WriteLine("Subscription Ready: " + data["subs"].ToString());
                        break;
                    case "removed":
                        Console.WriteLine("Document Removed: " + data["id"]);
                        break;

                    default:
                        Console.WriteLine(data.ToString());
                        break;
                }
            }
        }
開發者ID:aaronthorp,項目名稱:net-meteor-ddp-client,代碼行數:29,代碼來源:DDPClient.cs

示例15: invalidParams_audience

        public void invalidParams_audience() 
        {
            JObject payload = new JObject();
            payload.Add("platform", JToken.FromObject(JsonConvert.SerializeObject(Platform.all(), new PlatformConverter())));
            payload.Add("audience", JToken.FromObject("all_audience"));
            JsonSerializer jsonSerializer = new JsonSerializer();
            jsonSerializer.DefaultValueHandling = DefaultValueHandling.Ignore;
            payload.Add("notification", JToken.FromObject(new Notification().setAlert(ALERT), jsonSerializer));

            Console.WriteLine("json string: " + payload.ToString());
            try {
                 var result = _client.SendPush(payload.ToString());
            }catch (APIRequestException e) {
                 Assert.AreEqual(INVALID_PARAMS, e.ErrorCode);
	        }
         }
開發者ID:wcgh,項目名稱:Zichanguanli-Server-for-C-code,代碼行數:16,代碼來源:ExceptionTest.cs


注:本文中的Newtonsoft.Json.Linq.JObject.ToString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。