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)); } }
/// <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); }
/// <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); } }
/// <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"); } }
/// <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); }
/// <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]); }
/// <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(); } }