File: ProfileSection.cs

package info (click to toggle)
mono 6.8.0.105%2Bdfsg-3.3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,284,512 kB
  • sloc: cs: 11,172,132; xml: 2,850,069; ansic: 671,653; cpp: 122,091; perl: 59,366; javascript: 30,841; asm: 22,168; makefile: 20,093; sh: 15,020; python: 4,827; pascal: 925; sql: 859; sed: 16; php: 1
file content (240 lines) | stat: -rw-r--r-- 10,804 bytes parent folder | download | duplicates (7)
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
//------------------------------------------------------------------------------
// <copyright file="ProfileSection.cs" company="Microsoft">
//     Copyright (c) Microsoft Corporation.  All rights reserved.
// </copyright>
//------------------------------------------------------------------------------

namespace System.Web.Configuration {
    using System;
    using System.Xml;
    using System.Configuration;
    using System.Collections.Specialized;
    using System.Collections;
    using System.IO;
    using System.Text;
    using System.Web.Util;
    using System.Security.Permissions;

    /*          <!--
            Configuration for profile:
                enabled="[true|false]"   Feature is enabled?
                defaultProvider="string" Name of provider to use by default

                <providers>              Providers (class must inherit from ProfileProvider)

                    <add                 Add a provider
                        name="string"    Name to identify this provider instance by
                        type="string"   Class that implements ProfileProvider
                        provider-specific-configuration />

                    <remove              Remove a provider
                        name="string" /> Name of provider to remove
                    <clear/>             Remove all providers


                <properties>                Optional element. List of properties in the Profile system
                    <property            Properties in the profile
                            name="string"                 Name of the property
                            type="string"                 Optional. Type of the property. Default: string.
                            readOnly="[true|false]"       Optional. Is Value read-only. Default: false.
                            defaultValue="string"         Optional. Default Value. Default: Empty string.
                            allowAnonymous="[true|false]" Optional. Allow storing values for anonymous users. Default: false.
                            provider="string              Optional. Name of provider. Default: Default provider.
                            serializeAs=["String|Xml|Binary|ProviderSpecific"] Optional. How to serialize the type. Default: ProviderSpecific.
                        />


                    <group              Optional element. Group of properties: Note: groups can not nested
                        name="string"   Name of the group

                        <property       Property in the group
                            name="string"                 Name of the property
                            type="type-name"              Optional. Type of the property. Default: "string".
                            readOnly="[true|false]"       Optional. Is Value read-only. Default: false.
                            defaultValue="string"         Optional. Default Value. Default: Empty string.
                            allowAnonymous="[true|false]" Optional. Allow storing values for anonymous users. Default: false.
                            provider="string              Optional. Name of provider. Default: Default provider.
                            serializeAs=["String|Xml|Binary|ProviderSpecific"] Optional. How to serialize the type. Default: ProviderSpecific.
                        />
                    </group>
                </properties>

             Configuration for SqlProfileProvider:
                   connectionStringName="string"  Name corresponding to the entry in <connectionStrings> section where the connection string for the provider is specified
                   description="string"           Description of what the provider does
                   commandTimeout="int"           Command timeout value for SQL command

        -->


        <profile enabled="true" defaultProvider="AspNetSqlProfileProvider" inherits="System.Web.Profile.ProfileBase, System.Web, Version=%ASSEMBLY_VERSION%, Culture=neutral, PublicKeyToken=%MICROSOFT_PUBLICKEY%" >
           <providers>
              <add  name="AspNetSqlProfileProvider"
                    type="System.Web.Profile.SqlProfileProvider, System.Web, Version=%ASSEMBLY_VERSION%, Culture=neutral, PublicKeyToken=%MICROSOFT_PUBLICKEY%"
                    connectionStringName="LocalSqlServer"
                    applicationName="/"
                    description="Stores and retrieves profile data from the local Microsoft SQL Server database" />
           </providers>

           <properties>
                <!-- Add profile properties here. Example:
                       <property name="FriendlyName" type="string" />
                       <property name="Height"       type="int"    />
                       <property name="Weight"       type="int"    />
                -->
           </properties>
        </profile>
*/
    public sealed class ProfileSection : ConfigurationSection {
        private static ConfigurationPropertyCollection _properties;
        private static readonly ConfigurationProperty _propEnabled =
            new ConfigurationProperty("enabled",
                                        typeof(bool),
                                        true,
                                        ConfigurationPropertyOptions.None);
        private static readonly ConfigurationProperty _propDefaultProvider =
            new ConfigurationProperty("defaultProvider",
                                        typeof(string),
                                        "AspNetSqlProfileProvider",
                                        null,
                                        StdValidatorsAndConverters.NonEmptyStringValidator,
                                        ConfigurationPropertyOptions.None);
        private static readonly ConfigurationProperty _propProviders =
            new ConfigurationProperty("providers",
                                        typeof(ProviderSettingsCollection),
                                        null,
                                        ConfigurationPropertyOptions.None);
        private static readonly ConfigurationProperty _propProfile =
            new ConfigurationProperty("properties",
                                        typeof(RootProfilePropertySettingsCollection),
                                        null,
                                        ConfigurationPropertyOptions.IsDefaultCollection);
        private static readonly ConfigurationProperty _propInherits =
            new ConfigurationProperty("inherits",
                                        typeof(string),
                                        String.Empty,
                                        ConfigurationPropertyOptions.None);
        private static readonly ConfigurationProperty _propAutomaticSaveEnabled =
            new ConfigurationProperty("automaticSaveEnabled",
                                        typeof(bool),
                                        true,
                                        ConfigurationPropertyOptions.None);

