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


C# JsonDeserializer.Deserialize方法代码示例

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


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

示例1: OnLogInButtonClicked

        public Boolean OnLogInButtonClicked(string email, string password)
        {
            var hud = DependencyService.Get<IHud> ();
            hud.Show ("Verifying Credentials");

            var client = new RestClient("http://dev.envocsupport.com/GameStore2/");
            var request = new RestRequest("api/ApiKey?email=" + email + "&password=" + password, Method.GET);

            request.OnBeforeDeserialization = resp => { resp.ContentType = "application/json"; };

            IRestResponse queryResult = client.Execute(request);

            if (queryResult.StatusCode == HttpStatusCode.OK)
            {
                RestSharp.Deserializers.JsonDeserializer deserial = new JsonDeserializer();
                var x = deserial.Deserialize<UserApiKey>(queryResult);

                Application.Current.Properties["ApiKey"] = x.ApiKey;
                Application.Current.Properties ["UserId"] = x.UserId;

                //Console.WriteLine ("first" + queryResult.Content);
            //				Console.WriteLine ("key:"+x.ApiKey);

                // next request for User
                request = new RestRequest ("api/Users/"+x.UserId,Method.GET);

                var ApiKey = Application.Current.Properties ["ApiKey"];
                var UserId = Application.Current.Properties ["UserId"];

                request.AddHeader ("xcmps383authenticationkey",ApiKey.ToString ());
                request.AddHeader ("xcmps383authenticationid",UserId.ToString ());
                queryResult = client.Execute (request);

                User user = new User ();

                statusCodeCheck (queryResult);

                if (queryResult.StatusCode == HttpStatusCode.OK) {
                    user = deserial.Deserialize<User>(queryResult);
                }

                Application.Current.Properties ["FirstName"] = user.FirstName;

            //				Console.WriteLine (Application.Current.Properties ["UserId"]);
                //Console.WriteLine ("here" + queryResult.Content);

                loginStatus = true;
                return loginStatus ;
            }
            else
            {
                loginStatus = false;
                return loginStatus;

            }
        }
开发者ID:camotts,项目名称:383-Admin-Portal-Mobile-App,代码行数:56,代码来源:UserRepository.cs

示例2: TestDeserializeChannelResult

        public void TestDeserializeChannelResult()
        {
            var doc = File.ReadAllText(Path.Combine("Resources", "channels.json"));
            var json = new JsonDeserializer();
            var output = json.Deserialize<ChannelResult>(new RestResponse {Content = doc});

            Assert.NotNull(output);
            Assert.NotNull(output.Channels);
            Assert.AreEqual(1, output.Channels.Count);
            Assert.AreEqual("CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", output.Channels[0].Sid);
            Assert.AreEqual("ACaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", output.Channels[0].AccountSid);
            Assert.AreEqual("ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", output.Channels[0].ServiceSid);
            Assert.AreEqual("my channel", output.Channels[0].FriendlyName);
            Assert.IsEmpty(output.Channels[0].Attributes);
            Assert.AreEqual("system", output.Channels[0].CreatedBy);
            Assert.AreEqual("public", output.Channels[0].Type);
            Assert.AreEqual(
                "http://localhost/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
                output.Channels[0].Url);
            Dictionary<string, string> dictionary = output.Channels[0].Links;
            Assert.NotNull(dictionary);
            Assert.True(dictionary.ContainsKey("members"));
            Assert.True(dictionary.ContainsKey("messages"));
            Assert.AreEqual(
                "http://localhost/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Members",
                dictionary["members"]);
            Assert.AreEqual(
                "http://localhost/v1/Services/ISaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Channels/CHaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/Messages",
                dictionary["messages"]);
        }
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:30,代码来源:ChannelTests.cs

