Пример #1
0
        /// <summary>
        /// This method will eventually defer to the ISitecoreRepository to render the field value.
        /// </summary>
        /// <param name="fieldName"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        public string GetField(string fieldName, IItem item, Dictionary <string, string> parameters)
        {
            if (item != null)
            {
                if (!String.IsNullOrEmpty(fieldName))
                {
                    // Get the ISitecoreRepository to check if the field actually exists.
                    if (_sitecoreRepository.FieldExists(fieldName, item))
                    {
                        // Helper to return field parameters for this particular field (the dictionary contains all fields + their parameters)
                        string fieldParameters = GetFieldParameters(fieldName, parameters);

                        if (!String.IsNullOrEmpty(fieldParameters))
                        {
                            // Get field value from Sitecore, having already checked for null/empty, and whether or not the field actually exists.
                            return(_sitecoreRepository.GetFieldValue(fieldName, item, fieldParameters));
                        }
                        else
                        {
                            return(_sitecoreRepository.GetFieldValue(fieldName, item));
                        }
                    }
                }
            }

            return(String.Empty);
        }