コード例 #1
0
ファイル: ListColumn.cs プロジェクト: chandusekhar/Core
        public static ListColumn Create(String name, ListColumnAttribute attr)
        {
            var field = new ListColumn();

            if (!String.IsNullOrEmpty(attr.HeaderResource))
            {
                if (attr.ResourceType == null)
                {
                    throw new NullReferenceException("Missing Resource Type on Property " + name);
                }
                var headerProperty = attr.ResourceType.GetTypeInfo().GetDeclaredProperty(attr.HeaderResource);
                field.Header = (string)headerProperty.GetValue(headerProperty.DeclaringType, null);
            }
            else
            {
                field.Header = name;
            }

            if (!String.IsNullOrEmpty(attr.HelpResource))
            {
                if (attr.ResourceType == null)
                {
                    throw new NullReferenceException("Missing Resource Type on Property " + name);
                }

                var helpProperty = attr.ResourceType.GetTypeInfo().GetDeclaredProperty(attr.HelpResource);
                field.Help = (string)helpProperty.GetValue(helpProperty.DeclaringType, null);
            }

            field.FieldName    = name;
            field.Alignment    = attr.Alignment.ToString();
            field.Sortable     = attr.Sortable;
            field.Visible      = attr.Visible;
            field.FormatString = attr.FormatString;
            return(field);
        }
コード例 #2
0
        public void Values_Set_In_Constructor_Should_Be_Set_Correctly()
        {
            var enableSorting   = true;
            var caption         = "Caption";
            var displayOrder    = 3;
            var sortFieldName   = "SortField";
            var hideCaption     = true;
            var hideEmptyColumn = true;
            var attribute       = new ListColumnAttribute(
                enableSorting: enableSorting,
                headerText: caption,
                displayOrder: displayOrder,
                sortColumnName: sortFieldName
                )
            {
                HideCaption     = hideCaption,
                HideEmptyColumn = hideEmptyColumn,
            };

            var result = attribute.EnableSorting == enableSorting &&
                         attribute.HeaderText == caption &&
                         attribute.DisplayOrder == displayOrder &&
                         attribute.SortColumnName == sortFieldName &&
                         attribute.HideCaption == hideCaption &&
                         attribute.HideEmptyColumn == hideEmptyColumn;

            Assert.True(result);

            enableSorting   = false;
            caption         = "";
            displayOrder    = 0;
            sortFieldName   = "";
            hideCaption     = false;
            hideEmptyColumn = false;
            attribute       = new ListColumnAttribute(
                enableSorting: enableSorting,
                headerText: caption,
                displayOrder: displayOrder,
                sortColumnName: sortFieldName
                )
            {
                HideCaption     = hideCaption,
                HideEmptyColumn = hideEmptyColumn,
            };

            result = attribute.EnableSorting == enableSorting &&
                     attribute.HeaderText == caption &&
                     attribute.DisplayOrder == displayOrder &&
                     attribute.SortColumnName == sortFieldName &&
                     attribute.HideCaption == hideCaption &&
                     attribute.HideEmptyColumn == hideEmptyColumn;

            Assert.True(result);

            attribute = new ListColumnAttribute(
                enableSorting: enableSorting,
                headerText: caption,
                displayOrder: displayOrder,
                sortColumnName: sortFieldName
                );

            result = attribute.EnableSorting == enableSorting &&
                     attribute.HeaderText == caption &&
                     attribute.DisplayOrder == displayOrder &&
                     attribute.SortColumnName == sortFieldName &&
                     attribute.HideCaption == false &&
                     attribute.HideEmptyColumn == false;

            Assert.True(result);
        }