public ExplorerTopBarViewModel(ExplorerSettingsContainer settings, ITypeFactory typeFactory, IUIVisualizerService uIVisualizerService, INuGetConfigurationService configurationService, INuGetCacheManager nuGetCacheManager, IPleaseWaitService pleaseWaitService, IMessageService messageService, IMessageMediator messageMediator) { Argument.IsNotNull(() => typeFactory); Argument.IsNotNull(() => uIVisualizerService); Argument.IsNotNull(() => configurationService); Argument.IsNotNull(() => settings); Argument.IsNotNull(() => nuGetCacheManager); Argument.IsNotNull(() => pleaseWaitService); Argument.IsNotNull(() => messageService); Argument.IsNotNull(() => messageMediator); _typeFactory = typeFactory; _uIVisualizerService = uIVisualizerService; _configurationService = configurationService; _nuGetCacheManager = nuGetCacheManager; _pleaseWaitService = pleaseWaitService; _messageService = messageService; _messageMediator = messageMediator; Settings = settings; Title = "Manage NuGet Packages"; CommandInitialize(); }
public MessageCreation(IMessageMediator messageMediator) { InitializeComponent(); MessageMediator = messageMediator; NameMessage = new MessageModel(); }
/// <summary> /// Initializes a new instance of the <see cref="EmployeesViewModel"/> class. /// </summary> public EmployeesViewModel(IMessageMediator messageMediator, IUIVisualizerService uiVisualizerService, IEmployeeRepository employeeRepository, IMessageService messageService) : base(messageMediator) { Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => employeeRepository); Argument.IsNotNull(() => messageService); _uiVisualizerService = uiVisualizerService; _employeeRepository = employeeRepository; _messageService = messageService; AddEmployee = new Command(OnAddEmployeeExecute); EditEmployee = new Command(OnEditEmployeeExecute, OnEditEmployeeCanExecute); DeleteEmployee = new Command(OnDeleteEmployeeExecute, OnDeleteEmployeeCanExecute); Employees = new FastObservableCollection <IEmployee>(); if (!ObjectHelper.IsNull(SelectedDepartment)) { Employees.AddRange(EmployeeRepository.GetAllEmployees(SelectedDepartment.Name)); } if (Employees.Count > 0) { SelectedEmployee = Employees[0]; } Mediator.Register <string>(this, OnSelectedDepartmentUpdated, "UpdateEmployees"); }
public DocumentViewModel(string path, IMessageService messageService, ISaveFileService saveFileService, IMessageMediator messageMediator) { this.messageService = messageService; this.saveFileService = saveFileService; this.messageMediator = messageMediator; SaveCommand = new TaskCommand(SaveAsync, () => HasChanges); SaveAsCommand = new TaskCommand(SaveFileAs); if (string.IsNullOrWhiteSpace(path)) { Name = "Document " + (++documentCounter) + ".txt"; HasChanges = true; } else { fullFileName = path; Name = Path.GetFileName(path); Text = File.ReadAllText(path); HasChanges = false; } }
/// <summary> /// Unsubscribes all methods of the specified instance that are decorated with the <see cref="MessageRecipientAttribute"/>. /// </summary> /// <param name="instance">The instance.</param> /// <param name="messageMediator">The message mediator. If <c>null</c>, the default will be used.</param> /// <exception cref="ArgumentNullException">The <paramref name="instance"/> is <c>null</c>.</exception> public static void UnsubscribeRecipient(object instance, IMessageMediator messageMediator = null) { Argument.IsNotNull("instance", instance); var mediator = messageMediator ?? ServiceLocator.Default.ResolveType<IMessageMediator>(); mediator.UnregisterRecipient(instance); }
/// <summary> /// Initializes a new instance of the <see cref="EmployeesViewModel"/> class. /// </summary> public EmployeesViewModel(IMessageMediator messageMediator, IUIVisualizerService uiVisualizerService, IEmployeeRepository employeeRepository, IMessageService messageService) : base(messageMediator) { Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => employeeRepository); Argument.IsNotNull(() => messageService); _uiVisualizerService = uiVisualizerService; _employeeRepository = employeeRepository; _messageService = messageService; AddEmployee = new Command(OnAddEmployeeExecute); EditEmployee = new Command(OnEditEmployeeExecute, OnEditEmployeeCanExecute); DeleteEmployee = new Command(OnDeleteEmployeeExecute, OnDeleteEmployeeCanExecute); Employees = new FastObservableCollection<IEmployee>(); if (!ObjectHelper.IsNull(SelectedDepartment)) { Employees.AddRange(EmployeeRepository.GetAllEmployees(SelectedDepartment.Name)); } if (Employees.Count > 0) { SelectedEmployee = Employees[0]; } Mediator.Register<string>(this, OnSelectedDepartmentUpdated, "UpdateEmployees"); }
/// <summary> /// Can be used to set the message mediator instance; this is useful to replace /// the built-in system service. /// </summary> /// <param name="mediator">Mediator to use.</param> public static void SetMessageMediator(IMessageMediator mediator) { if (instance != null) { throw new InvalidOperationException("Can only set the MessageMediator once."); } instance = mediator; }
/// <summary> /// Initializes a new instance of the <see cref="DocumentMapViewModel"/> class. /// </summary> public DocumentMapViewModel(string Regex) { RegexContent = Regex; SaveRegex = new Command(OnSaveRegexExecute); _messageMediator = Catel.IoC.ServiceLocator.Default.ResolveType <IMessageMediator>(); }
/// <summary> /// Unsubscribes all methods of the specified instance that are decorated with the <see cref="MessageRecipientAttribute"/>. /// </summary> /// <param name="instance">The instance.</param> /// <param name="messageMediator">The message mediator. If <c>null</c>, the default will be used.</param> /// <exception cref="ArgumentNullException">The <paramref name="instance"/> is <c>null</c>.</exception> public static void UnsubscribeRecipient(object instance, IMessageMediator messageMediator = null) { Argument.IsNotNull("instance", instance); var mediator = messageMediator ?? ServiceLocator.Default.ResolveType <IMessageMediator>(); mediator.UnregisterRecipient(instance); }
public BrowserDocumentViewModel(IMessageMediator messageMediator) { _MessageMediator = messageMediator; Url = "http://www.metaseed.com"; GoBack = new Command(OnGoBackExecute, OnGoBackCanExecute); GoForward = new Command(OnGoForwardExecute, OnGoForwardCanExecute); Browse = new Command(OnBrowseExecute, OnBrowseCanExecute); }
/// <summary>Initializes a new instance of the <see cref="BrowserViewModel" /> class.</summary> /// <param name="mediator">The mediator.</param> public BrowserViewModel(IMessageMediator mediator) { _browserQueryViewerViewModel = TypeFactory.Default.CreateInstance <BrowserQueryViewerViewModel>(); CurrentModel = _browserQueryViewerViewModel; mediator.Register <SimpleMessage>(this, OnMessageReceived); }
/// <summary> /// Initializes a new instance of the <see cref="DataGridViewModel"/> class. /// </summary> /// <param name="title">The title.</param> /// <param name="openFileService">The open file service.</param> /// <param name="saveFileService">The save file service.</param> /// <param name="uiVisualizerService">The UI visualizer service.</param> /// <param name="messageMediator">The message mediator.</param> public DataGridViewModel(string title, IOpenFileService openFileService, ISaveFileService saveFileService, IUIVisualizerService uiVisualizerService, IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager) : this(openFileService, saveFileService, uiVisualizerService, messageMediator, contextualViewModelManager) { if (!string.IsNullOrWhiteSpace(title)) { Title = title; } }
/// <summary> /// Initializes a new instance of the <see cref="EmployeeViewModel" /> class. /// </summary> /// <param name="employee">The employee.</param> /// <param name="messageMediator">The message mediator.</param> /// <param name="departmentRepository">The department repository.</param> /// <exception cref="ArgumentNullException">The <paramref name="employee" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="messageMediator" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="departmentRepository" /> is <c>null</c>.</exception> public EmployeeViewModel(IEmployee employee, IMessageMediator messageMediator, IDepartmentRepository departmentRepository) : base(messageMediator) { Argument.IsNotNull(() => employee); Argument.IsNotNull(() => messageMediator); Employee = employee; AvailableDepartments = new FastObservableCollection <IDepartment>(departmentRepository.GetAllDepartments()); }
/// <summary> /// Initializes a new instance of the <see cref="EmployeeViewModel" /> class. /// </summary> /// <param name="employee">The employee.</param> /// <param name="messageMediator">The message mediator.</param> /// <param name="departmentRepository">The department repository.</param> /// <exception cref="ArgumentNullException">The <paramref name="employee" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="messageMediator" /> is <c>null</c>.</exception> /// <exception cref="ArgumentNullException">The <paramref name="departmentRepository" /> is <c>null</c>.</exception> public EmployeeViewModel(IEmployee employee, IMessageMediator messageMediator, IDepartmentRepository departmentRepository) : base(messageMediator) { Argument.IsNotNull(() => employee); Argument.IsNotNull(() => messageMediator); Employee = employee; AvailableDepartments = new FastObservableCollection<IDepartment>(departmentRepository.GetAllDepartments()); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> static MessageBase() { var serviceLocator = ServiceLocator.Default; if (!serviceLocator.IsTypeRegistered <IMessageMediator>()) { serviceLocator.RegisterInstance <IMessageMediator>(MessageMediator.Default); } _mediator = ServiceLocator.Default.ResolveType <IMessageMediator>(); }
/// <summary> /// Initializes a new instance of the <see cref="T:System.Object"/> class. /// </summary> static MessageBase() { var serviceLocator = IoCConfiguration.DefaultServiceLocator; if (!serviceLocator.IsTypeRegistered <IMessageMediator>()) { serviceLocator.RegisterInstance(MessageMediator.Default); } _mediator = serviceLocator.ResolveType <IMessageMediator>(); }
/// <summary> /// Unsubscribes all methods of the specified instance that are decorated with the <see cref="MessageRecipientAttribute"/>. /// </summary> /// <param name="instance">The instance.</param> /// <param name="messageMediator">The message mediator. If <c>null</c>, the default will be used.</param> /// <exception cref="ArgumentNullException">The <paramref name="instance"/> is <c>null</c>.</exception> public static void UnsubscribeRecipient(object instance, IMessageMediator messageMediator = null) { Argument.IsNotNull("instance", instance); if (messageMediator == null) { var dependencyResolver = IoCConfiguration.DefaultDependencyResolver; messageMediator = dependencyResolver.Resolve <IMessageMediator>(); } messageMediator.UnregisterRecipient(instance); }
/// <summary> /// Initializes a new instance of the <see cref="DepartmentsViewModel"/> class. /// </summary> public DepartmentsViewModel(IMessageMediator messageMediator, IDepartmentRepository departmentRepository, IUIVisualizerService uiVisualizerService) : base(messageMediator) { _uiVisualizerService = uiVisualizerService; Departments = new FastObservableCollection<IDepartment>(departmentRepository.GetAllDepartments()); if (Departments.Count > 0) { SelectedDepartment = Departments[0]; } Select = new Command(OnSelectExecute); }
/// <summary> /// Initializes a new instance of the <see cref="DepartmentsViewModel"/> class. /// </summary> public DepartmentsViewModel(IMessageMediator messageMediator, IDepartmentRepository departmentRepository, IUIVisualizerService uiVisualizerService) : base(messageMediator) { _uiVisualizerService = uiVisualizerService; Departments = new FastObservableCollection <IDepartment>(departmentRepository.GetAllDepartments()); if (Departments.Count > 0) { SelectedDepartment = Departments[0]; } Select = new Command(OnSelectExecute); }
public DataGridViewModel(IOpenFileService openFileService, ISaveFileService saveFileService, IUIVisualizerService uiVisualizerService, IMessageMediator messageMediator) { Argument.IsNotNull(() => openFileService); Argument.IsNotNull(() => saveFileService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageMediator); _openFileService = openFileService; _saveFileService = saveFileService; _uiVisualizerService = uiVisualizerService; _messageMediator = messageMediator; }
/// <summary> /// Subscribes all methods of the specified instance that are decorated with the <see cref="MessageRecipientAttribute"/>. /// </summary> /// <param name="instance">The instance to subscribe.</param> /// <param name="messageMediator">The message mediator. If <c>null</c>, the default will be used.</param> /// <exception cref="ArgumentNullException">The <paramref name="instance"/> is <c>null</c>.</exception> /// <exception cref="NotSupportedException">The object has non-public methods decorated with the <see cref="MessageRecipientAttribute"/>, but the /// application is not written in .NET (but in Silverlight, Windows Phone or WinRT).</exception> /// <exception cref="InvalidCastException">One of the methods cannot be casted to a valid message method.</exception> public static void SubscribeRecipient(object instance, IMessageMediator messageMediator = null) { Argument.IsNotNull("instance", instance); if (messageMediator == null) { var dependencyResolver = IoCConfiguration.DefaultDependencyResolver; messageMediator = dependencyResolver.Resolve<IMessageMediator>(); } var mediator = messageMediator; var methodInfos = instance.GetType().GetMethodsEx(BindingFlagsHelper.GetFinalBindingFlags(true, false)); foreach (var methodInfo in methodInfos) { var customAttributes = methodInfo.GetCustomAttributesEx(typeof(MessageRecipientAttribute), true); foreach (var customAttribute in customAttributes) { var attribute = (MessageRecipientAttribute)customAttribute; var parameterInfos = methodInfo.GetParameters(); Type actionType; Type actionParameterType; switch (parameterInfos.Length) { case 0: actionType = typeof(Action<object>); actionParameterType = typeof(object); break; case 1: actionType = typeof(Action<>).MakeGenericType(parameterInfos[0].ParameterType); actionParameterType = parameterInfos[0].ParameterType; break; default: var error = string.Format("Cannot cast '{0}' to Action or Action<T> delegate type.", methodInfo.Name); Log.Error(error); throw new InvalidCastException(error); } var tag = attribute.Tag; var action = DelegateHelper.CreateDelegate(actionType, instance, methodInfo); var registerMethod = mediator.GetType().GetMethodEx("Register").MakeGenericMethod(actionParameterType); registerMethod.Invoke(mediator, new[] { instance, action, tag }); } } }
/// <summary> /// Subscribes all methods of the specified instance that are decorated with the <see cref="MessageRecipientAttribute"/>. /// </summary> /// <param name="instance">The instance to subscribe.</param> /// <param name="messageMediator">The message mediator. If <c>null</c>, the default will be used.</param> /// <exception cref="ArgumentNullException">The <paramref name="instance"/> is <c>null</c>.</exception> /// <exception cref="NotSupportedException">The object has non-public methods decorated with the <see cref="MessageRecipientAttribute"/>, but the /// application is not written in .NET (but in SL, WP7 or WinRT).</exception> /// <exception cref="InvalidCastException">One of the methods cannot be casted to a valid message method.</exception> public static void SubscribeRecipient(object instance, IMessageMediator messageMediator = null) { Argument.IsNotNull("instance", instance); if (messageMediator == null) { var dependencyResolver = IoCConfiguration.DefaultDependencyResolver; messageMediator = dependencyResolver.Resolve <IMessageMediator>(); } var mediator = messageMediator; var methodInfos = instance.GetType().GetMethodsEx(BindingFlagsHelper.GetFinalBindingFlags(true, false)); foreach (var methodInfo in methodInfos) { var customAttributes = methodInfo.GetCustomAttributesEx(typeof(MessageRecipientAttribute), true); foreach (var customAttribute in customAttributes) { var attribute = (MessageRecipientAttribute)customAttribute; var parameterInfos = methodInfo.GetParameters(); Type actionType; Type actionParameterType; switch (parameterInfos.Length) { case 0: actionType = typeof(Action <object>); actionParameterType = typeof(object); break; case 1: actionType = typeof(Action <>).MakeGenericType(parameterInfos[0].ParameterType); actionParameterType = parameterInfos[0].ParameterType; break; default: var error = string.Format("Cannot cast '{0}' to Action or Action<T> delegate type.", methodInfo.Name); Log.Error(error); throw new InvalidCastException(error); } var tag = attribute.Tag; var action = DelegateHelper.CreateDelegate(actionType, instance, methodInfo); var registerMethod = mediator.GetType().GetMethodEx("Register").MakeGenericMethod(actionParameterType); registerMethod.Invoke(mediator, new[] { instance, action, tag }); } } }
/// <summary> /// Initializes a new instance of the <see cref="PropertiesViewModel"/> class. /// </summary> public PropertiesViewModel(IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager) { Argument.IsNotNull(() => orchestraService); Argument.IsNotNull(() => orchestraService); Argument.IsNotNull(() => messageMediator); _messageService = messageService; _orchestraService = orchestraService; _messageMediator = messageMediator; Title = "Properties"; // Comands DocMapSelectedCommand = new Command(OnDocMapSelectedCommandExecute, OnDocMapSelectedCommandCanExecute); }
/// <summary> /// Initializes a new instance of the <see cref="HomeWindowViewModel"/> class. /// </summary> public HomeWindowViewModel(IUpdateMessagesListTask updateMessagesListTask, IMessageMediator mediator, IPleaseWaitService pleaseWaitService, IFolderWatcher folderWatcher, ITryFindParent tryFindParent, IOpenEmailFile openEmailFile) { this.updateMessagesListTask = updateMessagesListTask; this.mediator = mediator; this.pleaseWaitService = pleaseWaitService; this.folderWatcher = folderWatcher; this.tryFindParent = tryFindParent; this.openEmailFile = openEmailFile; RowDoubleClick = new Command <MouseButtonEventArgs>(OnRowDoubleClickExecute, OnRowDoubleClickCanExecute); CheckMessagesCommand = new AsynchronousCommand(OnCheckMessagesCommandExecute, () => !CheckMessagesCommand.IsExecuting); MarkAsReadCommand = new Command <MessageModel>(OnMarkAsReadCommandExecute); ImageSingleClick = new Command <MessageModel>(OnImageSingleClickExecute); Messages = new InitialLoadCommand().Load(); CheckMessagesWithWaiting(); }
/// <summary> /// Initializes a new instance of the <see cref="BrowserViewModel" /> class. /// </summary> /// <param name="messageService">The message service.</param> /// <param name="orchestraService">The orchestra service.</param> /// <param name="messageMediator">The message mediator.</param> public BrowserViewModel(IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator) { Argument.IsNotNull(() => orchestraService); Argument.IsNotNull(() => orchestraService); Argument.IsNotNull(() => messageMediator); _messageService = messageService; _orchestraService = orchestraService; _messageMediator = messageMediator; GoBack = new Command(OnGoBackExecute, OnGoBackCanExecute); GoForward = new Command(OnGoForwardExecute, OnGoForwardCanExecute); Browse = new Command(OnBrowseExecute, OnBrowseCanExecute); Test = new Command(OnTestExecute); CloseBrowser = new Command(OnCloseBrowserExecute); Title = "Browser"; }
/// <summary> /// Initializes a new instance of the <see cref="NotificationBarViewModel"/> class. /// </summary> public NotificationBarViewModel(IMessageMediator messageMediator) : base(messageMediator) { MessageMediator.Register <string>(this, data => { if (ObjectHelper.IsNull(data)) { return; } try { EventMessage = data; } catch { } }, "UpdateNotification"); }
/// <summary> /// Initializes a new instance of the <see cref="NotificationBarViewModel"/> class. /// </summary> public NotificationBarViewModel(IMessageMediator messageMediator) : base(messageMediator) { MessageMediator.Register<string>(this, data => { if (ObjectHelper.IsNull(data)) { return; } try { EventMessage = data; } catch { } }, "UpdateNotification"); }
/// <summary> /// Initializes a new instance of the <see cref="DataGridViewModel"/> class. /// </summary> /// <param name="openFileService">The open file service.</param> /// <param name="saveFileService">The save file service.</param> /// <param name="uiVisualizerService">The UI visualizer service.</param> /// <param name="messageMediator">The message mediator.</param> public DataGridViewModel(IOpenFileService openFileService, ISaveFileService saveFileService, IUIVisualizerService uiVisualizerService, IMessageMediator messageMediator, IContextualViewModelManager contextualViewModelManager) { Argument.IsNotNull(() => openFileService); Argument.IsNotNull(() => saveFileService); Argument.IsNotNull(() => uiVisualizerService); Argument.IsNotNull(() => messageMediator); Argument.IsNotNull(() => contextualViewModelManager); _openFileService = openFileService; _saveFileService = saveFileService; _uiVisualizerService = uiVisualizerService; _messageMediator = messageMediator; _contextualViewModelManager = contextualViewModelManager; Items.CollectionChanged += ItemsCollectionChanged; Title = "Datagrid"; }
public QueryMediator(IMessageMediator messageMediator) { _messageMediator = messageMediator; }
/// <summary> /// Initializes a new instance of the <see cref="BrowserViewModel" /> class. /// </summary> /// <param name="title">The title.</param> /// <param name="messageService">The message service.</param> /// <param name="orchestraService">The orchestra service.</param> /// <param name="messageMediator">The message mediator.</param> public BrowserViewModel(string title, IMessageService messageService, IOrchestraService orchestraService, IMessageMediator messageMediator) : this(messageService, orchestraService, messageMediator) { if (!string.IsNullOrWhiteSpace(title)) { Title = title; } }
protected ViewModelBase(IMessageMediator messageMediator) { Argument.IsNotNull(() => messageMediator); MessageMediator = messageMediator; }
/// <summary> /// Initializes a new instance of the <see cref="T:Catel.Modules.ModuleBase`1" /> class. /// </summary> /// <param name="messageMediator">The message mediator.</param> public OxyPlotModule(IMessageMediator messageMediator) : base(Name) { messageMediator.Register(this, new Action <Tuple <ObservableCollection <int>, ObservableCollection <int> > >(OnPlot)); }
public void UnsubscribeViaMessageMediatorHelper(IMessageMediator messageMediator) { MessageMediatorHelper.UnsubscribeRecipient(this, messageMediator); }
public bool SendMessage(IMessageMediator messageMediator, string message) { return(SendMessage(messageMediator, message, null)); }
/// <summary> /// Initializes a new instance of the <see cref="ShellViewModel"/> class. /// </summary> public ShellViewModel(IMessageMediator messageMediator) : base(messageMediator) { }
/// <summary> /// Unsubscribes all methods of the specified instance that are decorated with the <see cref="MessageRecipientAttribute"/>. /// </summary> /// <param name="instance">The instance.</param> /// <param name="messageMediator">The message mediator. If <c>null</c>, the default will be used.</param> /// <exception cref="ArgumentNullException">The <paramref name="instance"/> is <c>null</c>.</exception> public static void UnsubscribeRecipient(object instance, IMessageMediator messageMediator = null) { Argument.IsNotNull("instance", instance); if (messageMediator == null) { var dependencyResolver = IoCConfiguration.DefaultDependencyResolver; messageMediator = dependencyResolver.Resolve<IMessageMediator>(); } messageMediator.UnregisterRecipient(instance); }
public MessageMediatorBViewModel(IMessageMediator messageMediator) { _messageMediator = messageMediator; }
public bool SendMessage(IMessageMediator messageMediator, string message) { return SendMessage(messageMediator, message, null); }
public ClassWithSeveralMatchesForDependencyInjection(IMessageMediator messageMediator, IMessageService messageService) { IsRightConstructorUsed = true; }
public bool SendMessage(IMessageMediator messageMediator, string message, object tag) { return messageMediator.SendMessage(message, tag); }
public bool SendMessage(IMessageMediator messageMediator, string message, object tag) { return(messageMediator.SendMessage(message, tag)); }
public CommandMediator(IMessageMediator messageMediator) { _messageMediator = messageMediator; }