Esempio n. 1
0
 public void DisplayText_PascalCase_ReturnsEnumWithSpaces()
 {
     Assert.Equal(
         "Three Four",
         EnumUtils.DisplayText(TestEnum.ThreeFour)
         );
 }
Esempio n. 2
0
 public void DisplayText_DisplayAttribute_ReturnsName()
 {
     Assert.Equal(
         "2",
         EnumUtils.DisplayText(TestEnum.Two)
         );
 }
Esempio n. 3
0
 public void DisplayText_Default_ReturnsEnumToString()
 {
     Assert.Equal(
         TestEnum.One.ToString(),
         EnumUtils.DisplayText(TestEnum.One)
         );
 }
Esempio n. 4
0
        private void GetTfoot(StringBuilder s, bool showCheckboxColumn)
        {
            // first column checkbox, so we start at 1 instead of 0
            var i        = 1;
            var thFormat = "<th data-is-searchable='{0}'>";

            s.AppendLine("<th></th>");

            foreach (var c in Columns)
            {
                s.AppendFormat(thFormat,
                               c.IsSearchable ? c.IsSearchable.ToString().ToLower() : string.Empty
                               );

                if (c.Type == typeof(bool) || c.Type == typeof(bool?))
                {
                    // NOTE: MS hard-codes bool ToString(): 'True' and 'False'
                    s.AppendFormat(@"
<select class='form-control input-sm' data-column-number='{0}'>
    <option value='' selected='selected'></option> 
    <option value='true'>{1}</option>
    <option value='false'>{2}</option>
</select></th>",
                                   i,
                                   TableSettings.Settings.BoolTrue,
                                   TableSettings.Settings.BoolFalse
                                   );
                }
                else if (c.Type != null && c.Type.IsEnum)
                {
                    s.AppendFormat(@"
<select class='form-control input-sm' data-column-number='{0}'>
<option value='' selected='selected'></option>"
                                   , i);
                    foreach (var e in Enum.GetValues(c.Type))
                    {
                        s.AppendFormat("<option value='{0}'>{1}</option>\n",
                                       e, EnumUtils.DisplayText(e)
                                       );
                    }
                    s.Append("</select></th>");
                }
                else
                {
                    s.AppendFormat(@"
<input style='width:100% !important;display: block !important;' data-column-number='{0}'
class='form-control input-sm' type='text' placeholder='Search' /></th>"
                                   , i);
                }
                ++i;
            }

            s.AppendLine("<th style='white-space: nowrap;'>");
            s.Append("<span class='btn search-icons glyphicon glyphicon-search' title='Search'></span>");
            s.Append("<span class='btn search-icons glyphicon glyphicon-repeat' title='Clear Search and Reload'></span>");
            s.Append("<span id='datatable-save-as' class='btn btn-default glyphicon glyphicon-download-alt' title='Save As...'></span>\n");
            s.Append("</th>");
        }
Esempio n. 5
0
 public override void WriteJson(
     JsonWriter writer,
     object value,
     JsonSerializer serializer)
 {
     if (value == null)
     {
         writer.WriteNull();
     }
     else
     {
         writer.WriteValue(EnumUtils.DisplayText(value));
     }
 }