Beispiel #1
0
        /// <summary>
        /// Get the file details for the specified resource
        /// </summary>
        /// <param name="resource">A resource to load</param>
        /// <returns>File datails</returns>
        private IResourceDetails GetFileDetails(IResource resource)
        {
            RetryPolicy  retryPolicy  = RetryPolicy ?? RetryPolicy.None;
            RetryCounter retryCounter = new RetryCounter(retryPolicy);
            int          iteration    = 0;
            Tuple <ResourceReadStatus, IResourceDetails> finalStatus = retryCounter.Run(
                () =>
            {
                iteration++;
                ULSLogging.LogTraceTag(0x238208cd /* tag_9669n */, Categories.ConfigurationDataSet, Levels.Verbose,
                                       "Attempting data set load for resource '{0}' in iteration '{1}' of '{2}'.",
                                       resource.Name, iteration, retryPolicy.RetryLimit);

                Tuple <ResourceReadStatus, IResourceDetails> status = resource.Read();
                return(Tuple.Create(status.Item1 == ResourceReadStatus.Success, status));
            });

            if (finalStatus.Item1 != ResourceReadStatus.Success)
            {
                ULSLogging.LogTraceTag(0x238208ce /* tag_9669o */, Categories.ConfigurationDataSet, Levels.Warning,
                                       "Failed to read resource '{0}' as the file read status is '{1}'.",
                                       resource.Name, finalStatus);
                return(null);
            }

            return(finalStatus.Item2);
        }
        private void DoNumberOfCallsTesting(RetryCounter retryCounter, int expectedNumbersOfCall)
        {
            AtomicCounter callsCount = new AtomicCounter();
            int           result     = retryCounter.Run(() => TestFunc(callsCount));

            Assert.Equal(expectedNumbersOfCall, result);
        }