1 //------------------------------------------------------------------------------
2 // <copyright file="ProfilePropertyNameValidator.cs" company="Microsoft">
3 //     Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //------------------------------------------------------------------------------
6 
7 namespace System.Web.Configuration
8 {
9     using System;
10     using System.Xml;
11     using System.Configuration;
12     using System.Collections.Specialized;
13     using System.Collections;
14     using System.IO;
15     using System.Text;
16     using System.Web.Util;
17 
18     internal sealed class ProfilePropertyNameValidator : ConfigurationValidatorBase
19     {
CanValidate(Type type)20         public override bool CanValidate(Type type) {
21             return (type == typeof(string));
22         }
Validate(object value)23         public override void Validate(object value) {
24             if (value == null) {
25                 throw new ArgumentNullException("value");
26             }
27 
28             string s = value as string;
29             if (s != null) {
30                 s = s.Trim();
31             }
32             if (string.IsNullOrEmpty(s)) {
33                 throw new ArgumentException(SR.GetString(SR.Profile_name_can_not_be_empty));
34             }
35 
36             if (s.Contains(".")) {
37                 throw new ArgumentException(SR.GetString(SR.Profile_name_can_not_contain_period));
38             }
39         }
40         internal static ProfilePropertyNameValidator SingletonInstance = new ProfilePropertyNameValidator();
41     }
42 }
43