当前位置: 首页>>代码示例>>C#>>正文


C# InteractionRequest.Raise方法代码示例

本文整理汇总了C#中InteractionRequest.Raise方法的典型用法代码示例。如果您正苦于以下问题:C# InteractionRequest.Raise方法的具体用法?C# InteractionRequest.Raise怎么用?C# InteractionRequest.Raise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在InteractionRequest的用法示例。


在下文中一共展示了InteractionRequest.Raise方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CategoriesViewModel

        public CategoriesViewModel(Client client)
        {
            _client = client;

            Categories = new ObservableCollection<Category>(
                _client.Context.Categories.ToList());

            AddNewCategoryRequest = new InteractionRequest<IConfirmation>();
            AddCategoryCommand = new DelegateCommand(() =>
                AddNewCategoryRequest.Raise(
                    new Confirmation()
                    {
                        Title = "Nowa kategoria",
                        Content = new System.Windows.Controls.TextBox()
                        {
                            VerticalAlignment = System.Windows.VerticalAlignment.Top
                        }
                    },
                    AddCategory));
            ConfirmDeleteCategoryRequest = new InteractionRequest<IConfirmation>();
            DeleteCategoryCommand = new DelegateCommand(() =>
                ConfirmDeleteCategoryRequest.Raise(
                    new Confirmation()
                    {
                        Title = "Potwierdź",
                        Content = "Czy na pewno usunąć wybraną kategorię?"
                    },
                    DeleteCategory)
                , CanDeleteCategory);
        }
开发者ID:kwapisiewicz,项目名称:Edu,代码行数:30,代码来源:CategoriesViewModel.cs

示例2: WhenANotificationIsRequested_ThenTheEventIsRaisedWithTheSuppliedContext

        public void WhenANotificationIsRequested_ThenTheEventIsRaisedWithTheSuppliedContext()
        {
            var request = new InteractionRequest<Notification>();
            object suppliedContext = null;
            request.Raised += (o, e) => suppliedContext = e.Context;

            var context = new Notification();

            request.Raise(context, c => { });

            Assert.AreSame(context, suppliedContext);
        }
开发者ID:eslahi,项目名称:prism,代码行数:12,代码来源:InteractionRequestFixture.cs

示例3: MainViewModel

 public MainViewModel()
 {
     NotificationRequest = new InteractionRequest<INotification>();
     NotificationCommand = new DelegateCommand(() =>
     {
         NotificationRequest.Raise(new Notification
         {
             Title = "Notification",
             Content = "Notification message displayed"
         },
         (i) => Status = "Done");
     });
 }
开发者ID:wordtinker,项目名称:c-sharp,代码行数:13,代码来源:MainViewModel.cs

示例4: WhenTheEventCallbackIsExecuted_ThenTheNotifyCallbackIsInvokedWithTheSuppliedContext

        public void WhenTheEventCallbackIsExecuted_ThenTheNotifyCallbackIsInvokedWithTheSuppliedContext()
        {
            var request = new InteractionRequest<Notification>();
            Action eventCallback = null;
            request.Raised += (o, e) => eventCallback = e.Callback;

            var context = new Notification();
            object suppliedContext = null;

            request.Raise(context, c => { suppliedContext = c; });

            eventCallback();

            Assert.AreSame(context, suppliedContext);
        }
开发者ID:eslahi,项目名称:prism,代码行数:15,代码来源:InteractionRequestFixture.cs

示例5: MainWindowViewModel

		public MainWindowViewModel(PageManager pageManager, IEventAggregator ea, IFolderReactionMonitorModel monitor, IRegionManager regionManagar)
		{
			PageManager = pageManager;
			_Monitor = monitor;
			_RegionManager = regionManagar;

			MessageRequest = new InteractionRequest<Notification>();

			_CompositeDisposable = new CompositeDisposable();


			var e = ea.GetEvent<PubSubEvent<TaskbarIconBalloonMessageEventPayload>>();
			e.Subscribe(x =>
			{
				MessageRequest.Raise(new Notification()
				{
					Title = x.Title,
					Content = x.Message
				});
			});

			IsOpenSubContent = PageManager
				.ObserveProperty(x => x.IsOpenSubContent)
				.ToReactiveProperty(false);

			IsOpenSideMenu = PageManager
				.ToReactivePropertyAsSynchronized(x => x.IsOpenSideMenu);




			NotificationSource = new NotificationsSource();

			var toastEvent = ea.GetEvent<PubSubEvent<ToastNotificationEventPayload>>();
			toastEvent.Subscribe(x =>
			{
				NotificationSource.Show(x.Message, x.Type);
			});
		}
