private bool isValidGameInformation(string title, string description, double size, decimal price, string imageUrl, string videoUrl) { var isValid = true; if (!TitleValidator.IsValid(title)) { this.ViewData["<!--ErrorTitle-->"] = "<div class=\"col - md - 4\">" + "<p class=\"text-danger\">Invalid Title. Has to begin with uppercase letter and" + "has length between 3 and 100 symbols (inclusive)" + "</div>"; isValid = false; } if (description.Length < 20) { this.ViewData["<!--ErrorDescription-->"] = "<div class=\"col - md - 4\">" + "<p class=\"text-danger\">Invalid Description! Must be at least 20 symbols" + "</div>"; isValid = false; } if (price < 0) { this.ViewData["<!--ErrorPrice-->"] = "<div class=\"col - md - 4\">" + "<p class=\"text-danger\">Invalid Price! Must be a positive number" + "</div>"; isValid = false; } if (size < 0) { this.ViewData["<!--ErrorSize-->"] = "<div class=\"col - md - 4\">" + "<p class=\"text-danger\">Invalid Size! Must be a positive number" + "</div>"; isValid = false; } if (string.IsNullOrEmpty(imageUrl) || string.IsNullOrWhiteSpace(imageUrl)) { this.ViewData["<!--ErrorImageUrl-->"] = "<div class=\"col - md - 4\">" + "<p class=\"text-danger\">Invalid Image URL! Is Required" + "</div>"; isValid = false; } if (videoUrl.Length != 11) { this.ViewData["<!--ErrorVideoUrl-->"] = "<div class=\"col - md - 4\">" + "<p class=\"text-danger\">Invalid Video URL! Is always 11 characters" + "</div>"; isValid = false; } if (isValid) { return(true); } return(false); }
public bool IsValid() { var validation = new TitleValidator(); var result = validation.Validate(this); ValidationErrors = result.Errors; return(result.IsValid); }
public OperationResult SetTitle(string title) { var operationResult = new TitleValidator().Validate(title); if (operationResult.Success) { Title = title; } return(operationResult); }
public static void Title(this IOperationRunner <IBrowserWrapper> operationRunner, Expression <Func <string, bool> > expression, string failureMessage = "") { var Title = new TitleValidator(expression, failureMessage); operationRunner.Evaluate <BrowserException>(Title); }
public static void Title(IBrowserWrapper wrapper, Expression <Func <string, bool> > expression, string failureMessage = "") { var title = new TitleValidator(expression, failureMessage); EvaluateValidator <BrowserException, IBrowserWrapper>(wrapper, title); }
private void CreateMenu() { MenuItem[] menu = null; MenuItem[] fileMenu = new MenuItem[] { new MenuItem { Label = "Load file", Type = MenuType.normal, Click = async() => { var mainWindow = Electron.WindowManager.BrowserWindows.First(); var options = new OpenDialogOptions() { Properties = new OpenDialogProperty[] { OpenDialogProperty.openFile }, Filters = new FileFilter[] { new FileFilter { Name = "Word Documents (.docx)", Extensions = new string[] { "docx" } } } }; string[] filePaths = await Electron.Dialog.ShowOpenDialogAsync(mainWindow, options); WordprocessingDocument wordProcessingDocument = WordprocessingDocument.Open(filePaths[0], false); if (wordProcessingDocument.MainDocumentPart != null) { Document document = wordProcessingDocument.MainDocumentPart.Document; Dictionary <String, List <String> > errorsMap = new Dictionary <string, List <string> >(); TitleValidator.Validate(errorsMap, document, filePaths[0]); foreach (var error in errorsMap.Values) { Array.ForEach(error.ToArray(), Console.WriteLine); } validatePageMargins(document); } } }, new MenuItem { Type = MenuType.separator }, new MenuItem { Role = MenuRole.quit } }; MenuItem[] viewMenu = new MenuItem[] { new MenuItem { Role = MenuRole.reload }, new MenuItem { Role = MenuRole.forcereload }, new MenuItem { Role = MenuRole.toggledevtools }, new MenuItem { Type = MenuType.separator }, new MenuItem { Role = MenuRole.resetzoom }, new MenuItem { Role = MenuRole.zoomin }, new MenuItem { Role = MenuRole.zoomout }, new MenuItem { Type = MenuType.separator }, new MenuItem { Role = MenuRole.togglefullscreen } }; menu = new MenuItem[] { new MenuItem { Label = "File", Type = MenuType.submenu, Submenu = fileMenu }, new MenuItem { Label = "View", Type = MenuType.submenu, Submenu = viewMenu } }; Electron.Menu.SetApplicationMenu(menu); }