Example #1
0
        /// <summary>
        /// Iterates through the given path and returns the existing valid parent folder
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public static String GetExistingAncestor(String path)
        {
            AppAssert.AssertNotNull(path, "path");

            // Check if the path exists
            if (Directory.Exists(path))
            {
                SetupLogger.LogInfo("InstallLocationPage.SetPathInBrowserDialog : The path {0} exists, returning", path);
                return(path);
            }

            String ancestor = null;
            int    index    = path.LastIndexOf(Path.DirectorySeparatorChar);

            while (index >= 0)
            {
                ancestor = path.Substring(0, index);
                SetupLogger.LogInfo("InstallLocationPage.SetPathInBrowserDialog : Check if the ancestor {0} exists", ancestor);
                if (Directory.Exists(ancestor))
                {
                    SetupLogger.LogInfo("InstallLocationPage.SetPathInBrowserDialog : The ancestor {0} exists, returning", ancestor);
                    return(ancestor + Path.DirectorySeparatorChar);
                }

                index = ancestor.LastIndexOf(Path.DirectorySeparatorChar);
            }
            return(null);
        }
Example #2
0
        protected void LoadEnumValuesForCurrentCulture()
        {
            CultureInfo currentCulture = Thread.CurrentThread.CurrentUICulture;
            Dictionary <EnumType, string> enumStringTable = new Dictionary <EnumType, string>();

            string[]   enumNames  = Enum.GetNames(typeof(EnumType));
            EnumType[] enumValues = (EnumType[])Enum.GetValues(typeof(EnumType));

            for (int i = 0; i < enumNames.Length; ++i)
            {
                //as long as the value has a name, we're okay.
                //(we can't tell the difference between two enums with the same value)
                if (!enumStringTable.ContainsKey(enumValues[i]))
                {
                    string key           = typeof(EnumType).Name + enumNames[i] + this.suffix;
                    string localizedName = this.localResourceManager.GetString(key);
                    AppAssert.AssertNotNull(localizedName,
                                            string.Format("Each enum in {0} must have a localizable string name. Resource {1} in {2} for value {3} undefined",
                                                          typeof(EnumType).FullName, key, this.localResourceManager.BaseName, enumNames[i]));

                    enumStringTable.Add(enumValues[i], localizedName);
                }
            }

            this.PopulateAdditionalCombinedValues(enumStringTable);

            lock (this.syncObject)
            {
                this.cultureToEnumTableLookup[currentCulture] = enumStringTable;
            }
        }
Example #3
0
 public CommandlineParameters()
 {
     // Sanity check
     for (CommandlineParameterId id = 0; id < CommandlineParameterId.Count; id++)
     {
         AppAssert.Assert(this.CommandlineParameterTable[(int)id].ParameterId == id, "CommandlineParameterTable is incorrectly initialized", String.Format("{0} != {1}", this.CommandlineParameterTable[(int)id].ParameterId, id));
     }
 }
Example #4
0
        public void SetInputValue(object inputValue)
        {
            AppAssert.AssertNotNull(inputValue, "inputValue");

            Validate(inputValue);
            this.inputValue = inputValue;
            this.valid      = true;
        }
Example #5
0
        public void LoadInputValue(String file)
        {
            AppAssert.AssertNotNull(file, "file");
            object inputValue = LoadInputValueFromFile(file);

            if (inputValue != null)
            {
                SetInputValue(inputValue);
            }
        }
Example #6
0
        /// <summary>
        /// Edits the value of a parameter
        /// </summary>
        /// <param name="parameter"></param>
        /// <param name="value"></param>
        virtual public void EditItem(String parameter, object value)
        {
            AppAssert.AssertNotNull(parameter, "parameter");
            AppAssert.Assert(this.parameterList.Contains(parameter), "Parameter List does not contain this parameter", parameter);
            AppAssert.AssertNotNull(value, "value");

            InputParameter inputParameter = PropertyBagDictionary.Instance.GetProperty <InputParameter>(parameter);

            inputParameter.SetInputValue(value);
        }
Example #7
0
        /// <summary>
        /// Adds quotes (") to a string at beginning and end if not already quoted
        /// </summary>
        /// <param name="stringToQuote"></param>
        /// <returns>Quoted string.</returns>
        public static string QuoteString(string stringToQuote)
        {
            AppAssert.Assert(null != stringToQuote, "Null string passed to stringToQuote");
            string doubleQuote = "\"";

            if (!(stringToQuote.StartsWith(doubleQuote) && stringToQuote.EndsWith(doubleQuote)))
            {
                return(String.Format("{0}{1}{0}", doubleQuote, stringToQuote));
            }
            else
            {
                return(stringToQuote);
            }
        }
