private static void ValidateProactiveCopies(DistributedContentSettings settings, ICollection <string> errors)
 {
     if (settings.ProactiveCopyUsePreferredLocations && !settings.UseBinManager)
     {
         errors.Add($"For {nameof(settings.ProactiveCopyUsePreferredLocations)} to be true, {nameof(settings.UseBinManager)} should also be true.");
     }
 }
        public static IReadOnlyList <string> Validate(this DistributedContentSettings settings)
        {
            var errorList = new List <string>();

            ValidateProactiveCopies(settings, errorList);
            ValidateDataAnnotations(settings, errorList);

            return(errorList);
        }
 public DistributedCacheServiceConfiguration(
     LocalCasSettings localCasSettings,
     DistributedContentSettings distributedCacheSettings,
     LoggingSettings loggingSettings = null)
 {
     LocalCasSettings           = localCasSettings;
     DistributedContentSettings = distributedCacheSettings;
     LoggingSettings            = loggingSettings;
 }
        private static void ValidateDataAnnotations(DistributedContentSettings settings, ICollection <string> errorList)
        {
            var validationResults = new List <ValidationResult>();

            if (!Validator.TryValidateObject(settings, new ValidationContext(settings), validationResults, validateAllProperties: true))
            {
                foreach (var result in validationResults)
                {
                    if (result != ValidationResult.Success)
                    {
                        errorList.Add(result.ErrorMessage !);
                    }
                }
            }
        }
示例#5
0
 public static DistributedContentSettings CreateForCloudBuildCacheCacheFactory(DistributedContentSettings distributedSettings)
 {
     return(new DistributedContentSettings
     {
         IsBandwidthCheckEnabled = distributedSettings.IsBandwidthCheckEnabled,
         IsDistributedEvictionEnabled = distributedSettings.IsDistributedEvictionEnabled,
         AlternateDriveMap =
             distributedSettings.GetAutopilotAlternateDriveMap().ToDictionary(kvp => kvp.Key, kvp => kvp.Value)
     });
 }