Exemple #1
0
        public static NexusFileURI Deserialize(string json)
        {
            var          uri        = new NexusFileURI();
            MemoryStream ms         = new MemoryStream(Encoding.UTF8.GetBytes(json));
            var          settings   = new DataContractJsonSerializerSettings();
            var          serializer = new DataContractJsonSerializer(typeof(NexusFileURI), settings);

            uri = serializer.ReadObject(ms) as NexusFileURI;
            ms.Close();

            return(uri);
        }
Exemple #2
0
        static public string GetNexusDownloadURL(string url)
        {
            string         downloadURL;
            HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);

            req.ContentType = "application/json";
            req.Headers.Add("APIKEY", apiKey);
            using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
                using (Stream stream = response.GetResponseStream())
                    using (StreamReader reader = new StreamReader(stream))
                    {
                        string s   = reader.ReadToEnd();
                        var    uri = NexusFileURI.Deserialize(s.Trim('[', ']'));
                        downloadURL = uri.URI;

                        //downloadURL = Regex.Match(s, @"""URI"":""(?<url>.+)""").Groups["url"].Value;
                    }

            return(downloadURL);
        }