/// <summary> /// /// </summary> /// <param name="locationid">Location id where you want to search</param> /// <param name="objectid">Object id which you want to search</param> /// <returns>Returns true where object exists in location otherwise false</returns> public static bool ExistsById(string locationId, string objectId) { if (string.IsNullOrEmpty(objectId)) { throw new ArgumentNullException("objectId"); } if (string.IsNullOrEmpty(locationId)) { locationId = "me/skydrive"; } foreach (File f in Folder.GetFiles(locationId)) { if (!WLType.IsFolder(f.FType)) { if (string.Compare(f.Id.ToUpper(CultureInfo.InvariantCulture), objectId.ToUpper(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase) == 0) { return(true); } } } return(false); }
/// <summary> /// /// </summary> /// <param name="location">FOLDER_ID</param> /// <param name="name">Name of object which you want to find</param> /// <returns>Return object if object exists in location otherwise null</returns> public static T GetByName(string location, string name) { if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name"); } if (string.IsNullOrEmpty(location)) { location = "me/skydrive"; } name = name.ToUpper(CultureInfo.InvariantCulture); string type = Activator.CreateInstance(typeof(T)).GetType().Name.ToUpper(CultureInfo.InvariantCulture); foreach (File f in Folder.GetFiles(location)) { if (string.Compare(type, WLType.File, StringComparison.Ordinal) == 0 && WLType.IsFile(f.FType)) { if (string.Compare(f.Name.ToUpper(CultureInfo.InvariantCulture), name, StringComparison.OrdinalIgnoreCase) == 0) { return(Get(f.Id)); } } else if ((string.Compare(type, WLType.Folder, StringComparison.Ordinal) == 0 || type == WLType.Album) && WLType.IsFolder(f.FType)) { if (string.Compare(f.Name.ToUpper(CultureInfo.InvariantCulture), name, StringComparison.OrdinalIgnoreCase) == 0) { return(Get(f.Id)); } } else if (string.Compare(type, f.FType.ToUpper(CultureInfo.InvariantCulture), StringComparison.OrdinalIgnoreCase) == 0 && string.Compare(f.Name.ToUpper(CultureInfo.InvariantCulture), name, StringComparison.OrdinalIgnoreCase) == 0) { return(Get(f.Id)); } } return(default(T)); }