public TermSetCollectionInstance GetTermSets(ArrayInstance termLabels, object lcid) { var termLabelsList = new List <string>(); for (var i = 0; i < termLabels.Length; i++) { var label = termLabels[i] as string; if (label != null) { termLabelsList.Add(label); } } TermSetCollectionInstance result = null; if (lcid == null || lcid == Null.Value || lcid == Undefined.Value) { var termSets = m_taxonomySession.GetTermSets(termLabelsList.ToArray()); if (termSets != null) { result = new TermSetCollectionInstance(this.Engine.Object.InstancePrototype, termSets); } } else { var termSets = m_taxonomySession.GetTermSets(termLabelsList.ToArray(), TypeConverter.ToInteger(lcid)); if (termSets != null) { result = new TermSetCollectionInstance(this.Engine.Object.InstancePrototype, termSets); } } return(result); }
public static void SearchTermSetsByTermLabels(SPSite site, string[] termLabels) { TaxonomySession session = new TaxonomySession(site); // Returns all TermSet instances from all TermStores that contain terms // with matching labels for all specified strings. TermSetCollection termSets = session.GetTermSets(termLabels); Console.WriteLine("The number of matching Term Sets is " + termSets.Count); }
public static void SearchTermSetsByName(SPSite site, string termSetName) { TaxonomySession session = new TaxonomySession(site); // Search all TermSets that are using the provided name in current // UI LCID from all TermStores associated with the provided site. TermSetCollection termSets = session.GetTermSets(termSetName, CultureInfo.CurrentUICulture.LCID); Console.WriteLine("The number of matching Term Sets is " + termSets.Count); }