Understanding Actions and UriQuery

本文关键字:UriQuery and Actions Understanding | 更新日期: 2023-09-27 18:01:40

我在工作中被分配了一个任务,作为一个实习生,一切都是新的哈哈。我被要求做以下事情:

//To test this you will need to update the code CoreModuleDesktop.cs.
this.NavManager.RegisterCommonActionItem("History Audit Log", "AuditLog", 110,
                    new BitmapImage(new Uri("pack://application:,,,/Core;component/Resources/maintenance.png")),
                    new Action(() => _regionManager.RequestNavigate(RegionNames.MainRegion, typeof(Views.HistoryAuditLogView).FullName)));
//The part inside the action will need to be changed to look something like this 
//where you specify the parameters.  Then you can pull them out OnNavigateTo method
//like in the ServiceOrderMaintenanceViewModel.  For this step just pass in the 
//Table and Key ID, leave the connection string hard coded.
IRegionManager regionManager = AllianceApp.Container.GetExportedValue<IRegionManager>();
UriQuery query = new UriQuery();
query.Add("AccountID", accountID.ToString());
query.Add("ServiceOrderID", serviceOrderID.ToString());
regionManager.RequestNavigate(RegionNames.MainRegion, new Uri(typeof(ServiceOrderMaintenanceView).FullName + query.ToString(), UriKind.Relative));

动作内部的部分是什么意思?这个查询到底是怎么工作的。任何帮助将不胜感激!

Understanding Actions and UriQuery

"Inside the Action" is <here>:

new Action(() => <here> );

为了在Action中放置多行,您需要用花括号{}定义一个块:

new Action(() => 
    {
        // this is
        // a couple of lines
        // of code to modify
    });

希望这能帮助你开始。关于Action在c#中如何工作的一些背景,这里是msdn文档。