Exemple #1
0
        public NetworkFolderChangeWatcher(string serverUrl, IAccountTokenController accountTokenController, string?relativePath = null)
        {
            _serverUrl = new Uri(serverUrl);
            _accountTokenController = accountTokenController;
            if (string.IsNullOrEmpty(relativePath))
            {
                _relativePath = "/";
            }
            else
            {
                var rootPathFragments = relativePath !.Split('/', Path.DirectorySeparatorChar)
                                        .Where(fragment => !string.IsNullOrWhiteSpace(fragment)).ToArray();
                _relativePath = '/' + string.Join("/", rootPathFragments) + '/';
            }

            _cancellationTokenSource = new CancellationTokenSource();
            FolderChanged            = Observable.FromAsync(async token =>
            {
                using var mergedCancellationTokenSource = CancellationTokenSource.CreateLinkedTokenSource(token, _cancellationTokenSource.Token);
                return(await WatchOneChange(mergedCancellationTokenSource.Token).ConfigureAwait(false));
            }).Repeat();
        }
Exemple #2
0
 public BookmarkNetworkService(string baseAddress, IAccountTokenController accountTokenController, string?hierarchyRoot = null, BookmarkHierarchyUtils?bookmarkHierarchyUtils = null)
 {
     if (baseAddress.Last() != '/')
     {
         throw new ArgumentException("URL should end with '/'!", nameof(baseAddress));
     }
     _httpClient = new HttpClient {
         BaseAddress = new Uri($"{baseAddress}{Endpoints.BookmarkControllerRoute}/")
     };
     _accountTokenController = accountTokenController;
     _bookmarkHierarchyUtils = bookmarkHierarchyUtils ?? BookmarkHierarchyUtils.Instance;
     if (hierarchyRoot == null)
     {
         _hierarchyRoot = string.Empty;
     }
     else
     {
         var rootPathFragments = hierarchyRoot.Split('/', Path.DirectorySeparatorChar)
                                 .Where(fragment => !string.IsNullOrWhiteSpace(fragment)).ToArray();
         _hierarchyRoot = string.Join("/", rootPathFragments);
     }
 }