public void ShouldNotThrowWhenExist()
        {
            var obj = JsonConvert.Deserialize <Object>("{ \"Numbers\": [1,2,3] }");

            Assert.NotNull(obj);
            Assert.Equal(new Int32[] { 1, 2, 3 }, obj.Numbers);
        }
Example #2
0
        private void HandleAuthClient()
        {
            //Inicia Thread KeepAlive
            var keepAliveThread = new Thread(new ThreadStart(KeepAlive));

            keepAliveThread.Start();

            while (Tcp.Connected)
            {
                try
                {
                    var messageBufferRead = new byte[500000]; //Tamanho do BUFFER á ler

                    //Lê mensagem do cliente
                    var bytesRead = this.NetworkStream.Read(messageBufferRead, 0, 500000);

                    //variável para armazenar a mensagem recebida
                    var message = new byte[bytesRead];

                    //Copia mensagem recebida
                    Buffer.BlockCopy(messageBufferRead, 0, message, 0, bytesRead);

                    var json = System.Text.Encoding.Default.GetString(message);

                    var response = JsonConvert.Deserialize <AuthPacketInfo>(json);

                    //Dispara evento OnPacketReceived
                    OnPacketReceived?.Invoke(this, response);
                }
                catch
                {
                    OnDisconnect?.Invoke();
                }
            }
        }
Example #3
0
        static int Main(string[] args)
        {
            //string str = "";
            //using (StreamReader reader = File.OpenText("../../../db.json"))
            //{
            //    str = reader.ReadToEnd();
            //}
            //JsonObject obj = JsonConvert.Deserialize(str);
            //string s = obj.ToJsonString();
            ////Console.WriteLine(s);
            //obj = JsonConvert.Deserialize(s);

            //Console.WriteLine(obj.ToJsonString());
            var obj = new Test()
            {
                a = 1, b = 2, c = 3, d = 4, e = 5, f = 'T', g = null, h = 1000000000000L, str = "slfjklnfw,jfklankdsjfksjnfklajdkfjaklfjksnfkjekjnfkjakffjkajfkjakjfkwenfkajfalksjfioeownbkdjfieonfa;akldjfieowfjnkdajfdkafjei"
            };
            var strObj = "{\"a\":1,\"b\":2,\"c\":3,\"d\":4,\"e\":5,\"f\":\"T\",\"g\":null,\"h\":1000000000000,\"str\":\"slfjklnfw,jfklankdsjfksjnfklajdkfjaklfjksnfkjekjnfkjakffjkajfkjakjfkwenfkajfalksjfioeownbkdjfieonfa; akldjfieowfjnkdajfdkafjei\"}";

            JsonObject JsonObj = JsonConvert.Deserialize(strObj) as JsonObject;

            Console.WriteLine(JsonObj["str"].ToObject <string>());

            return(1);
        }
