Ver código fonte

2009-10-22 Marek Habersack <[email protected]>

	* ProfileBase.cs: put named entries into SettingProperty's
	Attributes collection based on custom attributes decorating the
	associated profile property.

	* CustomProviderDataAttribute.cs: implemented IsDefaultAttribute

svn path=/trunk/mcs/; revision=144675
Marek Habersack 16 anos atrás
pai
commit
df8e32998a

+ 8 - 0
mcs/class/System.Web/System.Web.Profile/ChangeLog

@@ -1,3 +1,11 @@
+2009-10-22  Marek Habersack  <[email protected]>
+
+	* ProfileBase.cs: put named entries into SettingProperty's
+	Attributes collection based on custom attributes decorating the
+	associated profile property.
+
+	* CustomProviderDataAttribute.cs: implemented IsDefaultAttribute
+
 2009-09-08  Marek Habersack  <[email protected]>
 
 	* ProfileParser.cs: GetProfileGroupType creates type name with

+ 2 - 3
mcs/class/System.Web/System.Web.Profile/CustomProviderDataAttribute.cs

@@ -4,7 +4,7 @@
 // Authors:
 //	Chris Toshok ([email protected])
 //
-// (C) 2005 Novell, Inc (http://www.novell.com)
+// (C) 2005-2009 Novell, Inc (http://www.novell.com)
 //
 // Permission is hereby granted, free of charge, to any person obtaining
 // a copy of this software and associated documentation files (the
@@ -39,10 +39,9 @@ namespace System.Web.Profile
 			this.customProviderData = customProviderData;
 		}
 
-		[MonoTODO ("Not implemented")]
 		public override bool IsDefaultAttribute ()
 		{
-			throw new NotImplementedException ();
+			return String.IsNullOrEmpty (CustomProviderData);
 		}
 
 		public string CustomProviderData {

+ 12 - 14
mcs/class/System.Web/System.Web.Profile/ProfileBase.cs

@@ -244,7 +244,7 @@ namespace System.Web.Profile
 		{
 			SettingsProperty sp = new SettingsProperty (property.Name);
 
-			Attribute [] attributes = (Attribute [])property.GetCustomAttributes (typeof (SettingsSerializeAsAttribute), false);
+			Attribute [] attributes = (Attribute [])property.GetCustomAttributes (false);
 			SettingsAttributeDictionary attDict = new SettingsAttributeDictionary();
 			sp.SerializeAs = SettingsSerializeAs.ProviderSpecific;
 			sp.PropertyType = property.PropertyType;
@@ -253,24 +253,22 @@ namespace System.Web.Profile
 			sp.ThrowOnErrorSerializing = true;
 
 			for (int i = 0; i < attributes.Length; i++) {
-				if (attributes [i] is DefaultSettingValueAttribute)
+				if (attributes [i] is DefaultSettingValueAttribute) {
 					sp.DefaultValue = ((DefaultSettingValueAttribute) attributes [i]).Value;
-
-				else if (attributes [i] is SettingsProviderAttribute) {
+				} else if (attributes [i] is SettingsProviderAttribute) {
 					Type providerType = HttpApplication.LoadType (((SettingsProviderAttribute) attributes [i]).ProviderTypeName);
 					sp.Provider = (SettingsProvider) Activator.CreateInstance (providerType);
 					sp.Provider.Initialize (null, null);
-				}
-
-				else if (attributes [i] is SettingsSerializeAsAttribute)
+				} else if (attributes [i] is SettingsSerializeAsAttribute) {
 					sp.SerializeAs = ((SettingsSerializeAsAttribute) attributes [i]).SerializeAs;
-
-				else if (
-					attributes [i] is SettingsAllowAnonymousAttribute ||
-					attributes [i] is ApplicationScopedSettingAttribute ||
-					attributes [i] is UserScopedSettingAttribute ||
-					attributes [i] is SettingsDescriptionAttribute  ||
-					attributes [i] is SettingAttribute)
+				} else if (attributes [i] is SettingsAllowAnonymousAttribute) {
+					sp.Attributes ["AllowAnonymous"] = ((SettingsAllowAnonymousAttribute) attributes [i]).Allow;
+				} else if (attributes [i] is CustomProviderDataAttribute) {
+					sp.Attributes ["CustomProviderData"] = ((CustomProviderDataAttribute) attributes [i]).CustomProviderData;
+				} else if (attributes [i] is ApplicationScopedSettingAttribute ||
+					   attributes [i] is UserScopedSettingAttribute ||
+					   attributes [i] is SettingsDescriptionAttribute  ||
+					   attributes [i] is SettingAttribute)
 					attDict.Add (attributes [i].GetType (), attributes [i]);
 			}