Ejemplo n.º 1
0
        protected override string IsValid(object currentValue, Type typeToTest)
        {
            if (currentValue is string s)
            {
                return(UsefulStuff.IsBadName(s) ? "Name contains illegal characters":null);
            }

            return(null);
        }
Ejemplo n.º 2
0
        public string DescribeProblem(object o)
        {
            if (o is INamed n && !_ignoreBadNamesFor.Contains(o.GetType()) && UsefulStuff.IsBadName(n.Name))
            {
                return("Name contains illegal characters");
            }

            return(DescribeProblemImpl(o));
        }
Ejemplo n.º 3
0
        protected override string IsValid(object currentValue, Type typeToTest)
        {
            if (ProblemProvider.IgnoreBadNamesFor.Any(t => t.IsAssignableFrom(typeof(T))))
            {
                return(null);
            }

            if (currentValue is string s)
            {
                return(UsefulStuff.IsBadName(s) ? "Name contains illegal characters":null);
            }

            return(null);
        }
Ejemplo n.º 4
0
        public override void Execute()
        {
            base.Execute();

            if (!_explicitNewValuePassed)
            {
                var dialog = new TypeTextOrCancelDialog("Rename " + _nameable.GetType().Name, "Name", 2000, _nameable.Name);
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    while (UsefulStuff.IsBadName(dialog.ResultText))
                    {
                        if (YesNo("Name contains illegal characters, do you want to use it anyway?", "Bad Name"))
                        {
                            //user wants to use the name anyway
                            break;
                        }

                        //user does not want to use the bad name

                        //type a new one then
                        dialog = new TypeTextOrCancelDialog("Rename " + _nameable.GetType().Name, "Name", 2000, dialog.ResultText);

                        //no? in that case lets just give up altogether
                        if (dialog.ShowDialog() != DialogResult.OK)
                        {
                            return;
                        }
                    }
                    _newValue = dialog.ResultText;
                }
                else
                {
                    return;
                }
            }

            _nameable.Name = _newValue;
            EnsureNameIfCohortIdentificationAggregate();

            _nameable.SaveToDatabase();
            Publish((DatabaseEntity)_nameable);
        }
Ejemplo n.º 5
0
        public override void Execute()
        {
            base.Execute();

            if (!_explicitNewValuePassed)
            {
                if (TypeText("Rename " + _nameable.GetType().Name, "Name", 2000, _nameable.Name, out string text))
                {
                    while (UsefulStuff.IsBadName(text))
                    {
                        if (YesNo("Name contains illegal characters, do you want to use it anyway?", "Bad Name"))
                        {
                            //user wants to use the name anyway
                            break;
                        }

                        //user does not want to use the bad name

                        //type a new one then

                        if (!TypeText("Rename " + _nameable.GetType().Name, "Name", 2000, _nameable.Name, out text))
                        {
                            return;
                        }
                    }

                    _newValue = text;
                }
                else
                {
                    return;
                }
            }

            _nameable.Name = _newValue;
            EnsureNameIfCohortIdentificationAggregate();

            _nameable.SaveToDatabase();
            Publish((DatabaseEntity)_nameable);
        }
Ejemplo n.º 6
0
        public string DescribeProblem(object o)
        {
            if (o is INamed n && !IgnoreBadNamesFor.Any(t => t.IsInstanceOfType(o)) && UsefulStuff.IsBadName(n.Name))
            {
                return("Name contains illegal characters");
            }

            return(DescribeProblemImpl(o));
        }