Example #8
0
        /// <summary>
        /// Given a path, return the root of the path
        /// </summary>
        /// <param name="path"></param>
        /// <returns>"\" terminated root</returns>
        public static String GetPathRoot(String path)
        {
            AppAssert.AssertNotNull(path, "path");
            AppAssert.Assert(path.Length > 0, "Path is empty");
            AppAssert.Assert(path[0] != Path.DirectorySeparatorChar, "Path starts with \\");

            if (IsPathRooted(path))
            {
                return(path.Substring(0, 3));
            }
            else
            {
                throw new ArgumentException("path");
            }
        }
Example #9
0
        /// <summary>
        /// Given a path, return the root of the path
        /// </summary>
        /// <param name="path"></param>
        /// <returns>true, if path has a root, false if path does not have a root</returns>
        public static bool IsPathRooted(String path)
        {
            AppAssert.AssertNotNull(path, "path");
            AppAssert.Assert(path.Length > 0, "Path is empty");

            if (path.Length > 1 && path[1] == Path.VolumeSeparatorChar)
            {
                if (path.Length > 2 && path[2] == Path.DirectorySeparatorChar)
                {
                    return(true);
                }
            }

            return(false);
        }
Example #10
0
        /// <summary>
        /// Get the localized name for the given object type
        /// </summary>
        /// <param name="state">Enum value</param>
        /// <param name="requestCulture">CultureInfo for localization</param>
        /// <returns></returns>
        public string GetName(EnumType state, CultureInfo requestCulture)
        {
            Dictionary <EnumType, string> enumStringTable = null;

            if (!this.cultureToEnumTableLookup.ContainsKey(requestCulture))
            {
                this.LoadEnumValuesForCurrentCulture();
                AppAssert.Assert(this.cultureToEnumTableLookup.ContainsKey(requestCulture), "Could not find localized enum dictionary for the current culture after calling LoadEnumValuesForCurrentCulture");
            }

            enumStringTable = this.cultureToEnumTableLookup[requestCulture];

            AppAssert.Assert(enumStringTable.ContainsKey(state), "Request for an enum state was made without that state having been loaded.");
            return(enumStringTable[state]);
        }
Example #11
0
        /// <summary>
        /// Loads input values from a file
        /// </summary>
        /// <param name="file"></param>
        /// <param name="parameterList"></param>
        public void LoadFrom(String file, StringCollection parameterList)
        {
            AppAssert.AssertNotNull(file, "file");
            AppAssert.AssertNotNull(parameterList, "parameterList");

            this.LoadParameterList(parameterList);

            InputParameter inputParameter = null;

            foreach (String parameter in parameterList)
            {
                inputParameter = this.FindItem(parameter);
                inputParameter.LoadInputValue(file);
            }
        }
Example #12
0
        public void CheckForDirectoryAttributes(String path, bool forDB)
        {
            AppAssert.AssertNotNull(path, "path");
            try
            {
                FileAttributes attributes = File.GetAttributes(path);

                if ((int)attributes == -1)
                {
                    throw new Exception(String.Format("The attributes of directory {0} cannot be acquired", path));
                }

                if ((attributes & FileAttributes.Hidden) == FileAttributes.Hidden ||
                    (attributes & FileAttributes.ReadOnly) == FileAttributes.ReadOnly ||
                    (attributes & FileAttributes.System) == FileAttributes.System)
                {
                    ThrowInvalidLocationException(path);
                }

                if (forDB)
                {
                    if ((attributes & FileAttributes.Compressed) == FileAttributes.Compressed)
                    {
                        throw new Exception(
                                  String.Format("The selected location {0} is on a compressed volume", path));
                    }
                }
            }
            catch (DirectoryNotFoundException directoryNotFoundException)
            {
                // Do nothing
            }
            catch (FileNotFoundException fileNotFoundException)
            {
                // Do nothing
            }
            catch (UnauthorizedAccessException unauthorizedAccessException)
            {
                // Setup was denied access to the folder, ask user to choose other location.
                ThrowInvalidLocationException(path);
            }
            catch (IOException ioException)
            {
                // IO error while accessing the install location, ask user to choose other location.
                ThrowInvalidLocationException(path);
            }
        }
Example #13
0
        /// <summary>
        /// Loads input values from a file
        /// </summary>
        /// <param name="file"></param>
        /// <param name="parameterList"></param>
        public void LoadFrom(String file, StringCollection parameterList)
        {
            AppAssert.AssertNotNull(file, "file");
            AppAssert.AssertNotNull(parameterList, "parameterList");

            Tracer.Trace.TraceMessage(CallSite.New(), TraceFlag.DbgNormal, "Load inputs from file {0}", file);

            this.LoadParameterList(parameterList);

            InputParameter inputParameter = null;

            foreach (String parameter in parameterList)
            {
                inputParameter = this.FindItem(parameter);
                inputParameter.LoadInputValue(file);
            }
        }
Example #14
0
        /// <summary>
        /// Returns a parameter
        /// </summary>
        /// <param name="parameter"></param>
        /// <returns></returns>
        virtual public InputParameter FindItem(String parameter)
        {
            AppAssert.AssertNotNull(parameter, "parameter");

            return(PropertyBagDictionary.Instance.GetProperty <InputParameter>(parameter));
        }
