SPBuiltInFieldId.Contains-Methode
Gibt einen booleschen Wert, der angibt, ob die angegebene GUID die ID eines integrierten Felds entspricht oder nicht.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaration
Public Shared Function Contains ( _
fid As Guid _
) As Boolean
'Usage
Dim fid As Guid
Dim returnValue As Boolean
returnValue = SPBuiltInFieldId.Contains(fid)
public static bool Contains(
Guid fid
)
Parameter
fid
Typ: System.GuidEin Bezeichner dar.
Rückgabewert
Typ: System.Boolean
true Wenn die GUID der ID eines integrierten Felds entspricht; andernfalls false.
Beispiele
Das folgende Beispiel ist eine Konsolenanwendung, die die Contains -Methode zweimal aufruft: Erstens wird überprüft, ob ein beliebiges Element von der Website Columns-Auflistung eines integrierten Felds; ist zweite nachweisen, dass eine neu erstellte Feld nicht integrierten ist.
using System;
using Microsoft.SharePoint;
namespace Test
{
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.RootWeb)
{
// Test a field from the site columns collection.
SPField siteField = web.Fields[0];
FieldTest(siteField);
// Create a field and test it.
SPField newField = new SPField(web.Fields, SPFieldType.Boolean.ToString(), "New Field");
string internalName = web.Fields.Add(newField);
newField = web.Fields.GetFieldByInternalName(internalName);
FieldTest(newField);
}
}
Console.Write("\nPress ENTER to continue...");
Console.Read();
}
static void FieldTest(SPField field)
{
if (field == null)
throw new ArgumentNullException("field");
Guid fid = field.Id;
Console.WriteLine("The field {0} {1} a built-in field.",
field.InternalName, SPBuiltInFieldId.Contains(fid) ? "is" : "is not");
}
}
}
Imports System
Imports Microsoft.SharePoint
Namespace Test
Friend Class Program
Shared Sub Main(ByVal args() As String)
Using site As New SPSite("https://localhost")
Using web As SPWeb = site.RootWeb
' Test a field from the site columns collection.
Dim siteField As SPField = web.Fields(0)
FieldTest(siteField)
' Create a field and test it.
Dim newField As New SPField(web.Fields, SPFieldType.Boolean.ToString(), "New Field")
Dim internalName As String = web.Fields.Add(newField)
newField = web.Fields.GetFieldByInternalName(internalName)
FieldTest(newField)
End Using
End Using
Console.Write(vbLf & "Press ENTER to continue...")
Console.Read()
End Sub
Private Shared Sub FieldTest(ByVal field As SPField)
If field Is Nothing Then
Throw New ArgumentNullException("field")
End If
Dim fid As Guid = field.Id
Console.WriteLine("The field {0} {1} a built-in field.", field.InternalName,If(SPBuiltInFieldId.Contains(fid), "is", "is not"))
End Sub
End Class
End Namespace