using System; using System.Collections.Generic; using System.Configuration; using System.Globalization; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Controls; namespace XHandler.Class { public class MethodValidator : ValidationRule { public override ValidationResult Validate(object value, CultureInfo cultureInfo) { string text = value as string; if (string.IsNullOrEmpty(text.Trim())) return new ValidationResult(false, Properties.Resources.strCannotEmpty); string shortDir = ConfigurationManager.AppSettings["MethodFileBasePath"].ToString(); string fullName = shortDir + "\\" + text + ".mod"; if (!Directory.Exists(shortDir)) { Directory.CreateDirectory(shortDir); } if (File.Exists(fullName)) { return new ValidationResult(false, Properties.Resources.strMethodExist); } return new ValidationResult(true, null); } } }