internal static PSCommand[] GetProfileCommands(string shellId, bool useTestProfile) { List <PSCommand> psCommandList = new List <PSCommand>(); string fullProfileFileName1 = HostUtilities.GetFullProfileFileName((string)null, false, useTestProfile); string fullProfileFileName2 = HostUtilities.GetFullProfileFileName(shellId, false, useTestProfile); string fullProfileFileName3 = HostUtilities.GetFullProfileFileName((string)null, true, useTestProfile); string fullProfileFileName4 = HostUtilities.GetFullProfileFileName(shellId, true, useTestProfile); PSObject dollarProfile = HostUtilities.GetDollarProfile(fullProfileFileName1, fullProfileFileName2, fullProfileFileName3, fullProfileFileName4); PSCommand psCommand1 = new PSCommand(); psCommand1.AddCommand("set-variable"); psCommand1.AddParameter("Name", (object)"profile"); psCommand1.AddParameter("Value", (object)dollarProfile); psCommand1.AddParameter("Option", (object)ScopedItemOptions.None); psCommandList.Add(psCommand1); string[] strArray = new string[4] { fullProfileFileName1, fullProfileFileName2, fullProfileFileName3, fullProfileFileName4 }; foreach (string str in strArray) { if (File.Exists(str)) { PSCommand psCommand2 = new PSCommand(); psCommand2.AddCommand(str, false); psCommandList.Add(psCommand2); } } return(psCommandList.ToArray()); }
/// <summary> /// Gets the object that serves as a value to $profile and the paths on it /// </summary> /// <param name="shellId">The id identifying the host or shell used in profile file names.</param> /// <param name="useTestProfile">used from test not to overwrite the profile file names from development boxes</param> /// <param name="allUsersAllHosts">path for all users and all hosts</param> /// <param name="currentUserAllHosts">path for current user and all hosts</param> /// <param name="allUsersCurrentHost">path for all users current host</param> /// <param name="currentUserCurrentHost">path for current user and current host</param> /// <param name="dollarProfile">the object that serves as a value to $profile</param> /// <returns></returns> internal static void GetProfileObjectData(string shellId, bool useTestProfile, out string allUsersAllHosts, out string allUsersCurrentHost, out string currentUserAllHosts, out string currentUserCurrentHost, out PSObject dollarProfile) { allUsersAllHosts = HostUtilities.GetFullProfileFileName(null, false, useTestProfile); allUsersCurrentHost = HostUtilities.GetFullProfileFileName(shellId, false, useTestProfile); currentUserAllHosts = HostUtilities.GetFullProfileFileName(null, true, useTestProfile); currentUserCurrentHost = HostUtilities.GetFullProfileFileName(shellId, true, useTestProfile); dollarProfile = HostUtilities.GetDollarProfile(allUsersAllHosts, allUsersCurrentHost, currentUserAllHosts, currentUserCurrentHost); }