示例3: GetToken_Click

        private void GetToken_Click(object sender, RoutedEventArgs e)
        {
            var client = new RestClient("https://api.home.nest.com/oauth2/access_token");
            var request = new RestRequest(Method.POST);
            request.AddParameter("client_id", TextNestClientId.Text);
            request.AddParameter("code", TextNestPin.Text);
            request.AddParameter("client_secret", PwNestSecret.Password);
            request.AddParameter("grant_type", "authorization_code");
            var response = client.Execute(request);

            JsonDeserializer deserializer = new JsonDeserializer();

            var json = deserializer.Deserialize<Dictionary<string, string>>(response);

            if (json.ContainsKey("access_token"))
            {
                TextNestAccessToken.Text = json["access_token"];
                return;
            }

            if (json.ContainsKey("message"))
            {
                TextNestAccessToken.Text = json["message"];
                return;                
            }

            if (json.ContainsKey("error_description"))
            {
                TextNestAccessToken.Text = json["error_description"];
                return;
            }
        }
开发者ID:pacificIT,项目名称:FirebaseSharp,代码行数:32,代码来源:MainWindow.xaml.cs

示例4: OnContentReceived

		private void OnContentReceived(string content) {
			JsonDeserializer deserializer = new JsonDeserializer();

			var response = new RestResponse();
			response.Content = content;

			MessageContent messageContent = null;
			try {
				messageContent = deserializer.Deserialize<MessageContent>(response);
			} catch {
				MessageContent = null;
			}

			if (messageContent != null) {
				MessageContent = messageContent;

				if (Event == "message" || Event == "comment") {
					ExtractedBody = messageContent.Text;
				}
			} else if(Event == "message") {
				ExtractedBody = content;
			}

			Displayable = ExtractedBody != null;

			TimeStamp = UnixTimeToLocal(Sent);
		}
开发者ID:pratik136,项目名称:Flowdock.NET,代码行数:27,代码来源:Message.cs

示例5: JSONDeserializationTest

        public void JSONDeserializationTest() {
            var path = Path.Combine(Environment.CurrentDirectory, "Schedule.json");
            var ds = new JsonDeserializer();
            var response = new RestResponse() { ContentType = "application/json", ResponseStatus = ResponseStatus.Completed, StatusCode = System.Net.HttpStatusCode.OK };

            // Read the file as one string.
            StreamReader myFile = new StreamReader(path);
            string json = myFile.ReadToEnd();
            myFile.Close();

            response.Content = json;

            var mySchedule = ds.Deserialize<Schedule>(response);

            Assert.IsNotNull(mySchedule);
            Assert.IsNotNull(mySchedule.escalation_policies);

            Assert.AreEqual("FS4LEQD", mySchedule.id);
            Assert.AreEqual("24x7 Schedule", mySchedule.name);
            Assert.AreEqual("UTC", mySchedule.time_zone);
            Assert.AreEqual(new DateTime(635726880000000000), mySchedule.today);
            Assert.AreEqual(1, mySchedule.escalation_policies.Count);
            Assert.AreEqual("PAD5HK6", mySchedule.escalation_policies[0].id);
            Assert.AreEqual("Escalation Policy - 24x7", mySchedule.escalation_policies[0].name);
        }
开发者ID:Famien,项目名称:PagerDuty.Net,代码行数:25,代码来源:ScheduleTests.cs

示例6: JSONDeserializationTest

        public void JSONDeserializationTest() {
            var path = Path.Combine(Environment.CurrentDirectory, "User.json");
            var ds = new JsonDeserializer();
            var response = new RestResponse() { ContentType = "application/json", ResponseStatus = ResponseStatus.Completed, StatusCode = System.Net.HttpStatusCode.OK };

            // Read the file as one string.
            StreamReader myFile = new StreamReader(path);
            string json = myFile.ReadToEnd();
            myFile.Close();

            response.Content = json;

            var myUser = ds.Deserialize<User>(response);

            Assert.IsNotNull(myUser);


            Assert.AreEqual("PT23IWX", myUser.id);
            Assert.AreEqual("Tim Wright", myUser.name);
            Assert.AreEqual("[email protected]", myUser.email);
            Assert.AreEqual("Eastern Time (US & Canada)", myUser.time_zone);
            Assert.AreEqual("purple", myUser.color);
            Assert.AreEqual("owner", myUser.role);
            Assert.AreEqual("https://secure.gravatar.com/avatar/923a2b907dc04244e9bb5576a42e70a7.png?d=mm&r=PG", myUser.avatar_url);
            Assert.AreEqual("/users/PT23IWX", myUser.user_url);
            Assert.AreEqual(false, myUser.invitation_sent);
            Assert.AreEqual(false, myUser.marketing_opt_out);
        }
