schangxiang@126.com
2025-11-04 ca398287db3f5ea01f03aac4a85edb13b28100a6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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);
        }
    }
}