Beispiel #1
0
 private static void ValidateNocMeetingConfigs(StringBuilder errorMessages, IEnumerable <DeviceConfig> deviceConfigs)
 {
     foreach (var deviceConfig in deviceConfigs)
     {
         errorMessages.AppendLineIfNotNull(ValidatorString.Validate($"Device.{nameof(deviceConfig.Identifier)}", deviceConfig.Identifier));
         errorMessages.AppendLineIfNotNull(ValidatorString.Validate($"Device.{nameof(deviceConfig.Type)}", deviceConfig.Type));
         errorMessages.AppendLineIfNotNull(ValidatorString.Validate($"Device.{nameof(deviceConfig.OtaKey)}", deviceConfig.OtaKey));
     }
 }
        public static (string url, string errorMessage) ValidateAndFix(string propertyName, string url)
        {
            var    errorMessage = ValidatorString.Validate(propertyName, url);
            string fixedUrl     = null;

            if (errorMessage == null)
            {
                fixedUrl = url.EndsWith("/", StringComparison.OrdinalIgnoreCase) ? url : url + "/";
            }

            return(fixedUrl, errorMessage);
        }
Beispiel #3
0
        private static void ValidateDeviceServiceSettingsConfig(StringBuilder errorMessages, DeviceServiceSettingsConfig deviceServiceSettingsConfig)
        {
            var(baseUrl, baseUrlErrorMessage)   = ValidatorUrl.ValidateAndFix($"DeviceServiceSettings.{nameof(deviceServiceSettingsConfig.BaseUrl)}", deviceServiceSettingsConfig.BaseUrl);
            deviceServiceSettingsConfig.BaseUrl = baseUrl;
            errorMessages.AppendLineIfNotNull(baseUrlErrorMessage);
            errorMessages.AppendLineIfNotNull(ValidatorString.Validate($"DeviceServiceSettings.{nameof(deviceServiceSettingsConfig.AccessToken)}", deviceServiceSettingsConfig.AccessToken));

            if (!deviceServiceSettingsConfig.DeviceConfigs.Any())
            {
                errorMessages.AppendLine($"The property: \"DeviceServiceSettings.Devices\" collection is Empty. The collection must contain at least 1 item.");
            }
        }
Beispiel #4
0
        private string RetrieveConfigurationSettingValueOrNull(string key)
        {
            var value = RetrieveConfigurationSettingValue(key);

            switch (ValidatorString.DetermineNullEmptyOrWhiteSpaces(value))
            {
            case StringState.Null:
            case StringState.Empty:
            case StringState.WhiteSpaces:
                return(null);

            case StringState.Valid:
            default:
                return(value);
            }
        }