开发者ID:jameswestbv,项目名称:PagerDuty.Net,代码行数:28,代码来源:UserTests.cs

示例7: HitboxOnlineState

        private static bool HitboxOnlineState(string sStream)
        {
            var req = new RestRequest("/media/live/" + sStream, Method.GET);
            IRestClientProvider _restClientProvider = new RestClientProvider(new RestClient("http://api.hitbox.tv"));
            var response = _restClientProvider.Execute(req);
            try
            {
                var des = new JsonDeserializer();

                var data = des.Deserialize<HitboxRootObject>(response);
                foreach (var item in data.livestream)
                {
                    if(item.media_user_name.ToLower() == sStream.ToLower())
                    {
                        if(item.media_is_live == "1")
                        {
                            return true;
                        }
                    }
                }
                return false;

            }
            catch (Exception)
            {
                return false;
            }
        }
开发者ID:Kolpa,项目名称:DeathmicChatbot,代码行数:28,代码来源:Stream+Static+Functions.cs

示例8: JSONDeserializationTest

        public void JSONDeserializationTest() {
            var path = Path.Combine(Environment.CurrentDirectory, "Incident.json");
            var ds = new JsonDeserializer();
            var response = new RestResponse() { ContentType = "application/json", ResponseStatus = ResponseStatus.Completed, StatusCode = System.Net.HttpStatusCode.OK };

            // Read the file as one string.
            StreamReader myFile = new StreamReader(path);
            string json = myFile.ReadToEnd();
            myFile.Close();
            
            response.Content = json;

            var myAlert = ds.Deserialize<Incident>(response);

            Assert.IsNotNull(myAlert);
            Assert.IsNotNull(myAlert.service);
            Assert.IsNotNull(myAlert.last_status_change_by);
            
            Assert.AreEqual("1", myAlert.incident_number);
            Assert.AreEqual(new DateTime(634830005610000000), myAlert.created_on);
            Assert.AreEqual("resolved", myAlert.status);
            Assert.AreEqual("https://acme.pagerduty.com/incidents/P2A6J96", myAlert.html_url);
            Assert.AreEqual(null, myAlert.incident_key);
            Assert.AreEqual(null, myAlert.assigned_to_user);
            Assert.AreEqual("https://acme.pagerduty.com/incidents/P2A6J96/log_entries/P2NQP6P", myAlert.trigger_details_html_url);
            Assert.AreEqual(new DateTime(634830006590000000), myAlert.last_status_change_on);
        }
开发者ID:jameswestbv,项目名称:PagerDuty.Net,代码行数:27,代码来源:IncidentTests.cs

示例9: ReplayAllEvents

        public void ReplayAllEvents()
        {
            using (IDocumentSession session = _eventStorage.OpenSession())
            {
                int startPos = 0;

                while (true)
                {

                    RavenQueryStatistics stats;
                    var events = session.Query<EventDescriptor>()
                        .Statistics(out stats)
                        .OrderBy(ev => ev.AggregateId)
                        .ThenBy(ev => ev.Version)
                        .Select(ev => ev)
                        .Skip(startPos)
                        .ToArray();

                    JsonDeserializer deserializer = new JsonDeserializer();

                    foreach (EventDescriptor ev in events)
                    {
                        Publish(deserializer.Deserialize(ev.EventType, ev.EventData));
                    }

                    if (stats.TotalResults <= startPos)
                    {
                        break;
                    }

                    startPos += 128;

                }
            }
        }
开发者ID:Erls-Corporation,项目名称:Logos,代码行数:35,代码来源:RavenDbEventStore.cs

示例10: FetchDiff

		public bool FetchDiff (Push push)
		{
			string url = null;
			try {
				string response = CachingFetcher.FetchDiff (push.CHAuthID, push.Repository.Owner.Name, push.Repository.Name, ID, out url);
				if (response == null)
					return false;
				
				var jdes = new JsonDeserializer ();
				var wrapper = jdes.Deserialize<CommitWithDiffJsonWrapper> (response);
				if (wrapper != null) {
					var diff = wrapper.Commit;
					if (!diff.FetchBlobs (push)) {
						Log (LogSeverity.Error, "Failed to fetch blobs for commit '{0}' from URL '{1}'", ID, url);
						return false;
					}
					Diff = diff;
				} else {
					Log (LogSeverity.Error, "Failed to fetch diff for commit '{0}' from URL '{1}'", ID, url);
					return false;
				}
			} catch (Exception ex) {
				Log (ex, "Exception while fetching diff for commit '{4}' from URL '{5}'\n{0}", ID, url);
				return false;
			}
			
			CommitWithDiff ret = Diff;
			if (ret == null)
				Log (LogSeverity.Info, "FetchDiff did not fail, but no diff retrieved?");
			
			return ret != null;
		}
开发者ID:nsavga,项目名称:CaptainHook,代码行数:32,代码来源:Commit.cs

示例11: GetParams

 public static SinusModel GetParams()
 {
     var request = new RestRequest(Method.GET);
     request.Resource = "model/" + ModelId;
     IRestResponse response = client.Execute (request);
     var json = new JsonDeserializer();
     return json.Deserialize<SinusModel>(response);
 }
开发者ID:TomasKulhanek,项目名称:Physio.FmiRestService,代码行数:8,代码来源:SinusSimulator.cs

示例12: testDeserializeResponse

        public void testDeserializeResponse()
        {
            var doc = File.ReadAllText(Path.Combine("Resources", "workspace_statistics.json"));
            var json = new JsonDeserializer();
            var output = json.Deserialize<WorkspaceStatistics>(new RestResponse { Content = doc });

            Assert.NotNull(output);
        }
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:8,代码来源:WorkspaceStatisticsTests.cs

示例13: Deserialize_SerializationRepresentation_DeserializedObject

        public void Deserialize_SerializationRepresentation_DeserializedObject()
        {
            var subject = new JsonDeserializer();
            var deserialized = subject.Deserialize<Serializable>(Serializable.JsonString("s", 3m));

                Assert.That(deserialized.D, Is.EqualTo(3m));
                Assert.That(deserialized.S, Is.EqualTo("s"));
        }
开发者ID:dgg,项目名称:testing-commons,代码行数:8,代码来源:JsonDeserializerTester.cs

示例14: testDeserializeListResponse

        public void testDeserializeListResponse()
        {
            var doc = File.ReadAllText(Path.Combine("Resources", "task_queues_statistics.json"));
            var json = new JsonDeserializer();
            var output = json.Deserialize<TaskQueueStatisticsResult>(new RestResponse { Content = doc });

            Assert.NotNull(output);
        }
开发者ID:SnapMD,项目名称:twilio-csharp,代码行数:8,代码来源:TaskQueueStatisticsTests.cs

示例15: testDeserializeInstanceResponse

        public void testDeserializeInstanceResponse()
        {
            var doc = Twilio.Api.Tests.Utilities.UnPack(BASE_NAME + "worker_statistics.json");
            var json = new JsonDeserializer();
            var output = json.Deserialize<WorkerStatistics>(new RestResponse { Content = doc });

            Assert.NotNull(output);
        }
开发者ID:mrockmann,项目名称:twilio-dotnet,代码行数:8,代码来源:WorkerStatisticsTests.cs


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