CalDavSynchronizer.Ui.Options.ViewModels.OptionsCollectionViewModel.Validate C# (CSharp) Method

Validate() private method

private Validate ( string &errorMessage, IOptionsViewModel &firstViewModelWithError ) : bool
errorMessage string
firstViewModelWithError IOptionsViewModel
return bool
    private bool Validate (out string errorMessage, out IOptionsViewModel firstViewModelWithError)
    {
      StringBuilder errorMessageBuilder = new StringBuilder ();
      bool isValid = true;
      firstViewModelWithError = null;

      foreach (var viewModel in _options)
      {
        StringBuilder currentControlErrorMessageBuilder = new StringBuilder ();

        if (!viewModel.Validate (currentControlErrorMessageBuilder))
        {
          if (errorMessageBuilder.Length > 0)
            errorMessageBuilder.AppendLine ();

          errorMessageBuilder.AppendFormat ("Profile '{0}'", viewModel.Name);
          errorMessageBuilder.AppendLine ();
          errorMessageBuilder.Append (currentControlErrorMessageBuilder);

          isValid = false;
          if (firstViewModelWithError == null)
            firstViewModelWithError = viewModel;
        }
      }

      errorMessage = errorMessageBuilder.ToString ();
      return isValid;
    }