共用方式為


SPContentTypeUsage.IsUrlToList property

表示Url屬性的值是否為統一資源定位器 (URL),到清單。

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'宣告
Public ReadOnly Property IsUrlToList As Boolean
    Get
'用途
Dim instance As SPContentTypeUsage
Dim value As Boolean

value = instance.IsUrlToList
public bool IsUrlToList { get; }

Property value

Type: System.Boolean
true如果Url屬性包含清單 ; 的根資料夾的伺服器相對 URL否則, false。

備註

這個屬性的值可以幫助您解釋Url屬性的值。網站內容類型, Url屬性會傳回 Web 站台的伺服器相對 URL。清單內容類型, Url屬性會傳回清單的根資料夾的伺服器相對 URL。

Examples

下列範例會示範取得內建內容類型Folder的使用方式集合的主控台應用程式。針對集合中每個項目,應用程式會判斷Url屬性的值清單或網站,並接著會列印該資訊,以及 [URL],在主控台。

Imports System
Imports System.Collections.Generic
Imports Microsoft.SharePoint

Module ConsoleApp
   Sub Main()
      Using siteCollection As SPSite = New SPSite("https://localhost")
         Using rootWeb As SPWeb = siteCollection.RootWeb

            ' Get the content type.
            Dim contentType As SPContentType = _
               rootWeb.AvailableContentTypes(SPBuiltInContentTypeId.Folder)

            ' Get the usage collection.
            Dim usages As IList(Of SPContentTypeUsage) = _
               SPContentTypeUsage.GetUsages(contentType)

            For Each usage As SPContentTypeUsage In usages
               Console.WriteLine(vbCrLf + "{0} content type", _
                                 IIf(usage.IsUrlToList, "List", "Site"))
               Console.WriteLine("URL: {0}", usage.Url)
            Next usage

         End Using
      End Using
      Console.Write(vbCrLf + "Press ENTER to continue...")
      Console.ReadLine()
   End Sub

End Module
using System;
using System.Collections.Generic;
using Microsoft.SharePoint;

namespace Test
{
   class ConsoleApp
   {
      static void Main(string[] args)
      {
         using (SPSite siteCollection = new SPSite("https://localhost"))
         {
            using (SPWeb rootWeb = siteCollection.RootWeb)
            {
               // Get the content type.
               SPContentType contentType =
                  rootWeb.AvailableContentTypes[SPBuiltInContentTypeId.Folder];

               //Get the usage collection.
               IList<SPContentTypeUsage> usages = SPContentTypeUsage.GetUsages(contentType);

               foreach (SPContentTypeUsage usage in usages)
               {
                  Console.WriteLine("\n{0} content type.", usage.IsUrlToList ? "List" : "Site");
                  Console.WriteLine("URL: {0}", usage.Url);
               }
            }
         }
         Console.Write("\nPress ENTER to continue...");
         Console.ReadLine();
      }
   }
}

當應用程式執行非常簡單的網站時,它會列印下列輸出到主控台。

Site content type.
URL: /

Site content type.
URL: /

List content type.
URL: /Lists/Links

List content type.
URL: /Lists/Tasks

List content type.
URL: /Lists/Announcements

List content type.
URL: /Lists/Reporting Metadata

List content type.
URL: /_catalogs/masterpage

List content type.
URL: /Shared Documents

List content type.
URL: /Reporting Templates

List content type.
URL: /Lists/Team Discussion

Press ENTER to continue...

請參閱

參照

SPContentTypeUsage class

SPContentTypeUsage members

Microsoft.SharePoint namespace

其他資源

Site and List Content Types