Explorar o código

2005-03-29 Peter Bartok <[email protected]>
* Application.cs:
- Properly implemented CompanyName property
- Fixed LocalUserAppDataPath and UserAppDataPath, now properly
returns a path that includes CompanyName, ProductName and
Version (fixes bug #70330)

2005-03-29 Stefan Buehler <[email protected]>


svn path=/trunk/mcs/; revision=42360

Peter Dennis Bartok %!s(int64=21) %!d(string=hai) anos
pai
achega
bbd8fc4b3d

+ 7 - 15
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Application.cs

@@ -146,21 +146,13 @@ namespace System.Windows.Forms {
 
 		public static string CompanyName {
 			get {
-				StackTrace	st;
-
-				if (Environment.OSVersion.Platform != (PlatformID)128) {
-					RegistryKey	key;
-					String		ret;
-
-					key=Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion", false);
-					ret=(String)key.GetValue("RegisteredOrganization");
-
-					return ret;
-					
+				AssemblyCompanyAttribute[] attrs = (AssemblyCompanyAttribute[]) Assembly.GetEntryAssembly().GetCustomAttributes(typeof(AssemblyCompanyAttribute), true);
+				
+				if ((attrs != null) && attrs.Length>0) {
+					return attrs[0].Company;
 				}
 
-				st=new StackTrace();
-				return st.GetFrame(st.FrameCount-1).GetMethod().DeclaringType.Namespace;
+				return Assembly.GetEntryAssembly().GetName().Name;
 			}
 		}
 
@@ -193,7 +185,7 @@ namespace System.Windows.Forms {
 
 		public static string LocalUserAppDataPath {
 			get {
-				return Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
+				return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), CompanyName), ProductName), ProductVersion);
 			}
 		}
 
@@ -246,7 +238,7 @@ namespace System.Windows.Forms {
 
 		public static string UserAppDataPath {
 			get {
-				return Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
+				return Path.Combine(Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), CompanyName), ProductName), ProductVersion);
 			}
 		}
 

+ 9 - 1
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog

@@ -1,4 +1,12 @@
-2005-03-18  Stefan Buehler  <[email protected]>
+2005-03-29  Peter Bartok  <[email protected]>
+
+	* Application.cs:
+	  - Properly implemented CompanyName property
+	  - Fixed LocalUserAppDataPath and UserAppDataPath, now properly 
+	    returns a path that includes CompanyName, ProductName and 
+	    Version (fixes bug #70330)
+
+2005-03-29  Stefan Buehler  <[email protected]>
 
 	* TabPage.cs: Don't use Owner.DisplayRectangle unless owner is valid, 
 	  fixes bug #72588.