Example #4
0
        /// <summary>
        /// Convert the response of a SQL resultset to the desired T object.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resultSet"></param>
        /// <returns></returns>
        public T ConvertResultSet <T>(IDictionary <string, object>[][] resultSet)
        {
            // Need to convert from IDictionary[] or IDictionary[][] to Type T - 1st step is to serialize into JSON string
            string resultJSON;
            Type   type = typeof(T);

            if (typeof(Array[]).IsAssignableFrom(type))
            {
                if (resultSet.Length == 0 || resultSet[0].Length == 0)
                {
                    return(JsonConvert.Deserialize <T>("[]"));
                }
                resultJSON = JsonConvert.Serialize(resultSet);
            }
            else if (typeof(Array).IsAssignableFrom(type) ||
                     type.FullName.Contains(".List")
                     )
            {
                if (resultSet.Length == 0 || resultSet[0].Length == 0)
                {
                    return(JsonConvert.Deserialize <T>("[]"));
                }
                resultJSON = JsonConvert.Serialize(resultSet[0]);
            }
            else
            {
                if (resultSet.Length == 0 || resultSet[0].Length == 0)
                {
                    return(default);
Example #5
0
        public void TestDeserializeStoredEntry()
        {
            var json   = new JsonConvert();
            var result = json.Deserialize <BaseEntry>("{'type':'stored','password':'******'}".Replace('\'', '"')) as StoredEntry;

            Assert.AreEqual("secret", result.password);
        }
Example #6
0
        public GroupDto Update(ServerDto serverDto, string tenant, GroupDto groupDto, Token token)
        {
            var principalName = Uri.EscapeDataString(groupDto.GroupName + "@" + groupDto.GroupDomain);

            tenant = Uri.EscapeDataString(tenant);
            var url = string.Format(ServiceConfigManager.GroupEndPoint, serverDto.Protocol, serverDto.ServerName, serverDto.Port, tenant, principalName);
            var g   = new GroupDto()
            {
                GroupDetails = new GroupDetailsDto {
                    Description = groupDto.GroupDetails.Description
                }
            };
            var json = JsonConvert.Serialize(g);

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            var requestConfig = new RequestSettings
            {
                Method = HttpMethod.Put,
            };
            var headers = ServiceHelper.AddHeaders(ServiceConfigManager.JsonContentType);

            json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json;
            var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json);

            return(JsonConvert.Deserialize <GroupDto>(response));
        }
Example #7
0
        public async Task <HttpResponse <V1Pod> > DeletePodHttpAsync(string ns, string name, V1DeleteOptions options, string labelSelectorParameter = null, int?timeoutSecondsParameter = null)
        {
            // build query
            var query = new StringBuilder();

            if (!string.IsNullOrEmpty(labelSelectorParameter))
            {
                AddQueryParameter(query, "labelSelector", labelSelectorParameter);
            }
            if (timeoutSecondsParameter != null)
            {
                AddQueryParameter(query, "timeoutSeconds", timeoutSecondsParameter.Value.ToString());
            }

            var res = options == null
                ? await DeleteApiAsync($"/api/v1/namespaces/{ns}/pods/{name}", query).ConfigureAwait(false)
                : await DeleteApiAsync($"/api/v1/namespaces/{ns}/pods/{name}", query, options).ConfigureAwait(false);

            var status = JsonConvert.Deserialize <V1Pod>(res.Content);

            return(new HttpResponse <V1Pod>(status)
            {
                Response = res.HttpResponseMessage,
            });
        }
        public async ValueTask <HttpResponse <V1WatchEvent <V1Deployment> > > WatchDeploymentsHttpAsync(string ns, string resourceVersion = "", string labelSelectorParameter = null, int?timeoutSecondsParameter = null)
        {
            // build query
            var query = new StringBuilder();

            AddQueryParameter(query, "watch", "true");
            if (!string.IsNullOrEmpty(resourceVersion))
            {
                AddQueryParameter(query, "resourceVersion", resourceVersion);
            }
            if (!string.IsNullOrEmpty(labelSelectorParameter))
            {
                AddQueryParameter(query, "labelSelector", labelSelectorParameter);
            }
            if (timeoutSecondsParameter != null)
            {
                AddQueryParameter(query, "timeoutSeconds", timeoutSecondsParameter.Value.ToString());
            }

            var res = await GetStreamApiAsync($"/apis/apps/v1/namespaces/{ns}/deployments", query).ConfigureAwait(false);

            var watch = JsonConvert.Deserialize <V1WatchEvent <V1Deployment> >(res.Content);

            return(new HttpResponse <V1WatchEvent <V1Deployment> >(watch)
            {
                Response = res.HttpResponseMessage,
            });
        }
Example #9
0
        public AuthTokenDto GetTokenFromCertificate(ServerDto serverDto, X509Certificate2 certificate, RSACryptoServiceProvider rsa)
        {
            var url         = _serviceConfigManager.GetTokenFromCertificateUrl(serverDto);
            var aud         = _serviceConfigManager.GetAudience(serverDto);
            var signedToken = GetSignedJwtToken(rsa, certificate, aud);

            if (signedToken == null)
            {
                throw new Exception("Could not generate a valid token");
            }

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };

            var data          = _serviceConfigManager.GetJwtTokenBySolutionUserArgs(signedToken);
            var requestConfig = new RequestSettings
            {
                Method = HttpMethod.Post,
            };
            var headers = ServiceHelper.AddHeaders();
            var result  = _webRequestManager.GetResponse(url, requestConfig, headers, null, data);
            var token   = JsonConvert.Deserialize <Token>(result);

            token.Raw = result;
            return(new AuthTokenDto(Refresh)
            {
                Token = token, ClaimsPrincipal = null, Login = null, ServerDto = serverDto
            });
        }
Example #10
0
        public AuthTokenDto Authenticate(ServerDto serverDto, LoginDto loginDto, string clientId)
        {
            var tenant = Uri.EscapeDataString(loginDto.TenantName);
            var url    = _serviceConfigManager.GetLoginUrl(serverDto, tenant);

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            var data          = _serviceConfigManager.FormatLoginArgs(loginDto);
            var requestConfig = new RequestSettings
            {
                Method = HttpMethod.Post,
            };
            var headers = ServiceHelper.AddHeaders();
            var result  = _webRequestManager.GetResponse(url, requestConfig, headers, null, data);
            var token   = JsonConvert.Deserialize <Token>(result);

            token.Raw       = result;
            token.ClientId  = clientId;
            token.TokenType = TokenType.Bearer.ToString();
            token.Role      = GetRole(token.AccessToken);
            var certificates    = GetCertificates(serverDto, loginDto.TenantName, CertificateScope.TENANT, token);
            var claimsPrincipal = Validate(serverDto, loginDto.User + "@" + loginDto.DomainName, certificates[certificates.Count - 1], loginDto.TenantName, token.IdToken);

            if (claimsPrincipal != null)
            {
                return new AuthTokenDto(Refresh)
                       {
                           Token = token, ClaimsPrincipal = claimsPrincipal, Login = loginDto, ServerDto = serverDto
                       }
            }
            ;
            return(new AuthTokenDto(Refresh)
            {
                Token = token, ClaimsPrincipal = claimsPrincipal, Login = loginDto, ServerDto = serverDto
            });
        }
Example #11
0
        public AuthTokenDto GetTokenFromCertificate(ServerDto serverDto, X509Certificate2 certificate, RSACryptoServiceProvider rsa)
        {
            //token_class: "solution_assertion",
            //token_type: "Bearer",
            //jti: <randomly generated id string>,
            //iss: <cert subject dn>,
            //sub: <cert subject dn>,
            //aud: <token endpoint url>,
            //iat: 1431623789,
            //exp: 1462382189
            var url         = string.Format(ServiceConfigManager.LoginEndPoint, serverDto.Protocol, serverDto.ServerName, serverDto.Port, serverDto.Tenant);
            var signedToken = GetSignedJwtToken(rsa, certificate, url);

            if (signedToken == null)
            {
                throw new Exception("Could not generate a valid token");
            }

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            var data          = string.Format(ServiceConfigManager.JwtTokenBySolutionUserArguments, signedToken);
            var requestConfig = new RequestSettings
            {
                Method = HttpMethod.Post,
            };
            var headers = ServiceHelper.AddHeaders();
            var result  = _webRequestManager.GetResponse(url, requestConfig, headers, null, data);
            var token   = JsonConvert.Deserialize <Token>(result);

            token.Raw = result;
            return(new AuthTokenDto(Refresh)
            {
                Token = token, ClaimsPrincipal = null, Login = null, ServerDto = serverDto
            });
        }
Example #12
0
        public AuthTokenDto Authenticate(ServerDto serverDto, LoginDto loginDto, string clientId)
        {
            var tenant = Uri.EscapeDataString(loginDto.TenantName);
            var url    = string.Format(ServiceConfigManager.LoginEndPoint, serverDto.Protocol, serverDto.ServerName, serverDto.Port, tenant);

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            var data          = string.Format(ServiceConfigManager.LoginArguments, loginDto.User, loginDto.Pass, loginDto.DomainName, clientId);
            var requestConfig = new RequestSettings
            {
                Method = HttpMethod.Post,
            };
            var headers = ServiceHelper.AddHeaders();
            var result  = _webRequestManager.GetResponse(url, requestConfig, headers, null, data);
            var token   = JsonConvert.Deserialize <Token>(result);

            token.Raw       = result;
            token.ClientId  = clientId;
            token.TokenType = TokenType.Bearer.ToString();
            var certificates    = GetCertificates(serverDto, loginDto.TenantName, CertificateScope.TENANT, token);
            var claimsPrincipal = Validate(serverDto, loginDto.User + "@" + loginDto.DomainName, certificates[certificates.Count - 1], loginDto.TenantName, token.IdToken);

            if (claimsPrincipal != null)
            {
                return new AuthTokenDto(Refresh)
                       {
                           Token = token, ClaimsPrincipal = claimsPrincipal, Login = loginDto, ServerDto = serverDto
                       }
            }
            ;
            return(new AuthTokenDto(Refresh)
            {
                Token = token, ClaimsPrincipal = claimsPrincipal, Login = loginDto, ServerDto = serverDto
            });
            //throw new AuthenticationException(@"Login Failure: Invalid username or password");
        }
        public async ValueTask <HttpResponse <V1DeploymentList> > GetDeploymentsHttpAsync(string ns = "", bool watch = false, string labelSelectorParameter = null, int?timeoutSecondsParameter = null)
        {
            // build query
            var query = new StringBuilder();

            if (watch)
            {
                AddQueryParameter(query, "watch", "true");
            }
            if (!string.IsNullOrEmpty(labelSelectorParameter))
            {
                AddQueryParameter(query, "labelSelector", labelSelectorParameter);
            }
            if (timeoutSecondsParameter != null)
            {
                AddQueryParameter(query, "timeoutSeconds", timeoutSecondsParameter.Value.ToString());
            }

            var url = string.IsNullOrEmpty(ns)
                ? $"/apis/apps/v1/deployments"
                : $"/apis/apps/v1/namespaces/{ns}/deployments";
            var res = await GetApiAsync(url, query).ConfigureAwait(false);

            var deployments = JsonConvert.Deserialize <V1DeploymentList>(res.Content);

            return(new HttpResponse <V1DeploymentList>(deployments)
            {
                Response = res.HttpResponseMessage,
            });
        }
Example #14
0
        public async ValueTask <HttpResponse <V1JobList> > GetJobsHttpAsync(string ns, bool watch = false, string labelSelectorParameter = null, int?timeoutSecondsParameter = null, CancellationToken ct = default)
        {
            // build query
            var query = new StringBuilder();

            if (watch)
            {
                AddQueryParameter(query, "watch", "true");
            }
            if (!string.IsNullOrEmpty(labelSelectorParameter))
            {
                AddQueryParameter(query, "labelSelector", labelSelectorParameter);
            }
            if (timeoutSecondsParameter != null)
            {
                AddQueryParameter(query, "timeoutSeconds", timeoutSecondsParameter.Value.ToString());
            }

            var res = await GetApiAsync($"/apis/batch/v1/namespaces/{ns}/jobs", query, ct : ct).ConfigureAwait(false);

            var jobs = JsonConvert.Deserialize <V1JobList>(res.Content);

            return(new HttpResponse <V1JobList>(jobs)
            {
                Response = res.HttpResponseMessage,
            });
        }
Example #15
0
        void LoadMore()
        {
            HttpRequestInformation httpRequestInformation = new HttpRequestInformation()
            {
                Url = "https://pix.ipv4.host/ranks",
                QueryStringParameters =
                {
                    { "page",     Page                                            },
                    { "date",     DateTime.Now.AddDays(-3).ToString("yyyy-MM-dd") },
                    { "mode",     "day"                                           },
                    { "pageSize",                                              30 }
                }
            };

            new Thread(() => {
                string response = Global.Http.Request(httpRequestInformation);
                Console.WriteLine(response);
                JsonObject jsonObject = response;
                JsonArray data        = jsonObject["data"];
                foreach (var current in data)
                {
                    AddItem(JsonConvert.Deserialize <HomeItem> (current));
                }
                IsLoading = false;
            })
            {
                IsBackground = true
            }.Start();
        }
Example #16
0
        public void VerifyJsonConversions(TestObject dataInput)
        {
            IJsonConvert converter = new JsonConvert();
            string       json      = converter.Serialize(dataInput);
            TestObject   converted = converter.Deserialize <TestObject>(json);

            Assert.Equal(converted, dataInput);
        }
Example #17
0
        public void TestDeserializeSiteEntry()
        {
            var json   = new JsonConvert();
            var result = json.Deserialize <BaseEntry>("{'site':'example.net','alias':'example.com'}".Replace('\'', '"')) as SiteEntry;

            Assert.AreEqual("example.net", result.site);
            Assert.AreEqual("example.com", result.alias);
        }
Example #18
0
        public void TestDeserializeGeneratedEntry()
        {
            var json   = new JsonConvert();
            var result = json.Deserialize <BaseEntry>("{'type':'gen','length':2}".Replace('\'', '"')) as GeneratedEntry;

            Assert.AreEqual("gen", result.type);
            Assert.AreEqual(2, result.length);
        }
Example #19
0
    //However, this mapping glue in some internal class to retain SOLID principles
    private CustomerTO Mapping(Customer custEntity)
    {
        var custTO = _appMapper.Map(custEntity);
        var str    = JsonConvert.Serialize(custTO.CustomerData);

        custTO.CustomerData = JsonConvert.Deserialize(str);
        return(custTO);
    }
 public float[,,,] GetConv2DWeights(string name, int width, int height, int channel, int units)
 {
     if (name is null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     return(JsonConvert.Deserialize <float[, , , ]> (Data[name]["kernel"]));
 }
 public float[,] GetDenseWeights(string name, int units, int inputShape)
 {
     if (name is null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     return(JsonConvert.Deserialize <float[, ]> (Data[name]["kernel"]));
 }
 public float[] GetBiases(string name, int units)
 {
     if (name is null)
     {
         throw new ArgumentNullException(nameof(name));
     }
     return(JsonConvert.Deserialize <float[]> (Data[name]["bias"]));
 }
Example #23
0
        private void HandleDataReceived(IAsyncResult ar)
        {
            int bytesRead = 0;

            byte[] message = new byte[0];
            if (IsRunning)
            {
                var _Session = (ClientAuth)ar.AsyncState;
                var _Stream  = _Session.NetworkStream;

                try
                {
                    bytesRead = _Stream.EndRead(ar);
                    //verifica se o tamanho do pacote é zero
                    if (bytesRead == 0)
                    {
                        lock (m_Clients)
                        {
                            m_Clients.Remove(_Session.Info.UID);

                            OnClientDisconnected(_Session);
                            return;
                        }
                    }

                    //variável para armazenar a mensagem recebida
                    message = new byte[bytesRead];

                    //Copia mensagem recebida
                    Buffer.BlockCopy(MsgBufferRead, 0, message, 0, bytesRead);

                    s_AllReceBytes += bytesRead;
                    //ler o proximo pacote(se houver)
                    _Stream.BeginRead(MsgBufferRead, 0, MsgBufferRead.Length, HandleDataReceived, _Session);
                }
                catch
                {
                    lock (m_Clients)
                    {
                        m_Clients.Remove(_Session.Info.UID);

                        OnClientDisconnected(_Session);
                        return;
                    }
                }

                //checa se o tamanho da mensagem é zerada
                if (message.Length > 0)
                {
                    var json = System.Text.Encoding.Default.GetString(message);

                    var packet = JsonConvert.Deserialize <AuthPacketInfo>(json);

                    //Dispara evento OnPacketReceived
                    ClientRequestPacket(_Session, packet);
                }
            }
        }
Example #24
0
        public T Invoke <T>(string method, IDictionary <string, object> args = null)
        {
            System.Net.ServicePointManager.Expect100Continue = false;

            if (method == null)
            {
                throw new ArgumentNullException("method");
            }
            if (method.Length == 0)
            {
                throw new ArgumentException(null, "method");
            }

            //var restEndpoint = EndPoint + method + "/";

            var restEndpoint = @"https://api.betfair.com/exchange/betting/json-rpc/v1";

            var request = CreateWebRequest(restEndpoint);

            var call = new JsonRequest {
                Method = method, Id = 1, Params = args
            };

            var json = JsonConvert.Serialize <JsonRequest>(call);

            //var postData = "[{\"jsonrpc\": \"2.0\", \"method\": \"SportsAPING/v1.0/listMarketBook\", \"params\": {\"marketIds\":[\"1.120620079\"]}, \"id\": 1}]";

            var bytes = Encoding.GetEncoding("Unicode").GetBytes(json);

            request.ContentLength = bytes.Length;

            using (
                Stream stream = request.GetRequestStream())
            {
                stream.Write(bytes, 0, bytes.Length);
            }

            using (HttpWebResponse response = (HttpWebResponse)GetWebResponse(request))
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream, Encoding.UTF8))
                    {
                        string f = response.StatusCode.ToString();
                        string e = response.StatusDescription.ToString();

                        var jsonResponse = reader.ReadToEnd();
                        //Console.WriteLine("\nGot response: " + jsonResponse);

                        if (response.StatusCode != HttpStatusCode.OK)
                        {
                            throw ReconstituteException(JsonConvert.Deserialize <TourTrader.TO.Exception>(jsonResponse));
                        }

                        JsonResponse <T> j_resp = JsonConvert.Deserialize <JsonResponse <T> >(jsonResponse);

                        return(j_resp.Result);
                    }
        }
Example #25
0
        public override async Task OnIceCandidate(RelayMessage message)
        {
            var candidates = (DtoIceCandidates)JsonConvert.Deserialize(message.Payload, typeof(DtoIceCandidates));

            foreach (var candidate in candidates.Candidates)
            {
                await Context.PeerConnection.AddIceCandidate(candidate.FromDto());
            }
        }
        private static System.Exception ReconstituteException(Api_ng_sample_code.TO.Exception ex)
        {
            var data = ex.Data;

            // API-NG exception -- it must have "data" element to tell us which exception
            var exceptionName = data.Property("exceptionname").Value.ToString();
            var exceptionData = data.Property(exceptionName).Value.ToString();
            return JsonConvert.Deserialize<APINGException>(exceptionData);
        }
Example #27
0
 public async ValueTask<HttpResponse<V1Deployment>> CreateDeploymentHttpAsync(string ns, string manifest, CancellationToken ct = default)
 {
     var res = await PostApiAsync($"/apis/apps/v1/namespaces/{ns}/deployments", null, manifest, ct: ct).ConfigureAwait(false);
     var deploy = JsonConvert.Deserialize<V1Deployment>(res.Content);
     return new HttpResponse<V1Deployment>(deploy)
     {
         Response = res.HttpResponseMessage,
     };
 }
Example #28
0
        public void DeserializeJsonFromAFile()
        {
            string path  = @"movie.json";
            Movie  movie = JsonConvert.Deserialize <Movie> (File.ReadAllText(path));

            using (StreamReader file = File.OpenText(path)) {
                Movie movie2 = JsonConvert.Deserialize <Movie> (file);
            }
        }
Example #29
0
        public IdentityProviderDto Probe(ServerDto server, string tenant, IdentityProviderDto provider, Token token)
        {
            var schemaSerialized    = SerializeSchema(provider.Schema);
            var attributeSerailized = SerializeAttributes(provider.AttributesMap, "attributesMap");

            provider.Schema        = null;
            provider.AttributesMap = null;

            tenant = Uri.EscapeDataString(tenant);
            var url = string.Format(ServiceConfigManager.IdentityProvidersEndPoint, server.Protocol, server.ServerName, server.Port, tenant);

            url += "?probe=true";
            var dto  = typeof(IdentityProviderDto).Assembly;
            var json = JsonConvert.Serialize(provider, "root", dto.GetTypes(), true);

            json = SerializationJsonHelper.Cleanup(json);

            json = json.Substring(0, json.Length - 1);

            var attributeString = "\"attributesMap\":null,";

            if (json.Contains(attributeString))
            {
                json = json.Replace(attributeString, attributeSerailized + (string.IsNullOrEmpty(attributeSerailized)? string.Empty : ","));
            }
            else
            {
                json += attributeSerailized;
            }

            var schemaString = "\"schema\":null,";

            if (json.Contains(schemaString))
            {
                json = json.Replace(schemaString, schemaSerialized + (string.IsNullOrEmpty(schemaSerialized)? string.Empty : ","));
            }
            else
            {
                json += schemaSerialized;
            }
            json += "}";

            ServicePointManager.ServerCertificateValidationCallback = delegate { return(true); };
            var requestConfig = new RequestSettings
            {
                Method = HttpMethod.Post
            };
            var headers = ServiceHelper.AddHeaders(ServiceConfigManager.JsonContentType);

            json = "access_token=" + token.AccessToken + "&token_type=" + token.TokenType.ToString().ToLower() + "&" + json;
            var response = _webRequestManager.GetResponse(url, requestConfig, headers, null, json);

            response = SerializationJsonHelper.JsonToDictionary("attributesMap", response);
            response = CleanupSchemaJson(response);
            return(JsonConvert.Deserialize <IdentityProviderDto>(response, "root", dto.GetTypes(), true));
        }
Example #30
0
    public ActionResult Index()
    {
        HttpClient client = new HttpClient();
        Task<IEnumerable<Tweet>> tweetTask = client.GetStringAsync("http://search.twitter.com/search.json?q=dave")
            .ContinueWith(stringTask =>
                {
                    return JsonConvert.Deserialize<IEnumerable<Tweet>>(stringTask.Result);
                }
        return View(tweetTask.Result);
 }