Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed the Environment Reference #3198

Merged
merged 9 commits into from
Sep 13, 2023
15 changes: 13 additions & 2 deletions Ginger/Ginger/ValueExpression/ValueExpressionEditorPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ limitations under the License.
using System.Collections.Generic;
using System.Dynamic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
Expand Down Expand Up @@ -941,16 +942,26 @@ private void xTestButton_Click(object sender, RoutedEventArgs e)
{
if (mVE == null)
{
if (mContext.Environment == null && mEnvs != null && mEnvs.Count > 0)
if (mContext.Environment == null && mEnvs != null && mEnvs.Count > 0 && WorkSpace.Instance.UserProfile.RecentEnvironment != Guid.Empty)
Copy link
Contributor

@Maheshkale447 Maheshkale447 Sep 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep old condition as is in case WorkSpace.Instance.UserProfile.RecentEnvironment is empty or null or if GetCurrentEnvironment() returns null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implemented the requested change

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add else part to this if which will return first environment in case WorkSpace.Instance.UserProfile.RecentEnvironment is empty or null

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added the requested changes

{
mContext.Environment = mEnvs[0];
// selects the current environment in use. this environment is then used to get the values of the environment variables
mContext.Environment = GetCurrentEnvironment();
}
mVE = new ValueExpression(mContext.Environment, mContext, WorkSpace.Instance.SolutionRepository.GetAllRepositoryItems<DataSourceBase>());

}
mVE.Value = this.xExpressionUCTextEditor.textEditor.Text;
xCalculatedTextBox.Text = mVE.ValueCalculated;
}
/// <summary>
/// Finds the selected environment from the total list of environments
/// </summary>
/// <returns>Returns the current environment</returns>
private ProjEnvironment? GetCurrentEnvironment()
{
return mEnvs.FirstOrDefault((mEnv) => mEnv.Guid == WorkSpace.Instance.UserProfile.RecentEnvironment);
}


private void OKButton_Click(object sender, RoutedEventArgs e)
{
Expand Down
Loading