当前位置: 首页>>代码示例>>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;未经允许,请勿转载。