static ConfigurationProperty useHostingIdentityProp;
static ConfigurationPropertyCollection properties;
+ static ConfigurationElementProperty elementProperty;
+
static SessionStateSection ()
{
allowCustomSqlDatabaseProp = new ConfigurationProperty ("allowCustomSqlDatabase", typeof (bool), false);
- cookielessProp = new ConfigurationProperty ("cookieless", typeof (HttpCookieMode));
+ cookielessProp = new ConfigurationProperty ("cookieless", typeof (string), null);
cookieNameProp = new ConfigurationProperty ("cookieName", typeof (string), "ASP.NET_SessionId");
customProviderProp = new ConfigurationProperty ("customProvider", typeof (string), "");
- modeProp = new ConfigurationProperty ("mode", typeof (SessionStateMode), SessionStateMode.InProc);
+ modeProp = new ConfigurationProperty ("mode", typeof (SessionStateMode), SessionStateMode.InProc,
+ new GenericEnumConverter (typeof (SessionStateMode)), null,
+ ConfigurationPropertyOptions.None);
partitionResolverTypeProp = new ConfigurationProperty ("partitionResolverType", typeof (string), "");
- providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection));
+ providersProp = new ConfigurationProperty ("providers", typeof (ProviderSettingsCollection), null,
+ null, null, ConfigurationPropertyOptions.None);
regenerateExpiredSessionIdProp = new ConfigurationProperty ("regenerateExpiredSessionId", typeof (bool), true);
sessionIDManagerTypeProp = new ConfigurationProperty ("sessionIDManagerType", typeof (string), "");
- sqlCommandTimeoutProp = new ConfigurationProperty ("sqlCommandTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (30));
+ sqlCommandTimeoutProp = new ConfigurationProperty ("sqlCommandTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (30),
+ PropertyHelper.TimeSpanSecondsOrInfiniteConverter, null,
+ ConfigurationPropertyOptions.None);
sqlConnectionStringProp = new ConfigurationProperty ("sqlConnectionString", typeof (string), "data source=localhost;Integrated Security=SSPI");
stateConnectionStringProp = new ConfigurationProperty ("stateConnectionString", typeof (string), "tcpip=loopback:42424");
- stateNetworkTimeoutProp = new ConfigurationProperty ("stateNetworkTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (10));
- timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.FromMinutes (20));
+ stateNetworkTimeoutProp = new ConfigurationProperty ("stateNetworkTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (10),
+ PropertyHelper.TimeSpanSecondsOrInfiniteConverter,
+ PropertyHelper.PositiveTimeSpanValidator,
+ ConfigurationPropertyOptions.None);
+ timeoutProp = new ConfigurationProperty ("timeout", typeof (TimeSpan), TimeSpan.FromMinutes (20),
+ PropertyHelper.TimeSpanMinutesOrInfiniteConverter,
+ new TimeSpanValidator (new TimeSpan (0,1,0), TimeSpan.MaxValue),
+ ConfigurationPropertyOptions.None);
useHostingIdentityProp = new ConfigurationProperty ("useHostingIdentity", typeof (bool), true);
properties = new ConfigurationPropertyCollection ();
properties.Add (stateNetworkTimeoutProp);
properties.Add (timeoutProp);
properties.Add (useHostingIdentityProp);
+
+ elementProperty = new ConfigurationElementProperty (new CallbackValidator (typeof (SessionStateSection), ValidateElement));
}
[MonoTODO]
[ConfigurationProperty ("cookieless")]
public HttpCookieMode Cookieless {
- get { return (HttpCookieMode) base [cookielessProp];}
- set { base[cookielessProp] = value; }
+ get { return ParseCookieMode ((string) base [cookielessProp]); }
+ set { base[cookielessProp] = value.ToString(); }
}
[ConfigurationProperty ("cookieName", DefaultValue = "ASP.NET_SessionId")]
[TypeConverter (typeof (TimeSpanSecondsOrInfiniteConverter))]
[ConfigurationProperty ("stateNetworkTimeout", DefaultValue = "00:00:10")]
+ // LAMESPEC: MS lists no validator here but provides one in Properties.
public TimeSpan StateNetworkTimeout {
get { return (TimeSpan) base [stateNetworkTimeoutProp];}
set { base[stateNetworkTimeoutProp] = value; }
set { base[useHostingIdentityProp] = value; }
}
-#if notyet
[MonoTODO]
- public ConfigurationElementProperty ElementProperty {
- get { throw new NotImplementedException (); }
+ static void ValidateElement (object o)
+ {
+ /* XXX do some sort of element validation here? */
+ }
+
+ protected override ConfigurationElementProperty ElementProperty {
+ get { return elementProperty; }
}
-#endif
protected override ConfigurationPropertyCollection Properties {
get { return properties; }
}
+
+ HttpCookieMode ParseCookieMode (string s)
+ {
+ if (s == "true") return HttpCookieMode.UseUri;
+ else if (s == "false") return HttpCookieMode.UseCookies;
+ else {
+ try {
+ return (HttpCookieMode)Enum.Parse (typeof(HttpCookieMode), s);
+ }
+ catch {
+ return HttpCookieMode.UseCookies;
+ }
+ }
+ }
+
+#region CompatabilityCode
+ internal bool CookieLess {
+ get { return Cookieless != HttpCookieMode.UseCookies; }
+ set { Cookieless = value ? HttpCookieMode.UseUri : HttpCookieMode.UseCookies; }
+ }
+#endregion
+
}
}