Beispiel #1
0
            protected override void DoValidate(string objectToValidate, object currentTarget, string key,
                                               ValidationResults validationResults)
            {
                ICreateViewPageModel pageModel = currentTarget as ICreateViewPageModel;

                if (pageModel != null)
                {
                    string physicalPath = string.Empty;
                    if (pageModel.ProjectItem != null)
                    {
                        physicalPath = pageModel.ProjectItem.ItemPath;
                    }
                    else
                    {
                        physicalPath = pageModel.ModuleProject.ProjectPath;
                    }
                    string moduleViewsProjectPath = (pageModel.CreateViewFolder)
                                                                                ? Path.Combine(physicalPath, objectToValidate)
                                                                                : physicalPath;
                    string fileName =
                        String.Format(CultureInfo.CurrentCulture, "{0}Presenter.{1}", objectToValidate, pageModel.Language);
                    string fullFileName = Path.Combine(moduleViewsProjectPath, fileName);

                    if (objectToValidate == null || fullFileName.Length > maxFullFileNameLength ||
                        objectToValidate.Length > maxFileNameLength)
                    {
                        LogValidationResult(validationResults, MessageTemplate, currentTarget, key);
                    }
                }
            }
        protected override void DoValidate(string objectToValidate, object currentTarget, string key, ValidationResults validationResults)
        {
            ICreateViewPageModel pageModel = currentTarget as ICreateViewPageModel;

            if (pageModel != null && pageModel.ValidateExistingFileExtension != null)
            {
                string physicalPath = string.Empty;
                if (pageModel.ProjectItem != null)
                {
                    physicalPath = pageModel.ProjectItem.ItemPath;
                }
                else
                {
                    physicalPath = pageModel.ModuleProject.ProjectPath;
                }
                string moduleViewsProjectPath = (pageModel.CreateViewFolder) ? Path.Combine(physicalPath, objectToValidate) : physicalPath;

                string viewFileName      = String.Format(CultureInfo.CurrentCulture, "{0}.{1}", objectToValidate, pageModel.ValidateExistingFileExtension);
                string viewExistsMessage = (pageModel.IsWpfView) ? Resources.YouCantAddWpfViewIfFormsViewExists : Resources.YouCantAddFormsViewIfWpfViewExists;

                Validator <string> _viewViewFileValidator = new FileNotExistsValidator(
                    moduleViewsProjectPath,
                    String.Format(CultureInfo.CurrentCulture, viewExistsMessage, Path.Combine(moduleViewsProjectPath, viewFileName)));
                _viewViewFileValidator.Validate(viewFileName, validationResults);
            }
        }
Beispiel #3
0
        public CreateViewPagePresenter(ICreateViewPage view, ICreateViewPageModel model)
        {
            _view  = view;
            _model = model;

            _view.ViewNameChanged          += new EventHandler <EventArgs>(OnViewNameChanged);
            _view.RequestingValidation     += new EventHandler <EventArgs <bool> >(OnRequestingValidation);
            _view.ShowDocumentationChanged += new EventHandler <EventArgs>(OnShowDocumentationChanged);
            _view.CreateViewFolderChanged  += new EventHandler <EventArgs>(OnCreateViewFolderChanged);
        }