public ICollection <Share> CreateDefaultShares() { List <Share> result = new List <Share>(); Guid localFsResourceProviderId = LocalFsResourceProviderBase.LOCAL_FS_RESOURCE_PROVIDER_ID; if (LocalResourceProviders.ContainsKey(localFsResourceProviderId)) { string folderPath; if (WindowsAPI.GetSpecialFolder(WindowsAPI.SpecialFolder.MyMusic, out folderPath)) { folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath); string[] mediaCategories = new[] { DefaultMediaCategories.Audio.ToString() }; Share sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath), MY_MUSIC_SHARE_NAME_RESOURE, mediaCategories); result.Add(sd); } if (WindowsAPI.GetSpecialFolder(WindowsAPI.SpecialFolder.MyVideos, out folderPath)) { folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath); string[] mediaCategories = new[] { DefaultMediaCategories.Video.ToString() }; Share sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath), MY_VIDEOS_SHARE_NAME_RESOURCE, mediaCategories); result.Add(sd); } if (WindowsAPI.GetSpecialFolder(WindowsAPI.SpecialFolder.MyPictures, out folderPath)) { folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath); string[] mediaCategories = new[] { DefaultMediaCategories.Image.ToString() }; Share sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath), MY_PICTURES_SHARE_NAME_RESOURCE, mediaCategories); result.Add(sd); } } if (result.Count > 0) { return(result); } // Fallback: If no share was added for the defaults above, use the provider's root folders result.AddRange(LocalBaseResourceProviders.Select(resourceProvider => resourceProvider.Metadata).Select( metadata => Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(metadata.ResourceProviderId, "/"), metadata.Name, null))); return(result); }
public ICollection <Share> CreateDefaultShares() { List <Share> result = new List <Share>(); Guid localFsResourceProviderId = LocalFsResourceProviderBase.LOCAL_FS_RESOURCE_PROVIDER_ID; if (LocalResourceProviders.ContainsKey(localFsResourceProviderId)) { string folderPath; if (WindowsAPI.GetSpecialFolder(Environment.SpecialFolder.MyMusic, out folderPath)) { folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath); string[] mediaCategories = new[] { DefaultMediaCategories.Audio.ToString() }; Share sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath), MY_MUSIC_SHARE_NAME_RESOURE, true, mediaCategories); result.Add(sd); } if (WindowsAPI.GetSpecialFolder(Environment.SpecialFolder.MyVideos, out folderPath)) { folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath); string[] mediaCategories = new[] { DefaultMediaCategories.Video.ToString() }; Share sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath), MY_VIDEOS_SHARE_NAME_RESOURCE, true, mediaCategories); result.Add(sd); } if (WindowsAPI.GetSpecialFolder(Environment.SpecialFolder.MyPictures, out folderPath)) { folderPath = LocalFsResourceProviderBase.ToProviderPath(folderPath); string[] mediaCategories = new[] { DefaultMediaCategories.Image.ToString() }; Share sd = Share.CreateNewLocalShare(ResourcePath.BuildBaseProviderPath(localFsResourceProviderId, folderPath), MY_PICTURES_SHARE_NAME_RESOURCE, true, mediaCategories); result.Add(sd); } } return(result); }