Пример #1
0
        protected string GetAutoLabelText(AutoLabelSettings settings)
        {
            var result = ((IElement)this).GetAttr(HtmlAttribute.Name);

            if (result == null)
            {
                return(result);
            }
            if (settings.UseFullNameForNestedProperties)
            {
                result = result.Replace('.', ' ');
            }
            else
            {
                var lastDot = result.LastIndexOf(".");
                if (lastDot >= 0)
                {
                    result = result.Substring(lastDot + 1);
                }
            }
            result = result.PascalCaseToPhrase();
            result = RemoveArrayNotationFromPhrase(result);
            result = settings.LabelFormat != null
                ? string.Format(settings.LabelFormat, result)
                : result;

            return(result);
        }
Пример #2
0
        protected AutoLabelSettings GetAutoLabelSettings()
        {
            //TODO: should we throw if there is more than one?
            AutoLabelSettings foundSettings = null;

            if (behaviors != null)
            {
                foundSettings = behaviors.Where(x => x is AutoLabelSettings).FirstOrDefault() as AutoLabelSettings;
            }
            return(foundSettings ?? new AutoLabelSettings(false, null, null));
        }