Esempio n. 1
0
        public void GenerateNewNameTest()
        {
            UniqueNameGenerator _newInstance = new UniqueNameGenerator("RandomPrefix");
            string _newName1 = _newInstance.GenerateNewName();

            Assert.IsTrue(_newName1.StartsWith("RandomPrefix"));
            for (int i = 0; i < 1000; i++)
            {
                string _newName = _newInstance.GenerateNewName();
                Assert.AreNotEqual <string>(_newName1, _newName);
                Assert.IsTrue(_newName.StartsWith("RandomPrefix"));
                Assert.IsTrue(_newName.Contains($"{i+1}"), $"{_newName} - for {i}");
            }
        }
        internal static void OpenExisting(string solutionFileName, IGraphicalUserInterface gui)
        {
            AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Verbose, 234587501, $"Opening an existing solution captured in the file {solutionFileName} of the {nameof(SolutionConfigurationManagement)}");
            if ((DefaultInstance.CurrentConfiguration != null) && !DefaultInstance.CurrentConfiguration.TestIfChangesArePresentDisplayWindowAndReturnTrueIfShouldBeContinued())
            {
                return;
            }
            Tuple <UAModelDesignerSolution, string> _solution = null;
            bool _ChangesArePresent = false;

            try
            {
                if (String.IsNullOrEmpty(solutionFileName) || !File.Exists(solutionFileName))
                {
                    if (DefaultInstance.CurrentConfiguration != null)
                    {
                        _solution = SolutionConfigurationManagement.ReadConfiguration(gui, SolutionConfigurationManagement.SetupFileDialog);
                        if (_solution == null)
                        {
                            return;
                        }
                    }
                    else
                    {
                        string _defPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "UAModelDesignerSolution");
                        _solution          = new Tuple <UAModelDesignerSolution, string>(UAModelDesignerSolution.CreateEmptyModel(m_UniqueNameGenerator.GenerateNewName()), _defPath);
                        _ChangesArePresent = true;
                    }
                }
                else
                {
                    solutionFileName = Path.GetFullPath(solutionFileName);
                    _solution        = new Tuple <UAModelDesignerSolution, string>(SolutionConfigurationManagement.ReadConfiguration(solutionFileName, gui), solutionFileName);
                }
                if (_solution.Item1.ServerDetails == null)
                {
                    _solution.Item1.ServerDetails = UAModelDesignerSolutionServerDetails.CreateEmptyInstance();
                }
                ISolutionConfigurationManagement _newSolution = new SolutionConfigurationManagement(_solution, _ChangesArePresent, gui);
                DefaultInstance.OnSolutionChanged(_newSolution);
                return;
            }
            catch (Exception ex)
            {
                string _tmp = "Cannot initialize {0} described by {1} because of exception: {2}.";
                AssemblyTraceEvent.Tracer.TraceEvent(TraceEventType.Critical, 234587502, string.Format(_tmp, typeof(SolutionConfigurationManagement).FullName, _solution.Item2, ex.Message));
                throw;
            }
        }
        void ISolutionConfigurationManagement.NewModelDesign()
        {
            IProjectConfigurationManagement _newModel = ProjectConfigurationManagement.CreateNew(this, base.GraphicalUserInterface, m_UniqueNameGenerator.GenerateNewName());

            if (_newModel == null)
            {
                throw new ApplicationException("New project must be created");
            }
            AddProjectTCollection(_newModel);
        }