/// <summary> /// Returns a list of address book files that correspont to the specified list of item paths. /// </summary> /// <remarks> /// <para> /// This method is called by the Engine during <b>addressbook-multiget</b> call. /// </para> /// <para> /// For each item from the <b>pathList</b> parameter return an item that corresponds to path or <b>null</b> if the item is not found. /// </para> /// </remarks> /// <param name="pathList">Addressbook files path list.</param> /// <param name="propNames"> /// Properties requested by the client. You can use this as a hint about what properties will be called by /// the Engine for each item that are returned from this method. /// </param> /// <returns>List of address book files. Returns <b>null</b> for any item that is not found.</returns> public async Task <IEnumerable <ICardFileAsync> > MultiGetAsync(IEnumerable <string> pathList, IEnumerable <PropertyName> propNames) { // Get list of file names from path list. IEnumerable <string> fileNames = pathList.Select(a => System.IO.Path.GetFileNameWithoutExtension(a)); return(await CardFile.LoadByFileNamesAsync(Context, fileNames, PropsToLoad.All)); }
/// <summary> /// Gets CardDAV items. /// </summary> /// <param name="path">Relative path requested.</param> /// <param name="context">Instance of <see cref="DavContext"/> class.</param> /// <returns>Object implementing various business card items or null if no object corresponding to path is found.</returns> public static async Task <IHierarchyItemAsync> GetCardDavItemAsync(DavContext context, string path) { // If this is [DAVLocation]/addressbooks - return folder that contains all addressbooks. if (path.Equals(AddressbooksRootFolder.AddressbooksRootFolderPath.Trim('/'), System.StringComparison.InvariantCultureIgnoreCase)) { return(new AddressbooksRootFolder(context)); } string[] segments = path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries); // If URL ends with .vcf - return address book file, which contains vCard. if (path.EndsWith(CardFile.Extension, System.StringComparison.InvariantCultureIgnoreCase)) { string fileName = EncodeUtil.DecodeUrlPart(System.IO.Path.GetFileNameWithoutExtension(segments.Last())); return((await CardFile.LoadByFileNamesAsync(context, new[] { fileName }, PropsToLoad.All)).FirstOrDefault()); } // If this is [DAVLocation]/addressbooks/[AddressbookFolderId]/ return address book. if (path.StartsWith(AddressbooksRootFolder.AddressbooksRootFolderPath.Trim('/'), System.StringComparison.InvariantCultureIgnoreCase)) { Guid addressbookFolderId; if (Guid.TryParse(EncodeUtil.DecodeUrlPart(segments.Last()), out addressbookFolderId)) { return(await AddressbookFolder.LoadByIdAsync(context, addressbookFolderId)); } } return(null); }