예제 #1
0
        public override void Validate(string propertyName = null)
        {
            base.Validate(propertyName);

            string currentProperty = nameof(DownloadParams);

            if (string.IsNullOrWhiteSpace(propertyName) || propertyName == currentProperty)
            {
                DownloadParams?.Validate();

                if (_twitchService.IsFileNameUsed(_downloadParams.FullPath))
                {
                    DownloadParams.AddError(nameof(DownloadParams.Filename), "Another video is already being downloaded to this file!");
                }

                if (DownloadParams.HasErrors)
                {
                    AddError(currentProperty, "Invalid Download Parameters!");

                    if (DownloadParams.GetErrors(nameof(DownloadParameters.CropStartTime)) is List <string> cropStartErrors && cropStartErrors.Count > 0)
                    {
                        string firstError = cropStartErrors.First();
                        AddError(nameof(CropStartHours), firstError);
                        AddError(nameof(CropStartMinutes), firstError);
                        AddError(nameof(CropStartSeconds), firstError);
                    }

                    if (DownloadParams.GetErrors(nameof(DownloadParameters.CropEndTime)) is List <string> cropEndErrors && cropEndErrors.Count > 0)
                    {
                        string firstError = cropEndErrors.First();
                        AddError(nameof(CropEndHours), firstError);
                        AddError(nameof(CropEndMinutes), firstError);
                        AddError(nameof(CropEndSeconds), firstError);
                    }

                    if (DownloadParams.GetErrors(nameof(DownloadParameters.AutoSplitTime)) is List <string> autoSplitTimeErrors && autoSplitTimeErrors.Count > 0)
                    {
                        string firstError = autoSplitTimeErrors.First();
                        AddError(nameof(AutoSplitTimeHours), firstError);
                        AddError(nameof(AutoSplitTimeMinutes), firstError);
                        AddError(nameof(AutoSplitTimeSeconds), firstError);
                        AddError(nameof(AutoSplitUseExtended), firstError);
                    }

                    if (DownloadParams.GetErrors(nameof(DownloadParameters.AutoSplitOverlap)) is List <string> overlapErrors && overlapErrors.Count > 0)
                    {
                        string firstError = overlapErrors.First();
                        AddError(nameof(AutoSplitUseExtended), firstError);
                    }
                }
            }
        }
예제 #2
0
        public override void Validate(string propertyName = null)
        {
            base.Validate(propertyName);

            string currentProperty = nameof(DownloadParams);

            if (string.IsNullOrWhiteSpace(propertyName) || propertyName == currentProperty)
            {
                DownloadParams?.Validate();

                if (_twitchService.IsFileNameUsed(_downloadParams.FullPath))
                {
                    DownloadParams.AddError(nameof(DownloadParams.Filename), "Another video is already being downloaded to this file!");
                }

                if (DownloadParams.HasErrors)
                {
                    AddError(currentProperty, "Invalid Download Parameters!");
                }
            }

            currentProperty = nameof(CropStartTime);

            if (string.IsNullOrWhiteSpace(propertyName) || propertyName == currentProperty)
            {
                DownloadParams?.Validate(currentProperty);

                if (DownloadParams.HasErrors)
                {
                    if (DownloadParams.GetErrors(currentProperty) is List <string> errors && errors.Count > 0)
                    {
                        AddError(currentProperty, errors.First());
                    }
                }
            }

            currentProperty = nameof(CropEndTime);

            if (string.IsNullOrWhiteSpace(propertyName) || propertyName == currentProperty)
            {
                DownloadParams?.Validate(currentProperty);

                if (DownloadParams.HasErrors)
                {
                    if (DownloadParams.GetErrors(currentProperty) is List <string> errors && errors.Count > 0)
                    {
                        AddError(currentProperty, errors.First());
                    }
                }
            }
        }
예제 #3
0
        public override void Validate(string propertyName = null)
        {
            base.Validate(propertyName);

            string currentProperty = nameof(DownloadParams);

            if (string.IsNullOrWhiteSpace(propertyName) || propertyName == currentProperty)
            {
                DownloadParams?.Validate();

                if (_downloadParams.FullPath.Length > 250)
                {
                    DownloadParams.AddError(nameof(DownloadParams.Filename), "The full filename (directory + filename) must be shorter than 250 characters!");
                }

                if (_twitchService.IsFileNameUsed(_downloadParams.FullPath))
                {
                    DownloadParams.AddError(nameof(DownloadParams.Filename), "Another video is already being downloaded to this file!");
                }

                if (DownloadParams.HasErrors)
                {
                    AddError(currentProperty, "Invalid Download Parameters!");

                    if (DownloadParams.GetErrors(nameof(DownloadParameters.CropStartTime)) is List <string> cropStartErrors && cropStartErrors.Count > 0)
                    {
                        string firstError = cropStartErrors.First();
                        AddError(nameof(CropStartHours), firstError);
                        AddError(nameof(CropStartMinutes), firstError);
                        AddError(nameof(CropStartSeconds), firstError);
                    }

                    if (DownloadParams.GetErrors(nameof(DownloadParameters.CropEndTime)) is List <string> cropEndErrors && cropEndErrors.Count > 0)
                    {
                        string firstError = cropEndErrors.First();
                        AddError(nameof(CropEndHours), firstError);
                        AddError(nameof(CropEndMinutes), firstError);
                        AddError(nameof(CropEndSeconds), firstError);
                    }
                }
            }
        }
        public override void Validate(string propertyName = null)
        {
            base.Validate(propertyName);

            string currentProperty = nameof(DownloadParams);

            if (string.IsNullOrWhiteSpace(propertyName) || propertyName == currentProperty)
            {
                DownloadParams?.Validate();

                if (_twitchService.IsFileNameUsed(_downloadParams.FullPath))
                {
                    DownloadParams.AddError(nameof(DownloadParams.Filename), "파일을 사용중입니다!");
                }

                if (DownloadParams.HasErrors)
                {
                    AddError(currentProperty, "잘못된 다운로드 매개 변수입니다!");

                    if (DownloadParams.GetErrors(nameof(DownloadParameters.CropStartTime)) is List <string> cropStartErrors && cropStartErrors.Count > 0)
                    {
                        string firstError = cropStartErrors.First();
                        AddError(nameof(CropStartHours), firstError);
                        AddError(nameof(CropStartMinutes), firstError);
                        AddError(nameof(CropStartSeconds), firstError);
                    }

                    if (DownloadParams.GetErrors(nameof(DownloadParameters.CropEndTime)) is List <string> cropEndErrors && cropEndErrors.Count > 0)
                    {
                        string firstError = cropEndErrors.First();
                        AddError(nameof(CropEndHours), firstError);
                        AddError(nameof(CropEndMinutes), firstError);
                        AddError(nameof(CropEndSeconds), firstError);
                    }
                }
            }
        }