private void GetFiles_Result(RequestResult result) { if (this.InvokeRequired) { this.Invoke(new Action <RequestResult>(this.GetFiles_Result), result); return; } if (result.StatusCode == 200) { this.listBox1.Items.Clear(); this.listBox1.DisplayMember = "path_display"; foreach (UniValue file in result["entries"]) { listBox1.Items.Add(file); } if (!String.IsNullOrEmpty(this.CurrentPath)) { this.listBox1.Items.Insert(0, UniValue.ParseJson("{path_display: '..'}")); } } else { MessageBox.Show(result.ToString(), "Cannot find files or folders", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public void Clone() { UniValue v = UniValue.Create("test"); UniValue v2 = v.Clone() as UniValue; v2 = "123"; #if !NET35 && !NET40 Assert.NotEqual(v2, v); #endif Assert.False(v2.Equals(v)); var o = new { id = 123, text = "test" }; v = UniValue.Create(o); v2 = v.Clone() as UniValue; v2 = "test"; #if !NET35 && !NET40 Assert.NotEqual(v2, v); #endif Assert.False(v2.Equals(v)); v = UniValue.Create(o); v2 = v; v["id"] = "555"; #if !NET35 && !NET40 Assert.Equal(v, v2); #endif Assert.True(v2.Equals(v)); }
public CloudFiles AddFiles(Dictionary <string, object> items) { UniValue file = UniValue.Create((Dictionary <string, object>)items); var map = new ApiDataMapping(); map.Add("id", "FileID"); map.Add("name", "FileName"); map.Add("@content.downloadUrl", "DownUrl"); map.Add("size", "FileSize", typeof(long)); map.Add("lastModifiedDateTime", "modifiedDate"); FileInfo fi = new FileInfo(file, map); fi.driveinfo = driveinfo; if (fi.Items.CollectionItems.ContainsKey("folder")) { fi.IsFile = false; } else { fi.IsFile = true; fi.Extention = GetExtension(fi.FileName); } fi.Thumnail = GetTumbNail(fi.FileID); OneDriveFile itemss = new OneDriveFile(fi); files.Add(itemss); return(itemss); }
private void btnDownload_Click(object sender, EventArgs e) { if (listView1.FocusedItem == null) { btnDownload.Enabled = mnuDownload.Enabled = false; return; } if (listView1.FocusedItem.Tag == null) { this.CurrentPath = (Path.GetDirectoryName(this.CurrentPath) == "\\" ? "" : Path.GetDirectoryName(this.CurrentPath)); } else { UniValue itm = (UniValue)listView1.FocusedItem.Tag; if (itm[".tag"].Equals("folder")) { this.CurrentPath = itm["path_lower"].ToString(); } else { new Download(itm["path_lower"]) { Owner = this }.Show(); } } }
public UniTypedValue(object value, NameValueCollection attributes, UniValue parent) { base.Key = "value"; base.Data = value; base.Parent = parent; base.Attributes = attributes; }
private void GetFiles_Result(RequestResult result) { if (this.InvokeRequired) { this.Invoke(new Action <RequestResult>(GetFiles_Result), result); return; } if (result.StatusCode == 200) { listBox1.Items.Clear(); listBox1.DisplayMember = "path"; foreach (UniValue file in result["contents"]) { listBox1.Items.Add(file); } if (this.CurrentPath != "/") { listBox1.Items.Insert(0, UniValue.ParseJson("{path: '..'}")); } } else { MessageBox.Show("Error..."); } }
public CloudFiles AddFiles(Dictionary <string, object> items) { UniValue file = UniValue.Create((Dictionary <string, object>)items); var map = new ApiDataMapping(); map.Add("id", "FileID"); map.Add("title", "FileName"); map.Add("fileExtension", "Extention"); map.Add("downloadUrl", "DownUrl"); map.Add("thumbnailLink", "Thumnail"); map.Add("fileSize", "FileSize", typeof(long)); map.Add("modifiedDate", "modifiedDate"); FileInfo fi = new FileInfo(file, map); //fi.Path = "root"; fi.driveinfo = driveinfo; if (fi.Extention != null) { fi.DownUrl = "https://www.googleapis.com/drive/v2/files/" + fi.FileID + "?alt=media"; fi.IsFile = true; } else { fi.Path += fi.FileName + "/"; fi.IsFile = false; } GoogleFile files = new GoogleFile(fi); GoogleFiles.Add(files); return(files); }
private void btnDownload_Click(object sender, EventArgs e) { if (listView1.FocusedItem == null) { btnDownload.Enabled = mnuDownload.Enabled = false; return; } if (listView1.FocusedItem.Tag == null) { this.CurrentPath = (Path.GetDirectoryName(this.CurrentPath) == "\\" ? "" : Path.GetDirectoryName(this.CurrentPath)); } else { UniValue itm = (UniValue)listView1.FocusedItem.Tag; if (Convert.ToBoolean(itm["is_dir"])) { this.CurrentPath = itm["path"].ToString(); } else { new Download ( String.Format("https://api-content.dropbox.com/1/files/auto{0}", itm["path"]) ) { Owner = this }.Show(); } } }
private static string GetUserInfoRequest(UniValue param) { if (param == null) { return(null); } var parameters = new NameValueCollection { { "uids", param["uid"].ToString() } }; var getUserInfoRequest = Nemiro.OAuth.OAuthUtility.ExecuteRequest ( "GET", "https://api.vk.com/method/users.get", parameters, null ); string userName = String.Empty; foreach (UniValue item in getUserInfoRequest["response"]) { userName = String.Format("{0} {1}", item["first_name"], item["last_name"]); } return(userName); }
private void GetFilesSearch_Result(RequestResult result) { if (!Dispatcher.CheckAccess()) { Dispatcher.Invoke(new Action <RequestResult>(GetFilesSearch_Result), result); return; } if (result.StatusCode == 200) { this.MyListBox.Items.Clear(); this.MyListBox.DisplayMemberPath = "metadata"; foreach (UniValue file in result["matches"]) { MyListBox.Items.Add(file); } if (!String.IsNullOrEmpty(this.CurrentPath)) { this.MyListBox.Items.Insert(0, UniValue.ParseJson("{path_display: '..'}")); } } else { MessageBox.Show(result.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void Download_Load(object sender, EventArgs e) { if (this.saveFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK) { this.Close(); return; } this.FileStream = new FileStream(this.saveFileDialog1.FileName, FileMode.Create, FileAccess.Write); this.Writer = new BinaryWriter(this.FileStream); var req = WebRequest.Create("https://content.dropboxapi.com/2/files/download"); req.Method = "POST"; req.Headers.Add(HttpRequestHeader.Authorization, String.Format("Bearer {0}", Properties.Settings.Default.AccessToken)); req.Headers.Add("Dropbox-API-Arg", UniValue.Create(new { path = this.FilePath }).ToString()); req.BeginGetResponse(result => { var resp = req.EndGetResponse(result); this.SafeInvoke(() => { this.progressBar1.Maximum = (int)resp.ContentLength; this.Text = String.Format("Loading '{0}' ({1}%)", this.LoadingFileName, 0); }); // get response stream this.Reader = resp.GetResponseStream(); // read async this.Reader.BeginRead(this.ReadBuffer, 0, this.ReadBuffer.Length, this.ReadCallback, null); }, null); }
public void downloadFileFromDropbox() { if (drop_Files.Count == 0) { this.GetFiles(); } else { //mainForm.saveFileDialog1.FileName = Path.GetFileName(drop_Files[0].ToString()); //if (mainForm.saveFileDialog1.ShowDialog() != DialogResult.OK) //{ // return; //} foreach (UniValue file in drop_Files) { var web = new WebClient(); UniValue str1 = file; String str2 = Properties.Settings.Default.AccessToken; String url = String.Format("https://content.dropboxapi.com/1/files/auto" + str1 + "?access_token=" + str2); web.DownloadProgressChanged += DownloadProgressChange; //web.DownloadFileAsync(new Uri(url), ConstantPath.jsonPath + Path.GetFileName(file.ToString())); web.DownloadFile(new Uri(url), ConstantPath.jsonPath + Path.GetFileName(file.ToString())); } } }
private void listBox1_DoubleClick(object sender, EventArgs e) { if (listBox1.SelectedItem == null) { return; } UniValue file = (UniValue)listBox1.SelectedItem; if (file["path"] == "..") { if (this.CurrentPath != "/") { this.CurrentPath = Path.GetDirectoryName(this.CurrentPath).Replace("\\", "/"); } } else { if (file["is_dir"] == 1) { this.CurrentPath = file["path"].ToString(); } else { saveFileDialog1.FileName = Path.GetFileName(file["path"].ToString()); if (saveFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } var web = new WebClient(); web.DownloadProgressChanged += DownloadProgressChanged; web.DownloadFileAsync(new Uri(String.Format("https://api-content.dropbox.com/1/files/auto{0}?access_token={1}", file["path"], Properties.Settings.Default.AccessToken)), saveFileDialog1.FileName); } } this.GetFiles(); }
private void GetFiles_Result(RequestResult result) { if (this.InvokeRequired) { this.Invoke(new Action <RequestResult>(GetFiles_Result), result); return; } this.Cursor = Cursors.Default; if (Enumerable.Range(200, 100).Contains(result.StatusCode)) // result.StatusCode == 200 { listBox1.Items.Clear(); listBox1.DisplayMember = "name"; foreach (UniValue file in result["value"]) { listBox1.Items.Add(file); } if (!String.IsNullOrEmpty(this.CurrentFolderId)) { listBox1.Items.Insert(0, UniValue.Create(new { name = "..", toup = true })); } } else { this.ShowError(result); } }
private void listView2_DoubleClick(object sender, EventArgs e) { if (listView2.SelectedItems == null) { return; } UniValue file = (UniValue)listView2.SelectedItems[0].Tag; if (file["path"] == "..") { if (CurrentPath != "/") { CurrentPath = Path.GetDirectoryName(CurrentPath).Replace("\\", "/"); } } else { if (file["is_dir"] == 1) { CurrentPath = file["path"].ToString(); } else { //saveFileDialog1.FileName = Path.GetFileName(file["path"].ToString()); //if (saveFileDialog1.ShowDialog() != DialogResult.OK) { return; } //var web = new WebClient(); //web.DownloadProgressChanged += Web_DownloadProgressChanged; //web.DownloadFileAsync(new Uri(String.Format("https://content.dropboxapi.com/1/files/auto/{0}?access_token={1}", file["path"], Properties.Settings.Default.AccessToken)), saveFileDialog1.FileName); GetPreviewFile(file["path"].ToString()); } } GetFiles(); }
private void GetFiles_Result(RequestResult result) { if (this.InvokeRequired) { this.Invoke(new Action <RequestResult>(GetFiles_Result), result); return; } this.Cursor = Cursors.Default; if (result.StatusCode == 200) { listBox1.Items.Clear(); listBox1.DisplayMember = "name"; foreach (UniValue file in result["_embedded"]["items"]) { listBox1.Items.Add(file); } if (this.CurrentPath != "/") { listBox1.Items.Insert(0, UniValue.ParseJson("{name: '..'}")); } } else { this.ShowErrorMessage(result); } }
public void UniValue_Enumerator() { Console.WriteLine("Test 1"); UniValue value = UniValue.ParseXml("<response><item>1</item><item>2</item><item>3</item></response>"); Console.WriteLine(value); foreach (UniValue itm in value.First()["item"]) { Console.WriteLine(itm); if (!(itm == "1" || itm == 2 || itm == "3")) { Assert.Fail(); } } Console.WriteLine("-------------------------------------"); Console.WriteLine("Test 2"); value = UniValue.ParseXml("<response><item>1</item><item>2</item><item>3</item></response>"); Console.WriteLine(value); foreach (UniValue itm in value["response"]["item"].First()) { Console.WriteLine(itm); if (itm != "1") { Assert.Fail(); } } }
/// <summary> /// Handler of event to receive notification when the document finishes loading. /// </summary> /// <param name="webBrowser">The <see cref="System.Windows.Forms.WebBrowser"/> instance.</param> /// <param name="url">The loaded url.</param> public void WebDocumentLoaded(System.Windows.Forms.WebBrowser webBrowser, Uri url) { if (url.Fragment.IndexOf("code=") != -1) { // is result var v = UniValue.ParseParameters(url.Fragment.Substring(1)); this.GetAccessToken(v["code"].ToString()); } }
public void UniValueTest() { // Serialize var value = UniValue.Create(123); var bf = new BinaryFormatter(); var m = new MemoryStream(); bf.Serialize(m, value); // Deserialize m.Position = 0; var value2 = (UniValue)bf.Deserialize(m); Assert.Equal(value2, value); var value3 = UniValue.ParseXml("<items><item>1</item><item>2</item><item>3</item></items>");//UniValue.Create(new { id = 123, a = new HttpUrlParameter("test", null), text = "hello", list = new object[] { 1, 2, 3, 4, 5, 6, 7 } }); var bf2 = new BinaryFormatter(); var m2 = new MemoryStream(); bf.Serialize(m2, value3.First()); // Deserialize m2.Position = 0; var value4 = (UniValue)bf.Deserialize(m2); Assert.Equal(value4.ToString(), value3.First().ToString()); value3 = UniValue.ParseXml("<items><item>1</item><item>2</item><item>3</item></items>");//UniValue.Create(new { id = 123, a = new HttpUrlParameter("test", null), text = "hello", list = new object[] { 1, 2, 3, 4, 5, 6, 7 } }); bf2 = new BinaryFormatter(); m2 = new MemoryStream(); bf.Serialize(m2, value3); // Deserialize m2.Position = 0; value4 = (UniValue)bf.Deserialize(m2); Assert.Equal(value4.ToString(), value3.ToString()); value3 = UniValue.Create(new { id = 123, a = new HttpUrlParameter("test", null), text = "hello", list = new object[] { 1, 2, 3, 4, 5, 6, 7 } }); m2 = new MemoryStream(); bf.Serialize(m2, value3); m2.Position = 0; value4 = (UniValue)bf.Deserialize(m2); Assert.Equal(value4.ToString(), value3.ToString()); }
protected void Apply(UniFields other, string key) { if (uifields.ContainsKey(key)) { other[key] = new UniValue(uifields[key]); } else if (other.ContainsKey(key)) { other.Remove(key); } }
private void btnDownload_Click(object sender, RoutedEventArgs e) { if (MyListBox.SelectedItem == null) { return; } var file = (UniValue)this.MyListBox.SelectedItem; if (file[".tag"].Equals("folder")) { // this.CurrentPath = file["path_display"].ToString(); MessageBox.Show("Cannot download folder, please select a file"); return; } SaveFileDialog SaveF = new SaveFileDialog(); SaveF.FileName = System.IO.Path.GetFileName(file["path_display"].ToString()); Nullable <bool> result = SaveF.ShowDialog(); if (result.HasValue && result.Value == false) { return; } this.DownloadFileStream = new FileStream(SaveF.FileName, FileMode.Create, FileAccess.Write); this.DownloadWriter = new BinaryWriter(this.DownloadFileStream); var req = WebRequest.Create("https://content.dropboxapi.com/2/files/download"); req.Method = "GET"; req.Headers.Add(HttpRequestHeader.Authorization, this.Authorization.ToString()); req.Headers.Add("Dropbox-API-Arg", UniValue.Create(new { path = file["path_display"].ToString() }).ToString()); req.BeginGetResponse(resultB => { var resp = req.EndGetResponse(resultB); this.DownloadReader = resp.GetResponseStream(); this.DownloadReader.BeginRead(this.DownloadReadBuffer, 0, this.DownloadReadBuffer.Length, this.DownloadReadCallback, null); }, null); this.Getfiles(); }
public static void SetUDMFField(MapElement element, string key, DynValue value) { if (!General.Map.FormatInterface.HasCustomFields) { ScriptContext.context.WarnFormatIncompatible("UDMF fields not supported."); return; } if (key == null) { throw new ScriptRuntimeException("key is nil, can't SetUDMFField() (not enough arguments maybe?)"); } if (element == null) { throw new ScriptRuntimeException("map element is nil, can't SetUDMFField()"); } if (element.IsDisposed) { throw new ScriptRuntimeException("map element is disposed, can't SetUDMFField()"); } if (value.IsNilOrNan() || value.IsVoid()) { throw new ScriptRuntimeException("value is nil, nan, or void. can't SetUDMFField() (not enough arguments maybe?) " + value.ToObject().GetType().ToString()); } key = UniValue.ValidateName(key); if (key == "") { return; } object v_object = value.ToObject(); if (v_object is double) { v_object = (float)((double)v_object); } try { element.SetField(key, v_object); } catch (ArgumentException) { throw new ScriptRuntimeException("error setting UDMF field " + key + ", must be int, float, string, double or bool, instead was " + v_object.GetType().ToString()); } }
public void IsNullOrEmpty() { UniValue v = null; Assert.True(UniValue.IsNullOrEmpty(v)); v = "123"; Assert.False(UniValue.IsNullOrEmpty(v)); Assert.False(UniValue.IsNullOrEmpty(1)); Assert.False(UniValue.IsNullOrEmpty("test")); Assert.True(UniValue.IsNullOrEmpty(UniValue.Empty)); Assert.False(UniValue.IsNullOrEmpty(UniValue.Create(DateTime.Now))); Assert.True(UniValue.IsNullOrEmpty(UniValue.Create())); }
public void ParseParameters() { #if NET35 Assert.Throws <InvalidDataException>(() => UniValue.ParseParameters("test,1,#2,$3\r\n")); #elif NET40 Assert.Throws <InvalidDataException>(() => UniValue.ParseParameters("test,1,#2,$3\r\n")); #else Assert.ThrowsAny <InvalidDataException>(() => UniValue.ParseParameters("test,1,#2,$3\r\n")); #endif UniValue r = UniValue.Empty; Assert.False(UniValue.TryParseParameters("test,1,#2,$3\r\n", out r)); Assert.True(UniValue.TryParseParameters("a=1&b=2&c=3", out r)); }
internal static bool IsEmpty(object value) { if (value == DBNull.Value || value == null) { return(true); } if (value.GetType() == typeof(string)) { return(String.IsNullOrEmpty(value.ToString())); } if (value.GetType() == typeof(UniValue) || value.GetType().IsSubclassOf(typeof(UniValue))) { return(UniValue.IsNullOrEmpty((UniValue)value)); } return(false); }
public void Enumerator() { UniValue value = UniValue.ParseXml("<response><item>1</item><item>2</item><item>3</item></response>"); foreach (UniValue itm in value.First()["item"]) { Assert.True(itm == "1" || itm == 2 || itm == "3"); } value = UniValue.ParseXml("<response><item>1</item><item>2</item><item>3</item></response>"); foreach (UniValue itm in value["response"]["item"].First()) { Assert.Equal("1", itm.ToString()); } }
private void button2_Click(object sender, EventArgs e) { progressBar1.Value = 0; if (openFileDialog1.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } object parents = null; if (!String.IsNullOrEmpty(this.CurrentFolderId)) { parents = new object[] { new { id = this.CurrentFolderId } }; } UniValue properties = UniValue.Create ( new { title = Path.GetFileName(openFileDialog1.FileName), parents = parents } ); var file = openFileDialog1.OpenFile(); this.CurrentFileLength = file.Length; var parameters = new HttpParameterCollection(); parameters.Add("uploadType", "multipart"); parameters.AddContent("application/json", properties.ToString()); parameters.AddContent("application/octet-stream", file); OAuthUtility.PostAsync ( "https://www.googleapis.com/upload/drive/v2/files", parameters, authorization: new HttpAuthorization(AuthorizationType.Bearer, Properties.Settings.Default.AccessToken), contentType: "multipart/related", // handler of result callback: Upload_Result, // handler of uploading streamWriteCallback: Upload_Processing ); }
private string GetErrorMessage(UniValue value) { if (value["error_message"].HasValue) { return(value["error_message"].ToString()); } else if (value["error_description"].HasValue) { return(value["error_description"].ToString()); } else if (value["error"].HasValue) { return(value["error"].ToString()); } return(null); }
private void GetFiles_Result(RequestResult result) { if (this.InvokeRequired) { this.Invoke(new Action <RequestResult>(GetFiles_Result), result); return; } this.Cursor = Cursors.Default; if (result.StatusCode == 200) { listBox1.Items.Clear(); listBox1.DisplayMember = "title"; foreach (UniValue file in result["items"]) { listBox1.Items.Add(file); } if (!String.IsNullOrEmpty(this.CurrentFolderId)) { listBox1.Items.Insert(0, UniValue.Create(new { title = "..", toup = true })); } } else { if (result["error"]["errors"].Count > 0) { if (result["error"]["errors"][0]["reason"].Equals("authError", StringComparison.OrdinalIgnoreCase)) { this.GetAccessToken(); } else { MessageBox.Show(result["error"]["errors"][0]["message"].ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show(result.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public Tweet(UniValue data) { InitializeComponent(); Dock = DockStyle.Top; Username.Text = String.Format("@{0}", data["user"]["screen_name"]); Nickname.Text = data["user"]["name"].ToString(); TweetText.Text = data["text"].ToString(); var created = System.DateTime.ParseExact(data["created_at"].ToString(), "ddd MMM dd HH:mm:ss zzzz yyyy", System.Globalization.CultureInfo.InvariantCulture); if (DateTime.Now.Day == created.Day && DateTime.Now.Month == created.Month && DateTime.Now.Year == created.Year) { DateCreated.Text = created.ToString("HH:mm"); } else if (DateTime.Now.Year != created.Year) { DateCreated.Text = created.ToString("dd MMMM yyyy"); } else { DateCreated.Text = created.ToString("dd MMMM"); } if (data["user"]["profile_image_url"].HasValue && !String.IsNullOrEmpty(data["user"]["profile_image_url"].ToString())) { UserpicPath = Path.Combine(Tweet.CachePath, String.Format("{0}.jpg", this.GetMD5Hash(data["user"]["profile_image_url"].ToString()))); if (File.Exists(this.UserpicPath) && Tweet.LoadingPics.IndexOf(this.UserpicPath) == -1) { Userpic.Image = Image.FromFile(this.UserpicPath); Userpic.SizeMode = PictureBoxSizeMode.StretchImage; } else if (File.Exists(this.UserpicPath) && Tweet.LoadingPics.IndexOf(this.UserpicPath) != -1) { timer1.Enabled = true; } else { DownloadUserpic(data["user"]["profile_image_url"].ToString(), this.UserpicPath); timer1.Enabled = true; } } }
/// <summary> /// Initializes a new instance of the <see cref="UserInfo"/> class. /// </summary> /// <param name="source">The data source.</param> /// <param name="mapping">The mapping rules.</param> public UserInfo(UniValue source, ApiDataMapping mapping) { if (mapping == null || !source.HasValue) { return; } this.Items = source; var t = typeof(UserInfo); foreach (var p in t.GetProperties()) { var item = mapping.FirstOrDefault(itm => itm.DestinationName.Equals(p.Name, StringComparison.OrdinalIgnoreCase)); if (item != null && source.ContainsKey(item.SourceName)) { object vr = null; UniValue vs = source[item.SourceName]; if (item.Parse != null) { vr = item.Parse(vs); } else { if (item.Type == typeof(DateTime)) { var f = new CultureInfo(Thread.CurrentThread.CurrentCulture.Name, true); var formatDateTime = "dd.MM.yyyy HH:mm:ss"; if (!String.IsNullOrEmpty(item.Format)) { formatDateTime = item.Format; } f.DateTimeFormat.FullDateTimePattern = formatDateTime; f.DateTimeFormat.ShortDatePattern = formatDateTime; DateTime dateValue; if (DateTime.TryParse(vs.ToString(), f, DateTimeStyles.NoCurrentDateDefault, out dateValue)) { vr = dateValue; } else { vr = null; } } else if (item.Type == typeof(bool)) { vr = Convert.ToBoolean(vs); } else if (item.Type == typeof(Int16)) { vr = Convert.ToInt16(vs); } else if (item.Type == typeof(Int32)) { vr = Convert.ToInt32(vs); } else if (item.Type == typeof(Int64)) { vr = Convert.ToInt64(vs); } else if (item.Type == typeof(UInt16)) { vr = Convert.ToUInt16(vs); } else if (item.Type == typeof(UInt32)) { vr = Convert.ToUInt32(vs); } else if (item.Type == typeof(UInt64)) { vr = Convert.ToUInt64(vs); } else if (item.Type == typeof(double)) { vr = Convert.ToDouble(vs); } else if (item.Type == typeof(Single)) { vr = Convert.ToSingle(vs); } else if (item.Type == typeof(decimal)) { vr = Convert.ToDecimal(vs); } else if (item.Type == typeof(byte)) { vr = Convert.ToByte(vs); } else if (item.Type == typeof(char)) { vr = Convert.ToChar(vs); } else if (item.Type == typeof(string)) { vr = Convert.ToString(vs); } else { vr = Convert.ToString(vs); } } p.SetValue(this, vr, null); } } }
/// <summary> /// Initializes a new instance of the <see cref="OAuthAuthorization"/> class with specific value. /// </summary> public OAuthAuthorization(UniValue value) : base(AuthorizationType.OAuth, value) { this.DefaultInit(); }
private Image GetIcon(UniValue file) { Stream stream = this.GetType().Assembly.GetManifestResourceStream(string.Format("FolderExplorer.Resources.DropboxIcons.{0}.gif", file["icon"])); return Image.FromStream(stream); }
/// <summary> /// Initializes a new instance of the <see cref="OAuthAuthorization"/> class with specific authorization type and value. /// </summary> public HttpAuthorization(AuthorizationType type, UniValue value) { this.AuthorizationType = type; this.Value = value; }
private static string GetUserInfoRequest(UniValue param) { if (param == null) return null; var parameters = new NameValueCollection { { "uids", param["uid"].ToString() } }; var getUserInfoRequest = Nemiro.OAuth.OAuthUtility.ExecuteRequest ( "GET", "https://api.vk.com/method/users.get", parameters, null ); string userName = String.Empty; foreach (UniValue item in getUserInfoRequest["response"]) { userName = String.Format("{0} {1}", item["first_name"], item["last_name"]); } return userName; }
public DropBoxFile(UniValue value) { this.file = value; }