public void ReflectiveVisit(LibraryItem element) { Type[] types = new Type[] { element.GetType() }; MethodInfo methodInfo = this.GetType().GetMethod("Visit", types); methodInfo?.Invoke(this, new object[] { element }); }
private void InitUIElements() { Title = $"{_item.GetType().Name} Copies"; btnSave.IsEnabled = false; grdHeader.DataContext = this; dgCopies.ItemsSource = _itemCopiesViewModel.Values.ToList(); CollectionViewSource.GetDefaultView(dgCopies.Items).CollectionChanged += ItemCopiesWindow_CollectionChanged; SetToolBarsAvailability(); }
private bool UserCanCurrentlyLendItem(LibraryItem item, User user) { bool result = false; if (user.Status == UserStatus.Blocked) { return(result); } if (user.Lendings.Count(l => l.Item.GetType() == item.GetType()) < item.MaximumNumberOfItemsInLending()) { result = true; } return(result); }
// j2tta sisse sellep2rast, et n2idata kuidas meetodi olemasolu kontrollitakse (reflektsioon). muidu m6ttetu test. private bool HasMethod(LibraryItem objectToCheck, string methodName) { var type = objectToCheck.GetType(); return(type.GetMethod(methodName) != null); }