2013-04-04 42 views
1

我讀過約翰·韋斯特的文章站點配置廠(http://www.sitecore.net/unitedkingdom/Community/Technical-Blogs/John-West-Sitecore-Blog/Posts/2011/02/The-Sitecore-ASPNET-CMS-Configuration-Factory.aspxSitecore的配置工廠 - 有多個參數

我想在一個自定義鏈接提供商實現它調用方法。

我想配置工廠調用下面的方法中的鏈接提供者:

public void AddSitePath(String site, String path) 
{ 
    // do stuff 
} 

這裏的配置(雖然我試過幾個類似的變化)。

<add name="sitecore" type="MyProject.Providers.CustomLinkProvider, MyProject" addAspxExtension="false" alwaysIncludeServerUrl="false" encodeNames="true" languageEmbedding="never" languageLocation="filePath" shortenUrls="true" useDisplayName="false"> 
    <sitePaths hint="list:AddSitePath"> 
     <sitePath> 
      <site>SiteOneName</site> 
      <path>/product-range/</path>   
     </sitePath> 
     <sitePath > 
      <site>SiteTwoName</site> 
      <path>/items-for-sale/</path> 
     </sitePath>    
    </sitePaths> 
</add > 

我收到以下錯誤信息: 找不到添加方法:AddSitePath(類型:MyProject.Providers.CustomLinkProvider)

我懷疑問題是,我是試圖通過2參數加入到方法中,當然,當我使用單參數版本測試它時,它就可以工作。

我需要更改配置或類代碼以實現我需要的功能?

回答

1

所以看起來你不能提供2個參數。相反,您傳遞一個單獨的XmlNode對象,其中包含您需要的所有內容。您必須從方法中的XmlNode中提取信息。你必須使用的,而不是「名單」

「原始」的前綴

public void AddSitePath(XmlNode arg) 
{ 
    // pick apart the XmlNode and do stuff 
} 
<sitePaths hint="raw:AddSitePath"> 
    <sitePath site="SiteNameOne" path="/product-range/"> 
    <sitePath site="SiteNameTwo" path="/items-for-sale/">    
</sitePaths> 

注:沿行

東西