Exemplo n.º 1
0
        private void PopulateParameters()
        {
            // Temp dictionary
            Dictionary <string, string> tempDict = new Dictionary <string, string>();

            // Save all values from grid to be able to reuse them again
            foreach (DataGridViewRow row in dgvParameters.Rows)
            {
                tempDict.Add((string)row.Cells["colName"].Value, (string)row.Cells["colValue"].Value);
            }

            // Clear parameterlist
            dgvParameters.Rows.Clear();

            // Get parameters from product
            if (Product.Parameters.Count > 0)
            {
                foreach (Parameter param in Product.Parameters)
                {
                    // Check if parameter should be shown depending on versions
                    if (!string.IsNullOrEmpty(param.ProductVersionIntroduced) &&
                        VersionHandler.IsVersion(param.ProductVersionIntroduced))
                    {
                        // If selected version is less than the version it was introduced then don't show it
                        if (VersionHandler.VersionStringCompare(SelectedRunningVersion.Name, param.ProductVersionIntroduced) < 0)
                        {
                            continue;
                        }
                    }

                    if (!string.IsNullOrEmpty(param.ProductVersionLastUsed) &&
                        VersionHandler.IsVersion(param.ProductVersionLastUsed))
                    {
                        // If selected version is greater than the version it was last used then don't show it
                        if (VersionHandler.VersionStringCompare(SelectedRunningVersion.Name, param.ProductVersionLastUsed) > 0)
                        {
                            continue;
                        }
                    }

                    // Check if we were editing an instance and if the current parameter value could be reused.
                    if (tempDict.ContainsKey(param.Name) && !string.IsNullOrEmpty(tempDict[param.Name]))
                    {
                        AddParameterRow(param.Name, tempDict[param.Name], param.IsMandatory, param.Description);
                    }
                    else if (EditInstance != null && EditInstance.Parameters.ContainsKey(param.Name))
                    {
                        AddParameterRow(param.Name, EditInstance.Parameters[param.Name], param.IsMandatory, param.Description);
                    }
                    else
                    {
                        AddParameterRow(param.Name, param.Default, param.IsMandatory, param.Description);
                    }
                }
            }
        }