Question 70
You plan to create one provider Web Part and two consumer Web Parts.
You need to ensure that the consumer Web Parts can receive data from the provider Web Part.
You create an interface that contains the following code segment.
public interface Interface1
{
string Parameter1 { get; set; }
}
What should you do next?
A. Implement Interface1 in the provider Web Part.
B. Implement IWebPartField in the provider Web Part.
C. Create a set accessor for Parameter1.
D. Create a second interface and use it to communicate with the provider Web Part.web
解析:
本題實際上是上題的翻版,仍是考你在哪一個WebPart實現題幹部分定義的Interface。
選項B. IwebPartField: 屬於微軟針對 Web 部件基礎結構提供的一組標準鏈接接口中的一種(還有: IWebPartRow ,IWebPartTable等 ),此類標準鏈接接口,主要是爲了使可鏈接WebPart的開發更具工業化特點(如同制定了汽車輪胎的標準接口,那麼無論哪家工廠生產的輪胎,只要符合此標準,就能夠通用到符合此標準的汽車上),所以可鏈接的 Web 部件能夠徹底能夠由不一樣的開發人員或公司進行開發以便彼此進行通訊。因此,選項B的IwebPartField接口就是用來實現WebPart鏈接的,並且的確也應該是在Provider Web Part中實現的。但對本題爲何是錯的呢?由於本題已經在題幹部分」個性化」定製了一個接口Interface1,而並無採用「標準化接口」方案,因此在Provider端實現的就應該是個性化定製的接口Interface1。
選項C說的是給Parameter1建立一個設置手段,
eg:
public System.String Parameter1
{
get { return _ PARAMETER1; }
set { _ PARAMETER1= value; } //建立一個Set Accessor
}
說的是參數屬性的建立,顯然與本題的WebPart部件鏈接無關。
選項D是建議你另建立一個Interface,有點畫蛇添足的作法。
因此本題目正確選項應該是Aide
參考:
http://msdn.microsoft.com/zh-cn/library/system.web.ui.webcontrols.webparts.iwebpartfield.aspx
http://msdn.microsoft.com/en-us/library/ms469765.aspx
網站
Question 71
You create a Web Part named WP1.
You need to ensure that the name of the Web Part displays as Corporate in SharePoint.
What should you do?
A. Rename WP1.webpart as Corporate.webpart.
B. In WP1.webpart, change the Title property to Corporate.
C. In the constructor of WP1.cs, add the following line of code:
Page.Title="Corporate";
D. In the Elements.xml file, change the Name property of the <File> element to Corporate.ui
解析:
本題意圖經過代碼設置Webpart的Title屬性。此屬性的設置值將會顯示在Webpart的Title Bar位置。
選項A. Rename WP1.webpart as Corporate.webpart. 只是修改了Wepart文件的文件名。咱們知道咱們能夠經過創建VS2010的Web 部件項目來建立 SharePoint 網站的 web 部件。 當您建立一個 Web 部件 項目時,Visual Studio 在項目中建立一個文件夾中並將添加幾個文件到文件夾。 下面就是這幾個文件:
1. Elements.xml:包含在項目中的功能定義文件使用部署 web 部件的信息。
2. .webpart 文件:提供 SharePoint 須要顯示了您在 web 部件庫中的 web 部件的信息。
3. 代碼文件:包含將控件添加到 web 部件,並生成在 web 部件中的自定義內容的方法。
本選項就是設置的.webpart文件的文件名,它並不能影響Webpart在顯示界面上的Title值。
選項B. 是本題的答案,經過設置Webpart控件的Title屬性固然就是修改了Webpart的Title顯示值。
選項C. In the constructor of WP1.cs, add the following line of code:
Page.Title="Corporate"; 本選項的操做修改的是Webpart所在頁面的Title屬性,而不是Webpart控件的Title屬性。
選項D. In the Elements.xml file, change the Name property of the <File> element to Corporate. 參考選項A,Elements.xml文件是用於定義文件使用部署 web 部件的信息,也即它主要是控制WebPart的部署。並且關於Element.xml文件中的<File>元素,我尚未看到修改它的所謂Name屬性的情形,一般都是修改它的Path,Url與Type屬性,若是查看資料,你會發現,在此處它是沒有什麼Name屬性的。spa
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="WP_Resources" Path="WP_Resources">
<File Path="links.xml" Url="links.xml" Type="GhostableInLibrary" />
</Module>
</Elements>
因此本題目正確選項應該是Bcode
參考:
http://msdn.microsoft.com/en-us/library/ms227561.aspx
http://msdn.microsoft.com/zh-cn/library/microsoft.sharepoint.webpartpages.webpart.title(v=office.12).aspx
http://msdn.microsoft.com/en-us/library/ee231567.aspxorm
Question 72
You create a Web Part that contains the following logging code. (Line numbers are included for reference only.)
01 SPWeb web = SPContext.Current.Web;
02 try
03 {
04
05 }
06 catch (Exception ex)
07 {
08
09 System.Diagnostics.EventLog.WriteEntry("WebPart Name", ("Exception Information: " + ex.Message), EventLogEntryType.Error);
10 }
You discover that line 09 causes an error. You need to resolve the error.
What should you do?
A. Run the code segment at line 09 inside a RunWithElevatedPrivileges delegate.
B. Add the following code at line 08:
if (web.CurrentUser.IsSiteAuditor == false)
C. Add the following code at line 08:
if (web.CurrentUser.IsSiteAdmin == false)
D. Change line 09 to the following code segment:
System.Diagnostics.EventLog.WriteEntry("WebPart Name", "Exception Information", EventLogEntryType.Error);xml
解析:
本題的情景就是在你的代碼中捕捉到異常,而後想把異常信息寫入到EventLog中,結果出錯。因此很明顯,這是關於寫入操做的權限問題,若是作了前面的Question59,你就能很快地肯定選項A爲本題的答案,即:經過RunWithElevatedPrivileges以」管理員帳戶身份」來完成寫入操做。
選項B. 是用來判斷當前登陸的用戶是不是當前Site Collection的 auditor(審計者)。
選項C. 是用來判斷當前登陸的用戶是不是當前Site Collection的 administrator(管理員)。這也解決不了問題,由於EventLog並非歸屬於哪一個Site Collection的,它必需要更高層次的管理員賬戶纔能有權寫入操做。
選項D. 只是改變了寫入內容,而並沒提高寫入的權限。
因此本題目正確選項應該是A接口
參考:
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsecurity.runwithelevatedprivileges.aspx
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spuser.issiteauditor.aspx
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spuser.issiteadmin.aspxelement