TaxonomyFieldValue classe
Representa um único valor em um objeto TaxonomyField .
Inheritance hierarchy
System.Object
Microsoft.SharePoint.Taxonomy.TaxonomyFieldValue
Namespace: Microsoft.SharePoint.Taxonomy
Assembly: Microsoft.SharePoint.Taxonomy (em Microsoft.SharePoint.Taxonomy.dll)
Sintaxe
'Declaração
<DataContractAttribute> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Class TaxonomyFieldValue
'Uso
Dim instance As TaxonomyFieldValue
[DataContractAttribute]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public class TaxonomyFieldValue
Exemplos
using System;
using System.IO;
using System.Globalization;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Taxonomy;
namespace Microsoft.SDK.SharePointServer.Samples
{
// This code requires a reference to the Microsoft.SharePoint.dll and Microsoft.SharePoint.Taxonomy.dll
internal partial class TestTaxonomy
{
/// <summary>
/// This method creates a taxonomy field value for the given taxonomy field with a value of the given term
/// </summary>
/// <param name="term">Value to set</param>
/// <param name="taxonomyField">Field that value is for</param>
private void TestTaxonomyFieldValueBasic(Term term, TaxonomyField taxonomyField)
{
if (term == null)
{
throw new ArgumentException("Parameter term cannot be null");
}
if (taxonomyField == null)
{
throw new ArgumentException("Parameter taxonomyField cannot be null");
}
// If you have a term use the following:
TaxonomyFieldValue taxonomyValue = new TaxonomyFieldValue(taxonomyField);
taxonomyValue.TermGuid = term.Id.ToString();
taxonomyValue.Label = term.Name;
Console.WriteLine("TaxonomyFieldValue created with value " + taxonomyValue.ToString());
}
/// <summary>
/// This method shows how a TaxonomyFieldValue can be created from the results of a TaxonomyWebTaggingControl
/// </summary>
/// <param name="text">Text from taxonomy web tagging control which will provide a value</param>
/// <param name="taxonomyField">Field that value is for</param>
private void TestTaxonomyFieldValueBasicFromWebControl(string text, TaxonomyField taxonomyField)
{
if (taxonomyField == null)
{
throw new ArgumentException("Parameter taxonomyField cannot be null");
}
if (string.IsNullOrEmpty(text))
{
throw new ArgumentException("a value must be picked from the web tagging control");
}
TaxonomyFieldValue taxonomyValue = new TaxonomyFieldValue(taxonomyField);
taxonomyValue.PopulateFromLabelGuidPair(text);
Console.WriteLine("TaxonomyFieldValue created with value " + taxonomyValue.ToString());
}
/// <summary>
/// This method shows how to create TaxonomyFieldValue that is not bound to a field
/// </summary>
/// <param name="term">Value to set</param>
private void TestTaxonomyFieldValueNoField(Term term)
{
if (term == null)
{
throw new ArgumentException("Parameter term cannot be null");
}
// When this constructor is used calling ValidatedString will throw an exception
TaxonomyFieldValue taxonomyValue = new TaxonomyFieldValue("-1" + // We don't know the WssId so default to -1
";#" + // This is the lookup field delimiter
term.Name + // the label you want the TaxonomyFieldValue to have
TaxonomyField.TaxonomyGuidLabelDelimiter + // This is the delimiter between the Label and Guid
term.Id.ToString()); // This is the ID you want the TaxonomyFieldValue to have
Console.WriteLine("TaxonomyFieldValue created with value " + taxonomyValue.ToString());
}
}
}
Segurança de thread
Os membros públicos estática (Shared no Visual Basic) desse tipo são seguros para thread. Nenhum membro de instância pode ser garantido como seguro para thread.