Author: atsushi
Date: 2007-06-21 09:13:51 -0400 (Thu, 21 Jun 2007)
New Revision: 80469
Modified:
trunk/mcs/class/System/System.Configuration/ChangeLog
trunk/mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs
trunk/mcs/class/System/System.Configuration/LocalFileSettingsProvider.cs
trunk/mcs/class/System/System.Configuration/SettingValueElement.cs
Log:
2007-06-21 Atsushi Enomoto <[EMAIL PROTECTED]>
* SettingValueElement.cs : implement Reset().
* CustomizableFileSettingsProvider.cs : fixed company name getter
and product name getter.
LoadPropertyValue() should expect null ValueXml.
* LocalFileSettingsProvider.cs : time to switch. With a bit of
directory name difference, it should work.
Modified: trunk/mcs/class/System/System.Configuration/ChangeLog
===================================================================
--- trunk/mcs/class/System/System.Configuration/ChangeLog 2007-06-21
13:11:58 UTC (rev 80468)
+++ trunk/mcs/class/System/System.Configuration/ChangeLog 2007-06-21
13:13:51 UTC (rev 80469)
@@ -1,3 +1,12 @@
+2007-06-21 Atsushi Enomoto <[EMAIL PROTECTED]>
+
+ * SettingValueElement.cs : implement Reset().
+ * CustomizableFileSettingsProvider.cs : fixed company name getter
+ and product name getter.
+ LoadPropertyValue() should expect null ValueXml.
+ * LocalFileSettingsProvider.cs : time to switch. With a bit of
+ directory name difference, it should work.
+
2007-06-13 Atsushi Enomoto <[EMAIL PROTECTED]>
* CustomizableLocalFileSettingsProvider.cs :
Modified:
trunk/mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs
===================================================================
---
trunk/mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs
2007-06-21 13:11:58 UTC (rev 80468)
+++
trunk/mcs/class/System/System.Configuration/CustomizableFileSettingsProvider.cs
2007-06-21 13:13:51 UTC (rev 80469)
@@ -37,6 +37,8 @@
using System.Configuration;
using System.IO;
using System.Reflection;
+using System.Security.Cryptography;
+using System.Text;
using System.Xml;
using NameValueCollection =
PrebuiltSystem.System.Collections.Specialized.NameValueCollection;
@@ -220,21 +222,26 @@
set { isCompany = value; }
}
+ // AssemblyCompanyAttribute->Namespace->"Program"
private static string GetCompanyName ()
{
Assembly assembly = Assembly.GetEntryAssembly ();
if (assembly == null)
assembly = Assembly.GetCallingAssembly ();
- if (assembly == null)
- return string.Empty;
-
+
AssemblyCompanyAttribute [] attrs =
(AssemblyCompanyAttribute []) assembly.GetCustomAttributes (typeof
(AssemblyCompanyAttribute), true);
-
+
if ((attrs != null) && attrs.Length > 0) {
return attrs [0].Company;
}
- return assembly.GetName ().Name;
+ MethodInfo entryPoint = assembly.EntryPoint;
+ Type entryType = entryPoint != null ?
entryPoint.DeclaringType : null;
+ if (entryType != null && entryType.Namespace.Length >
0) {
+ int end = entryType.Namespace.IndexOf ('.');
+ return end < 0 ? entryType.Namespace :
entryType.Namespace.Substring (0, end);
+ }
+ return "Program";
}
private static string GetProductName ()
@@ -242,16 +249,26 @@
Assembly assembly = Assembly.GetEntryAssembly ();
if (assembly == null)
assembly = Assembly.GetCallingAssembly ();
- if (assembly == null)
- return string.Empty;
-
+
+#if true
+
+ byte [] pkt = assembly.GetName ().GetPublicKeyToken ();
+ byte [] hash = SHA1.Create ().ComputeHash (pkt != null
? pkt : Encoding.UTF8.GetBytes (assembly.EscapedCodeBase));
+ return String.Format ("{0}_{1}_{2}",
+ AppDomain.CurrentDomain.FriendlyName,
+ pkt != null ? "StrongName" : "Url",
+ // FIXME: it seems that something else is used
+ // here, to convert hash bytes to string.
+ Convert.ToBase64String (hash));
+
+#else // AssemblyProductAttribute-based code
AssemblyProductAttribute [] attrs =
(AssemblyProductAttribute[]) assembly.GetCustomAttributes (typeof
(AssemblyProductAttribute), true);
-
+
if ((attrs != null) && attrs.Length > 0) {
return attrs [0].Product;
}
-
return assembly.GetName ().Name;
+#endif
}
private static string GetProductVersion ()
@@ -619,9 +636,10 @@
private void LoadPropertyValue (SettingsPropertyCollection
collection, SettingElement element, bool allowOverwrite)
{
- SettingsPropertyValue value = new SettingsPropertyValue
(collection [element.Name]);
+ SettingsProperty prop = collection [element.Name];
+ SettingsPropertyValue value = new SettingsPropertyValue
(prop);
value.IsDirty = false;
- value.SerializedValue =
element.Value.ValueXml.InnerText;
+ value.SerializedValue = element.Value.ValueXml != null
? element.Value.ValueXml.InnerText : prop.DefaultValue;
try
{
if (allowOverwrite)
Modified:
trunk/mcs/class/System/System.Configuration/LocalFileSettingsProvider.cs
===================================================================
--- trunk/mcs/class/System/System.Configuration/LocalFileSettingsProvider.cs
2007-06-21 13:11:58 UTC (rev 80468)
+++ trunk/mcs/class/System/System.Configuration/LocalFileSettingsProvider.cs
2007-06-21 13:13:51 UTC (rev 80469)
@@ -59,12 +59,7 @@
public override SettingsPropertyValueCollection
GetPropertyValues (SettingsContext context,
SettingsPropertyCollection properties)
{
- SettingsPropertyValueCollection pv = new
SettingsPropertyValueCollection ();
- foreach (SettingsProperty prop in properties)
- pv.Add (new SettingsPropertyValue (prop));
- return pv;
- // FIXME: enable this when the compiler issue is solved.
- //return impl.GetPropertyValues (context, properties);
+ return impl.GetPropertyValues (context, properties);
}
#if CONFIGURATION_DEP
@@ -76,8 +71,6 @@
if (values != null)
impl.ApplicationName = values
["applicationName"];
- // FIXME: this must be enabled
- //impl.Initialize (name, values);
base.Initialize (name, values);
}
#endif
Modified: trunk/mcs/class/System/System.Configuration/SettingValueElement.cs
===================================================================
--- trunk/mcs/class/System/System.Configuration/SettingValueElement.cs
2007-06-21 13:11:58 UTC (rev 80468)
+++ trunk/mcs/class/System/System.Configuration/SettingValueElement.cs
2007-06-21 13:13:51 UTC (rev 80469)
@@ -90,7 +90,7 @@
protected override void Reset (ConfigurationElement
parentElement)
{
- throw new NotImplementedException ();
+ node = null;
}
protected override void ResetModified ()
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches