Beispiel #1
0
        private static TaxonomyValue GetTaxonomyValueForLabelInternal(TermStore termStore, Group termStoreGroup, TermSet termSet, string termLabel)
        {
            Term term = GetTermForLabelInternal(termStore, termStoreGroup, termSet, termLabel);

            TaxonomyValue value = null;

            if (term != null)
            {
                value = new TaxonomyValue(term);
            }

            return(value);
        }
Beispiel #2
0
        private static void GetTaxonomyFieldValue(T entity, PropertyInfo property, SPListItem item, string fieldName)
        {
            if (item[fieldName] is TaxonomyFieldValueCollection)
            {
                var value = item[fieldName] as TaxonomyFieldValueCollection;

// ReSharper disable HeuristicUnreachableCode
                if (value == null)
                {
                    return;
                }
// ReSharper restore HeuristicUnreachableCode

                var taxValues = new List <TaxonomyValue>();

                taxValues.AddRange(value.Select(t => new TaxonomyValue
                {
                    Label = t.Label,
                    Guid  = new Guid(t.TermGuid)
                }));
                property.SetValue(entity, taxValues, null);
            }
            else if (item[fieldName] is TaxonomyFieldValue)
            {
                var value = item[fieldName] as TaxonomyFieldValue;

// ReSharper disable ConditionIsAlwaysTrueOrFalse
                if (value == null)
                {
                    return;
                }
// ReSharper restore ConditionIsAlwaysTrueOrFalse

                var taxonomyValue = new TaxonomyValue
                {
                    Label = value.Label,
                    Guid  = new Guid(value.TermGuid)
                };

                property.SetValue(entity, taxonomyValue, null);
            }
        }