コード例 #1
0
        public bool ValidateName(List <string> errors)
        {
            errors.Clear();

            if (string.IsNullOrEmpty(ServiceName))
            {
                errors.Add("Name cannot be empty.");
                return(false);
            }

            if (!ServiceName.EndsWith("Service"))
            {
                errors.Add("Name must end with 'Service' suffix.");
            }

            if (!CSharpCodeProvider.CreateProvider("C#").IsValidIdentifier(ServiceName))
            {
                errors.Add("Name must not contain illegal characters.");
            }

            return(errors.Count == 0);
        }