开发者ID:tor4kichi,项目名称:ReactiveFolder,代码行数:39,代码来源:MainWindowViewModel.cs

示例6: Delete

        public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
        {
            var countBuffer = new List<string>();

            // count: categories in Catalog
            int itemCount = repository.Categories.Where(x => x.CatalogId == InnerItem.CatalogId).Count();
            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("contains {0} category(ies)".Localize(), itemCount));
            }

            // count: items in Catalog
            itemCount = repository.Items.Where(x => x.CatalogId == InnerItem.CatalogId).Count();
            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("has {0} item(s)".Localize(), itemCount));
            }

            var content = string.Empty;
            var warnings = countBuffer.Select(x => "\n\t- " + x).ToArray();
            if (warnings.Length > 0)
            {
                content = string.Format("ATTENTION: This Catalog {0}.\n\n".Localize(), string.Join("", warnings));
            }
            content += string.Format("Are you sure you want to delete Catalog '{0}'?".Localize(), DisplayName);

            var item = LoadItem(InnerItem.CatalogId, repository);
            var itemVM = _catalogDeleteVmFactory.GetViewModelInstance(
                new KeyValuePair<string, object>("item", item),
                new KeyValuePair<string, object>("contentText", content));

            var confirmation = new ConditionalConfirmation(itemVM.Validate)
            {
                Content = itemVM,
                Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
            };
            commonConfirmRequest.Raise(confirmation, async (x) =>
            {
                if (x.Confirmed)
                {
                    await Task.Run(() =>
                    {
                        repository.Remove(item);

                        // report status
                        var id = Guid.NewGuid().ToString();
                        var statusUpdate = new StatusMessage { ShortText = string.Format("A Catalog '{0}' deletion in progress".Localize(), DisplayName), StatusMessageId = id };
                        EventSystem.Publish(statusUpdate);

                        try
                        {
                            repository.UnitOfWork.Commit();
                            statusUpdate = new StatusMessage { ShortText = string.Format("A Catalog '{0}' deleted successfully".Localize(), DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
                            EventSystem.Publish(statusUpdate);
                        }
                        catch (Exception e)
                        {
                            statusUpdate = new StatusMessage
                            {
                                ShortText = string.Format("Failed to delete Catalog '{0}'".Localize(), DisplayName),
                                Details = e.ToString(),
                                StatusMessageId = id,
                                State = StatusMessageState.Error
                            };
                            EventSystem.Publish(statusUpdate);
                        }
                    });

                    onSuccess();
                }
            });
        }
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:72,代码来源:TreeCatalogViewModel.cs

示例7: Delete

        public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
        {
            var countBuffer = new List<string>();
            int itemCount;

            // count: items in category. Don't try counting items for VirtualCatalog (nor linked category in it). 
            var isThisCategoryInRealCatalog = CatalogHomeViewModel.GetCatalog(this) is catalogModel.Catalog;
            if (isThisCategoryInRealCatalog)
            {
                // checking current category and level 1 (direct) subcategories.
                itemCount = repository.Items
                                      .Where(x =>
                                          x.CategoryItemRelations.Any(y =>
                                              y.CategoryId == InnerItem.CategoryId || y.Category.ParentCategoryId == InnerItem.CategoryId))
                                      .Count();

                if (itemCount > 0)
                {
                    countBuffer.Add(string.Format("has {0} item(s), won't be deleted".Localize(), itemCount));
                }
            }

            // count: direct sub-categories
            itemCount = repository.Categories
                .Where(x => x.ParentCategoryId == InnerItem.CategoryId)
                .Count();

            if (itemCount > 0)
            {
                countBuffer.Add(string.Format("has {0} sub-category(ies), will be deleted".Localize(), itemCount));
            }

            if (isThisCategoryInRealCatalog)
            {
                // count: linked categories			
                itemCount = repository.Categories
                    .OfType<LinkedCategory>()
                    .Where(x => x.LinkedCategoryId == InnerItem.CategoryId)
                    .Count();

                if (itemCount > 0)
                {
                    countBuffer.Add(string.Format("is coupled with {0} Linked Category(ies), will be deleted".Localize(), itemCount));
                }
            }

            // construct nice message
            var typeName = ((InnerItem is Category) ? "category" : "linked category").Localize();
            var content = string.Empty;
            var warnings = countBuffer.Select(x => "\n\t- " + x).ToArray();
            if (warnings.Length > 0)
            {
                content = string.Format("ATTENTION: This {0} {1}.\n\n".Localize(), typeName, string.Join("", warnings));
            }

            content += string.Format("Are you sure you want to delete {0} '{1}'?".Localize(), typeName, DisplayName);

            var confirmation = new ConditionalConfirmation
            {
                Content = content,
                Title = "Delete confirmation".Localize(null, LocalizationScope.DefaultCategory)
            };

            commonConfirmRequest.Raise(confirmation, async (x) =>
            {
                if (x.Confirmed)
                {
                    await Task.Run(() =>
                    {
                        // Removing item by attaching makes DataServiceRequest exception.
                        var categoryItem = repository.Categories.Where(c => c.CategoryId == InnerItem.CategoryId).FirstOrDefault();
                        //repository.Attach(InnerItem);
                        repository.Remove(categoryItem);

                        // report status
                        var id = Guid.NewGuid().ToString();
                        var item = new StatusMessage { ShortText = string.Format("A {0} '{1}' deletion in progress".Localize(), typeName, DisplayName), StatusMessageId = id };
                        EventSystem.Publish(item);

                        try
                        {
                            if (DeleteSeoKeywords())
                            {
                                repository.UnitOfWork.Commit();
                            }
                            item = new StatusMessage { ShortText = string.Format("A {0} '{1}' deleted successfully".Localize(), typeName, DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
                            EventSystem.Publish(item);
                        }
                        catch (Exception e)
                        {
                            item = new StatusMessage
                            {
                                ShortText = string.Format("Failed to delete {0} '{1}'".Localize(), typeName, DisplayName),
                                Details = e.ToString(),
                                StatusMessageId = id,
                                State = StatusMessageState.Error
                            };
                            EventSystem.Publish(item);
                        }
                    });
//.........这里部分代码省略.........
开发者ID:gitter-badger,项目名称:vc-community-1.x,代码行数:101,代码来源:TreeCategoryViewModel.cs

示例8: Delete

		public override void Delete(ICatalogRepository repository, InteractionRequest<Confirmation> commonConfirmRequest, InteractionRequest<Notification> errorNotifyRequest, Action onSuccess)
		{
			var content = string.Empty;

			// count: categories in VirtualCatalog
			var itemCount = repository.Categories
				.Where(x => x.CatalogId == InnerItem.CatalogId)
				.Count();

			if (itemCount > 0)
			{
				content = string.Format("ATTENTION: This Virtual Catalog contains {0} category(ies).\n\n", itemCount);
			}

			content += string.Format("Are you sure you want to delete Virtual Catalog '{0}'?", DisplayName);

			var item = repository.Catalogs.Where(x => x.CatalogId == InnerItem.CatalogId).Single();
			var itemVM = _catalogDeleteVmFactory.GetViewModelInstance(
				new KeyValuePair<string, object>("item", item),
				new KeyValuePair<string, object>("contentText", content));

			var confirmation = new ConditionalConfirmation(itemVM.Validate)
			{
				Content = itemVM,
				Title = "Delete confirmation"
			};
			commonConfirmRequest.Raise(confirmation, async (x) =>
			{
				if (x.Confirmed)
				{
					await Task.Run(() =>
						{
							repository.Remove(item);

							// report status
							var id = Guid.NewGuid().ToString();
							var statusUpdate = new StatusMessage { ShortText = string.Format("A Virtual Catalog '{0}' deletion in progress", DisplayName), StatusMessageId = id };
							EventSystem.Publish(statusUpdate);

							try
							{
								repository.UnitOfWork.Commit();
								statusUpdate = new StatusMessage { ShortText = string.Format("A Virtual Catalog '{0}' deleted successfully", DisplayName), StatusMessageId = id, State = StatusMessageState.Success };
								EventSystem.Publish(statusUpdate);
							}
							catch (Exception e)
							{
								statusUpdate = new StatusMessage
								{
									ShortText = string.Format("Failed to delete Virtual Catalog '{0}'", DisplayName),
									Details = e.ToString(),
									StatusMessageId = id,
									State = StatusMessageState.Error
								};
								EventSystem.Publish(statusUpdate);
							}
						});

					onSuccess();
				}
			});
		}
开发者ID:karpinskiy,项目名称:vc-community,代码行数:62,代码来源:TreeVirtualCatalogViewModel.cs


注:本文中的InteractionRequest.Raise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。