        static ProfileSection() {
            // Property initialization
            _properties = new ConfigurationPropertyCollection();
            _properties.Add(_propEnabled);
            _properties.Add(_propDefaultProvider);
            _properties.Add(_propProviders);
            _properties.Add(_propProfile);
            _properties.Add(_propInherits);
            _properties.Add(_propAutomaticSaveEnabled);
        }

        private long _recompilationHash;

        private bool _recompilationHashCached;

        internal long RecompilationHash {
            get {
                if (!_recompilationHashCached) {
                    _recompilationHash = CalculateHash();
                    _recompilationHashCached = true;
                }

                return _recompilationHash;
            }
        }

        private long CalculateHash() {
            HashCodeCombiner hashCombiner = new HashCodeCombiner();

            CalculateProfilePropertySettingsHash(PropertySettings, hashCombiner);

            if (PropertySettings != null) {
                foreach (ProfileGroupSettings pgs in PropertySettings.GroupSettings) {
                    hashCombiner.AddObject(pgs.Name);
                    CalculateProfilePropertySettingsHash(pgs.PropertySettings, hashCombiner);
                }
            }

            return hashCombiner.CombinedHash;
        }

        private void CalculateProfilePropertySettingsHash(
            ProfilePropertySettingsCollection settings,
            HashCodeCombiner hashCombiner) {
            foreach (ProfilePropertySettings pps in settings) {
                hashCombiner.AddObject(pps.Name);
                hashCombiner.AddObject(pps.Type);
            }
        }

        public ProfileSection() {
        }

        protected override ConfigurationPropertyCollection Properties {
            get {
                return _properties;
            }
        }

        [ConfigurationProperty("automaticSaveEnabled", DefaultValue = true)]
        public bool AutomaticSaveEnabled {
            get {
                return (bool)base[_propAutomaticSaveEnabled];
            }
            set {
                base[_propAutomaticSaveEnabled] = value;
            }
        }

        [ConfigurationProperty("enabled", DefaultValue = true)]
        public bool Enabled {
            get {
                return (bool)base[_propEnabled];
            }
            set {
                base[_propEnabled] = value;
            }
        }

        [ConfigurationProperty("defaultProvider", DefaultValue = "AspNetSqlProfileProvider")]
        [StringValidator(MinLength = 1)]
        public string DefaultProvider {
            get {
                return (string)base[_propDefaultProvider];
            }
            set {
                base[_propDefaultProvider] = value;
            }
        }

        [ConfigurationProperty("inherits", DefaultValue = "")]
        public string Inherits {
            get {
                return (string)base[_propInherits];
            }
            set {
                base[_propInherits] = value;
            }
        }

                [ConfigurationProperty("providers")]
                public ProviderSettingsCollection Providers                 {
                    get                     {
                        return (ProviderSettingsCollection)base[_propProviders];
                    }
                }

        // not exposed to the API
        [ConfigurationProperty("properties")]
        public RootProfilePropertySettingsCollection PropertySettings {
            get {
                return (RootProfilePropertySettingsCollection)base[_propProfile];
            }
        }
    }
}