本文整理匯總了C#中System.Guid.ValidateNotNullOrEmpty方法的典型用法代碼示例。如果您正苦於以下問題:C# Guid.ValidateNotNullOrEmpty方法的具體用法?C# Guid.ValidateNotNullOrEmpty怎麽用?C# Guid.ValidateNotNullOrEmpty使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Guid
的用法示例。
在下文中一共展示了Guid.ValidateNotNullOrEmpty方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: CreateTaxonomyField
/// <summary>
/// Can be used to create taxonomy field remotely in a list. Associated to group and term set in the GetDefaultSiteCollectionTermStore
/// </summary>
/// <param name="list">List to be processed</param>
/// <param name="id">Unique Id for the taxonomy field</param>
/// <param name="internalName">Internal Name of the field</param>
/// <param name="displayName">Display name</param>
/// <param name="group">Site column group</param>
/// <param name="mmsGroupName">Taxonomy group </param>
/// <param name="mmsTermSetName">Term set name</param>
/// <param name="multiValue">If true, create multi value field</param>
/// <returns>New taxonomy field</returns>
public static Field CreateTaxonomyField(this List list, Guid id, string internalName, string displayName, string group, string mmsGroupName, string mmsTermSetName, bool multiValue = false)
{
id.ValidateNotNullOrEmpty("id");
internalName.ValidateNotNullOrEmpty("internalName");
displayName.ValidateNotNullOrEmpty("displayName");
mmsGroupName.ValidateNotNullOrEmpty("mmsGroupName");
mmsTermSetName.ValidateNotNullOrEmpty("mmsTermSetName");
var clientContext = list.Context as ClientContext;
TermStore termStore = clientContext.Site.GetDefaultSiteCollectionTermStore();
if (termStore == null)
throw new NullReferenceException("The default term store is not available.");
// get the term group and term set
TermGroup termGroup = termStore.Groups.GetByName(mmsGroupName);
TermSet termSet = termGroup.TermSets.GetByName(mmsTermSetName);
list.Context.Load(termStore);
list.Context.Load(termSet);
list.Context.ExecuteQuery();
return list.CreateTaxonomyField(id, internalName, displayName, group, termSet, multiValue);
}