Sharepoint学习笔记—习题系列--70-573习题解析 -(Q70-Q72)

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

相关文章
相关标签/搜索