/// <inheritdoc /> public T GetComponent <T>(string name) { Fail.IfArgumentWhiteSpace(name, nameof(name)); return(this.windsorContainer .Kernel .Resolve <T>(name)); }
/// <inheritdoc /> public bool HasComponent(string name) { Fail.IfArgumentWhiteSpace(name, nameof(name)); return(this.windsorContainer .Kernel .HasComponent(name)); }
public ActionResult Book(string name) { Fail.IfArgumentWhiteSpace(name, nameof(name)); var book = BookStore.GetBook(name); return(RedirectToBookEditor(book)); }
public static void ApproveForScenario <T>(this Json <T> json, string scenario) { Fail.IfArgumentWhiteSpace(scenario, nameof(scenario)); using (ApprovalResults.ForScenario(scenario)) { json.Approve(); } }
public static Contractor CreatePerson([NotNull] string firstName, [NotNull] string lastName) { Fail.IfArgumentEmpty(firstName, nameof(firstName)); Fail.IfArgumentWhiteSpace(lastName, nameof(lastName)); return(new Contractor() { FirstName = firstName, LastName = lastName }); }
public ActionResult Word(Guid categoryId, string name) { Fail.IfArgumentEmpty(categoryId, nameof(categoryId)); Fail.IfArgumentWhiteSpace(name, nameof(name)); var category = BookStore.GetCategory(categoryId); var word = category.GetWord(name); var model = new EditModel(word); return(View(model)); }
public ActionResult CategoryCreate([NotNull] NewCategoryModel model) { Fail.IfArgumentNull(model, nameof(model)); Fail.IfArgumentEmpty(model.BookId, nameof(model.BookId)); Fail.IfArgumentWhiteSpace(model.Name, nameof(model.Name)); var book = BookStore.GetBookById(model.BookId); var category = book.CreateCategory(model.Name); book.Save(); return(RedirectToCategoryEditor(category)); }
public ActionResult CategoryUpdate([NotNull] EditCategoryModel model) { Fail.IfArgumentNull(model, nameof(model)); Fail.IfArgumentEmpty(model.Id, nameof(model.Id)); Fail.IfArgumentWhiteSpace(model.Name, nameof(model.Name)); var category = BookStore.GetCategory(model.Id); category.Rename(model.Name); category.Book.Save(); return(RedirectToCategoryEditor(category)); }
public void IfArgumentWhiteSpace() { Assert.Throws <DesignByContractViolationException>( () => Fail.IfArgumentWhiteSpace(null, "null") ); Assert.Throws <DesignByContractViolationException>( () => Fail.IfArgumentWhiteSpace("", "empty") ); Assert.Throws <DesignByContractViolationException>( () => Fail.IfArgumentWhiteSpace(" ", "bia³e-znaki") ); Fail.IfArgumentWhiteSpace("nie pusty", "nie-pusty"); }
public ActionResult BookSave([NotNull] EditBookModel model) { Fail.IfArgumentNull(model, nameof(model)); Fail.IfArgumentEmpty(model.Id, nameof(model.Id)); Fail.IfArgumentWhiteSpace(model.Name, nameof(model.Name)); // TODO: nazwa książki musi być unikalna - wyjątek // TODO: Dodaj obsługę wyjątków var book = BookStore.GetBookById(model.Id); var duplicate = BookStore.FindBook(model.Name); if (duplicate != null && duplicate != book) { throw new ApplicationException($"There already is book named '{model.Name}'"); } book.Rename(model.Name); book.Save(); return(RedirectToBookEditor(book)); }
public Json <T> Replace(string jsonPath, string value) { Fail.IfArgumentWhiteSpace(jsonPath, nameof(jsonPath)); Fail.IfArgumentWhiteSpace(value, nameof(value)); var json = JToken.Parse(this.Content); foreach (var token in json.SelectTokens(jsonPath)) { switch (token) { case JValue jValue: jValue.Value = value; break; case JArray jArray: jArray.Clear(); jArray.Add(value); break; } } return(new Json <T>(json.ToString(Formatting.None))); }
public void IfArgumentWhiteSpaceSuccess([NotNull] string text) { Fail.IfArgumentWhiteSpace(text, nameof(text)); }
public void IfArgumentWhiteSpace(string text) { Assert.Throws <DesignByContractViolationException>( () => Fail.IfArgumentWhiteSpace(text, nameof(text)) ); }
public Json(string content) { Fail.IfArgumentWhiteSpace(content, nameof(content)); this.Content = content; }
public void Rename([NotNull] string name) { Fail.IfArgumentWhiteSpace(name, nameof(name)); this.Name = name; }
public Paragraph Line(string line) { Fail.IfArgumentWhiteSpace(line, nameof(line)); return(new Paragraph(this.text + NL + line)); }