Example #15
0
        /// <summary>
        /// Loads the paramneters into wizard inputs
        /// </summary>
        /// <param name="parameterList"></param>
        public void LoadParameterList(StringCollection parameterList)
        {
            this.parameterList = parameterList;

            InputParameter inputParameter = null;

            foreach (String parameter in parameterList)
            {
                switch (parameter)
                {
                case SetupInputTags.SetupUserAccountTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SetupUserAccount());
                    break;
                }

                case SetupInputTags.UserNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new UserName());
                    break;
                }

                case SetupInputTags.CompanyNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new CompanyName());
                    break;
                }

                case SetupInputTags.ProductKeyTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new ProductKey());
                    break;
                }

                case SetupInputTags.BinaryInstallLocationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new BinaryInstallLocation());
                    break;
                }

                case SetupInputTags.IntegratedInstallSourceTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new IntegratedInstallSource());
                    break;
                }

                case SetupInputTags.CreateNewSqlDatabaseTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new CreateNewSqlDatabase());
                    break;
                }

                case SetupInputTags.RetainSqlDatabaseTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new RetainSqlDatabase());
                    break;
                }

                case SetupInputTags.ForceHAVMMUninstallTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new ForceHAVMMUninstall());
                    break;
                }

                case SetupInputTags.SqlInstanceNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlInstanceName());
                    break;
                }

                case SetupInputTags.SqlDatabaseNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlDatabaseName());
                    break;
                }

                case SetupInputTags.RemoteDatabaseImpersonationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new RemoteDatabaseImpersonation());
                    break;
                }

                case SetupInputTags.SqlMachineNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlMachineName());
                    break;
                }

                case SetupInputTags.SqlDBAdminNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlDBAdminName());
                    break;
                }

                case SetupInputTags.SqlDBAdminPasswordTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlDBAdminPassword());
                    break;
                }

                case SetupInputTags.SqlDBAdminDomainTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlDBAdminDomain());
                    break;
                }

                case SetupInputTags.SqlServerPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlServerPort());
                    break;
                }

                case SetupInputTags.SqlDataFileLocationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlFileLocation());
                    break;
                }

                case SetupInputTags.SqlLogFileLocationTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SqlFileLocation());
                    break;
                }

                case SetupInputTags.IndigoTcpPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new IndigoTcpPort());
                    break;
                }

                case SetupInputTags.IndigoHTTPSPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new IndigoHTTPSPort());
                    break;
                }

                case SetupInputTags.IndigoNETTCPPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new IndigoNETTCPPort());
                    break;
                }

                case SetupInputTags.IndigoHTTPPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new IndigoHTTPPort());
                    break;
                }

                case SetupInputTags.WSManTcpPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new WSManTcpPort());
                    break;
                }

                case SetupInputTags.BitsTcpPortTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new BitsTcpPort());
                    break;
                }

                case SetupInputTags.VmmServerNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VmmServerName());
                    break;
                }

                case SetupInputTags.VmmServiceLocalAccountTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VmmServiceLocalAccount());
                    break;
                }

                case SetupInputTags.VmmServiceDomainTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VmmServiceDomain());
                    break;
                }

                case SetupInputTags.VmmServiceUserNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VmmServiceUserName());
                    break;
                }

                case SetupInputTags.VmmServiceUserPasswordTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VmmServiceUserPassword());
                    break;
                }

                case SetupInputTags.CreateNewLibraryShareTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new CreateNewLibraryShare());
                    break;
                }

                case SetupInputTags.LibraryShareNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new LibraryShareName());
                    break;
                }

                case SetupInputTags.LibrarySharePathTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new LibrarySharePath());
                    break;
                }

                case SetupInputTags.LibraryShareDescriptionTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new LibraryShareDescription());
                    break;
                }

                case SetupInputTags.SQMOptInTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new SQMOptIn());
                    break;
                }

                case SetupInputTags.MUOptInTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new MUOptIn());
                    break;
                }

                case SetupInputTags.TopContainerNameTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new TopContainerName());
                    break;
                }

                case SetupInputTags.HighlyAvailableTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new HighlyAvailable());
                    break;
                }

                case SetupInputTags.HighlyAvailable2ndNodeTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new HighlyAvailable2ndNode());
                    break;
                }

                case SetupInputTags.UpgradeTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new Upgrade());
                    break;
                }

                case SetupInputTags.VMMStaticIPAddressTag:
                {
                    PropertyBagDictionary.Instance.SafeAdd(parameter, new VMMStaticIPAddress());
                    break;
                }

                default:
                {
                    AppAssert.Assert(false, "Unknown parameter", parameter);
                    break;
                }
                }

                // Initialize all the parameters to defaults
                inputParameter = this.FindItem(parameter);
                inputParameter.ResetToDefault();
            }
        }