List:Commits« Previous MessageNext Message »
From:Reggie Burnett Date:February 3 2011 5:34pm
Subject:bzr commit into wex-installer-1.0 branch (reggie.burnett:294)
View as plain text  
#At file:///C:/Users/Reggie/work/wex/installer-updated/ based on revid:reggie.burnett@stripped

  294 Reggie Burnett	2011-02-03
      changed config controller base from being an interface to being an abstract base class and added Owner property

    modified:
      WexInstaller/Controls/InstallWizardControl.cs
      WexInstaller/Core/Product.cs
      WexInstaller/Panels/ProductConfigurationController.cs
=== modified file 'WexInstaller/Controls/InstallWizardControl.cs'
=== modified file 'WexInstaller/Controls/InstallWizardControl.cs'
--- a/WexInstaller/Controls/InstallWizardControl.cs	2011-02-02 16:43:49 +0000
+++ b/WexInstaller/Controls/InstallWizardControl.cs	2011-02-03 17:34:36 +0000
@@ -75,7 +75,7 @@
             InstallerPanel.StatusChanged -= statusChanged;
             wizardPages.TabPages.Remove(finalPage);
 
-            IProductConfigurationController c = p.Controller;
+            ProductConfigurationController c = p.Controller;
             foreach (UserControl page in c.Pages)
             {
                 TabPage tab = new TabPage("Config");

=== modified file 'WexInstaller/Core/Product.cs'
--- a/WexInstaller/Core/Product.cs	2011-02-02 16:31:30 +0000
+++ b/WexInstaller/Core/Product.cs	2011-02-03 17:34:36 +0000
@@ -21,7 +21,7 @@
 
     public class Product : ProductElement
     {
-        private IProductConfigurationController controller;
+        private ProductConfigurationController controller;
         private StringBuilder InstallActionLog;
         private WebClient wc;
         private BackgroundWorker bgw;
@@ -34,7 +34,7 @@
             get { return String.Format("{0} {1}", Title, GetPackage().ThisVersion); }
         }
 
-        public IProductConfigurationController Controller
+        public ProductConfigurationController Controller
         {
             get
             {
@@ -799,17 +799,18 @@
 
             int version = 0;
             Assembly a = Assembly.GetExecutingAssembly();
-            GetControllerFromAssembly(a, ref version);          
+            GetControllerFromAssembly(a, ref version);
+            controller.Owner = this;
         }
 
         private void GetControllerFromAssembly(Assembly assembly, ref int version)
         {
-            Type interfaceType = typeof(IProductConfigurationController);
+            Type interfaceType = typeof(ProductConfigurationController);
             Type[] types = assembly.GetTypes();
 
             foreach (Type t in types)
             {
-                if (!t.IsInterface && interfaceType.IsAssignableFrom(t))
+                if (!t.IsAbstract && interfaceType.IsAssignableFrom(t))
                 {
                     object[] attr = t.GetCustomAttributes(typeof(ProductConfigurationAttribute), false);
                     if (attr == null || attr.Length != 1) continue;
@@ -818,7 +819,7 @@
 
                     if (a.Version > version)
                     {
-                        controller = (IProductConfigurationController)assembly.CreateInstance(t.FullName);
+                        controller = (ProductConfigurationController)assembly.CreateInstance(t.FullName);
                         version = a.Version;
                     }
                 }

=== modified file 'WexInstaller/Panels/ProductConfigurationController.cs'
--- a/WexInstaller/Panels/ProductConfigurationController.cs	2011-01-31 16:46:34 +0000
+++ b/WexInstaller/Panels/ProductConfigurationController.cs	2011-02-03 17:34:36 +0000
@@ -13,13 +13,22 @@
 
 namespace WexInstaller.Panels
 {
-    public interface IProductConfigurationController
+    public abstract class ProductConfigurationController
     {
-        int NumPages { get; }
-        UserControl[] Pages { get; }
-        ConfigState CurrentState { get; set; }
-        void Configure();
-        void Initalize();
+        public abstract int NumPages { get; }
+
+        public abstract UserControl[] Pages { get; }
+
+        public ConfigState CurrentState { get; protected set; }
+        public Product Owner { get; set; }
+
+        public virtual void Configure()
+        {
+        }
+
+        public virtual void Initalize()
+        {
+        }
     }
 
     public class ProductConfigurationAttribute : Attribute
@@ -68,7 +77,7 @@
     public delegate void ConfigurationEventHandler(object sender, ConfigurationEventArgs ce);
 
     [ProductConfiguration("mysql-server", 1)]
-    public class ServerConfigurationController : IProductConfigurationController
+    public class ServerConfigurationController : ProductConfigurationController
     {
         private BackgroundWorker bgw;
         private UserControl[] pages;
@@ -86,7 +95,6 @@
         public string RootPassword { get; set; }
         public string ExistingRootPassword { get; set; }
         public string ExistingConfigFile { get; set; }
-        public ConfigState CurrentState { get; set; }
 
         public ServerConfigurationController()
         {
@@ -95,12 +103,7 @@
             Initalize();
         }
 
-        public int NumPages
-        {
-            get { return (Reconfigure) ? 1 : 3; }
-        }
-
-        public UserControl[] Pages
+        public override UserControl[] Pages
         {
             get
             {
@@ -109,7 +112,12 @@
             }
         }
 
-        public void Configure()
+        public override int NumPages
+        {
+            get { return (Reconfigure) ? 1 : 3; }
+        }
+
+        public override void Configure()
         {
             CurrentState = ConfigState.ConfigurationInProgress;
             Debug.Assert(bgw == null);
@@ -264,7 +272,7 @@
         }
 
 
-        public void Initalize()
+        public override void Initalize()
         {
             Logger.LogInformation("Product configuration controller initialization started.");
 
@@ -276,18 +284,16 @@
             string foundDataDir = String.Empty;
             string version = String.Empty;
 
-            Product serverProduct = FindServerProduct();
-
-            if (serverProduct != null)
+            if (Owner != null)
             {
-                if (serverProduct.Installed)
+                if (Owner.Installed)
                 {
-                    Logger.LogInformation(String.Format("Product configuration controller found {0} installed.", serverProduct.Name));
+                    Logger.LogInformation(String.Format("Product configuration controller found {0} installed.", Owner.Name));
 
-                    baseDirectory = serverProduct.GetInstalledProductRegistryKey("Location");
-                    dataDirectory = serverProduct.GetInstalledProductRegistryKey("DataLocation");
-                    foundDataDir = serverProduct.GetInstalledProductRegistryKey("FoundExistingDataDir");
-                    version = serverProduct.GetInstalledProductRegistryKey("Version");
+                    baseDirectory = Owner.GetInstalledProductRegistryKey("Location");
+                    dataDirectory = Owner.GetInstalledProductRegistryKey("DataLocation");
+                    foundDataDir = Owner.GetInstalledProductRegistryKey("FoundExistingDataDir");
+                    version = Owner.GetInstalledProductRegistryKey("Version");
 
                     if (!String.IsNullOrEmpty(baseDirectory))
                     {
@@ -302,7 +308,7 @@
                     }
                 }
 
-                Reconfigure = (serverProduct.IsUpgrade && serverProduct.Installed);
+                Reconfigure = (Owner.IsUpgrade && Owner.Installed);
                 if (Reconfigure)
                 {
                     Regex defaultsFilePattern = new Regex(@" --defaults-file=""(?<iniLocation>.+)?"" ");
@@ -479,22 +485,6 @@
 
             bgw.ReportProgress(percent, e);
         }
-
-        private Product FindServerProduct()
-        {
-            Product currentServer = null;
-
-            foreach (ProductCategory pc in ProductManager.ProductCategories)
-            {
-                if (pc.Type == ProductCategoryType.Server)
-                {
-                    currentServer = pc.Products[0];
-                }
-            }
-
-            return currentServer;
-        }
-
     }
 
     public enum ConfigState


Attachment: [text/bzr-bundle] bzr/reggie.burnett@oracle.com-20110203173436-vsrcg96prpnpojkh.bundle
Thread
bzr commit into wex-installer-1.0 branch (reggie.burnett:294) Reggie Burnett3 Feb