protected override ValidationResult IsValid(object value, ValidationContext validationContext) { var errorMessage = $"Property '{validationContext.MemberName}' value is not valid full name."; if (string.IsNullOrEmpty(value?.ToString())) { return(_allowNullorEmptyStrings ? ValidationResult.Success : new ValidationResult(errorMessage)); } if (!(value is string)) { throw new InvalidOperationException($"'{nameof(IsValidPathAttribute)}' attribute can be used only on 'string' value type properties."); } try { if (!string.IsNullOrWhiteSpace(value.ToString())) { var dummy = new CasparFileInfo(value.ToString()); } } catch { return(new ValidationResult(errorMessage)); } return(ValidationResult.Success); }
public TemplateDataFromDataFile(CasparFileInfo fileInfo) { _fileInfo = fileInfo; }