Example #1
0
        /// <summary>
        /// Determines whether the Sitecore Field holds multiple values.
        /// </summary>
        /// <param name="field">The field.</param>
        /// <returns>
        ///   <c>true</c> if the field holds multiple values; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsFieldPlural(SitecoreField field)
        {
            var multipleValueFields = new[]
            {
                "treelist",
                "treelistex",
                "treelist descriptive",
                "checklist",
                "multilist"
            };

            return(multipleValueFields.Contains(field.Type.ToLower()));
        }
Example #2
0
        /// <summary>
        /// Given a sitecore field, returns the name of the property to use.
        /// <para>If the field is plural, it returns a plural property name</para>
        /// </summary>
        /// <param name="field">The field.</param>
        /// <returns>A string to use for a property representing the field</returns>
        public static string GetPropertyName(SitecoreField field)
        {
            // has the field been configured in TDS with a custom name?
            string customName = GetCustomProperty(field.Data, "name");

            if (!string.IsNullOrEmpty(customName))
            {
                return(customName);
            }

            bool isFieldPlural = IsFieldPlural(field);

            return(field.Name.AsPropertyName(isFieldPlural));
        }
		/// <summary>
		/// Determines whether the Sitecore Field holds multiple values.
		/// </summary>
		/// <param name="field">The field.</param>
		/// <returns>
		///   <c>true</c> if the field holds multiple values; otherwise, <c>false</c>.
		/// </returns>
		public static bool IsFieldPlural(SitecoreField field)
		{
			var multipleValueFields = new[]
				{
					"treelist",
					"treelistex",
					"treelist descriptive",
					"checklist",
					"multilist"
				};

			return multipleValueFields.Contains(field.Type.ToLower());
		}
		/// <summary>
		/// Given a sitecore field, returns the name of the property to use.
		/// <para>If the field is plural, it returns a plural property name</para>
		/// </summary>
		/// <param name="field">The field.</param>
		/// <returns>A string to use for a property representing the field</returns>
		public static string GetPropertyName(SitecoreField field)
		{
			// has the field been configured in TDS with a custom name?
			string customName = GetCustomProperty(field.Data, "name");
			if (!string.IsNullOrEmpty(customName))
			{
				return customName;
			}

			bool isFieldPlural = IsFieldPlural(field);

			return field.Name.AsPropertyName(isFieldPlural);
		}