SiteMapProvider.ParentProvider 属性

定义

获取或设置当前提供程序的父 SiteMapProvider 对象。

public:
 virtual property System::Web::SiteMapProvider ^ ParentProvider { System::Web::SiteMapProvider ^ get(); void set(System::Web::SiteMapProvider ^ value); };
public virtual System.Web.SiteMapProvider ParentProvider { get; set; }
member this.ParentProvider : System.Web.SiteMapProvider with get, set
Public Overridable Property ParentProvider As SiteMapProvider

属性值

当前 SiteMapProvider 的父提供程序。

示例

下面的代码示例演示如何在实现 ParentProvider 抽象 SiteMapProvider 类的类中实现 属性。

此代码示例是为 SiteMapProvider 类提供的一个更大示例的一部分。

// Implement the ParentProvider property.
public override SiteMapProvider ParentProvider
{
  get
  {
    return parentSiteMapProvider;
  }
  set
  {
    parentSiteMapProvider = value;
  }
}

// Implement the RootProvider property.
public override SiteMapProvider RootProvider
{
  get
  {
    // If the current instance belongs to a provider hierarchy, it
    // cannot be the RootProvider. Rely on the ParentProvider.
    if (this.ParentProvider != null)
    {
      return ParentProvider.RootProvider;
    }
    // If the current instance does not have a ParentProvider, it is
    // not a child in a hierarchy, and can be the RootProvider.
    else
    {
      return this;
    }
  }
}
' Implement the ParentProvider property.
Public Overrides Property ParentProvider() As SiteMapProvider
  Get
    Return parentSiteMapProvider
  End Get
  Set(ByVal value As SiteMapProvider)
    parentSiteMapProvider = Value
  End Set
End Property

' Implement the RootProvider property.
Public Overrides ReadOnly Property RootProvider() As SiteMapProvider
  Get
    ' If the current instance belongs to a provider hierarchy, it
    ' cannot be the RootProvider. Rely on the ParentProvider.
    If Not (Me.ParentProvider Is Nothing) Then
      Return ParentProvider.RootProvider
      ' If the current instance does not have a ParentProvider, it is
      ' not a child in a hierarchy, and can be the RootProvider.
    Else
      Return Me
    End If
  End Get
End Property

注解

实现抽象 SiteMapProvider 类的所有类都可以支持站点地图提供程序层次结构的概念。 提供程序之间的任何分层关系都由提供程序本身维护在集合范围 SiteMapProviderCollection 之外。 有关功能提供程序层次结构的示例,请参阅 XmlSiteMapProvider

适用于

另请参阅