/// <summary> /// Deserialization json data to DiskInfo /// </summary> /// <param name="content">String json for deserialization</param> /// <returns>Structure DiskInfo</returns> public static DiskInfo GetDiskInfo(string content) { DiskInfo diskInfo = new DiskInfo(); System_folders system_folders = new System_folders(); User user = new User(); ErrorResponse errorResponse = new ErrorResponse(); if (!string.IsNullOrEmpty(content)) { JObject json = JObject.Parse(content); diskInfo.Max_file_size = (long?)json.SelectToken("max_file_size"); diskInfo.Unlimited_autoupload_enabled = (bool?)json.SelectToken("unlimited_autoupload_enabled"); diskInfo.Total_space = (long?)json.SelectToken("total_space"); diskInfo.Trash_size = (long?)json.SelectToken("trash_size"); diskInfo.Is_paid = (bool?)json.SelectToken("is_paid"); diskInfo.Used_space = (long?)json.SelectToken("used_space"); system_folders.Odnoklassniki = (string)json.SelectToken("system_folders.odnoklassniki"); system_folders.Google = (string)json.SelectToken("system_folders.google"); system_folders.Instagram = (string)json.SelectToken("system_folders.instagram"); system_folders.Vkontakte = (string)json.SelectToken("system_folders.vkontakte"); system_folders.Mailru = (string)json.SelectToken("system_folders.mailru"); system_folders.Downloads = (string)json.SelectToken("system_folders.downloads"); system_folders.Applications = (string)json.SelectToken("system_folders.applications"); system_folders.Facebook = (string)json.SelectToken("system_folders.facebook"); system_folders.Social = (string)json.SelectToken("system_folders.social"); system_folders.Screenshots = (string)json.SelectToken("system_folders.screenshots"); system_folders.Photostream = (string)json.SelectToken("system_folders.photostream"); diskInfo.System_folders = system_folders; user.Login = (string)json.SelectToken("user.login"); user.Uid = (string)json.SelectToken("user.uid"); diskInfo.User = user; diskInfo.Revision = (long?)json.SelectToken("revision"); diskInfo.ErrorResponse = errorResponse.GetError(content); } return(diskInfo); }
/// <summary> /// Get meta information about disk, by default return all fields /// </summary> /// <param name="fields">Array returned fields . Example use 'new DiskFields[] {DiskFields.Used_space, DiskFields.Unlimited_autoupload_enabled, DiskFields.System_folders}'</param> /// <returns>DiskInfo structure</returns> public DiskInfo GetDiskInfo(DiskFields[] fields = null) { string content; DiskInfo diskInfo = new DiskInfo(); Param param = new Param(); if (fields != null) { foreach (DiskFields i in fields) { param.Fields += i + ","; } param.Fields = param.Fields.Remove(param.Fields.Length - 1); } content = CommandDisk(Oauth, YandexDiskAsk.Get_meta_information_about_disk_user, param); if (content != null) { diskInfo = DiskInfo.GetDiskInfo(content); } return(diskInfo); }