public void TestOverriddenProperty()
        {
            OLVColumn column = new OLVColumn();

            column.AspectName = "CulinaryRating";
            Assert.AreEqual(200, column.GetValue(this.person2));

            TypedColumn <Person2> tcolumn = new TypedColumn <Person2>(column);

            Assert.IsNull(column.AspectGetter);
            tcolumn.GenerateAspectGetter();
            Assert.IsNotNull(column.AspectGetter);
            Assert.AreEqual(200, column.GetValue(this.person2));
        }
        public void ExecuteAspect(string aspectName, object expectedResult, Person person)
        {
            OLVColumn column = new OLVColumn();

            column.AspectName = aspectName;
            Assert.AreEqual(expectedResult, column.GetValue(person));

            TypedColumn <Person> tcolumn = new TypedColumn <Person>(column);

            Assert.IsNull(column.AspectGetter);
            tcolumn.GenerateAspectGetter();
            Assert.IsNotNull(column.AspectGetter);
            Assert.AreEqual(expectedResult, column.GetValue(person));
        }
        public void ExecuteAspect(string aspectName, object expectedResult, Person person)
        {
            OLVColumn column = new OLVColumn();

            column.AspectName = aspectName;
            Assert.AreEqual(expectedResult, column.GetValue(person));
        }
Exemple #4
0
        public void ExecuteAspect(string aspectName, object newValue, object dict)
        {
            OLVColumn column = new OLVColumn();

            column.AspectName = aspectName;
            column.PutValue(dict, newValue);
            Assert.AreEqual(newValue, column.GetValue(dict));
        }
        public void Execute <T>(string aspectName, object expectedResult, T person) where T : class
        {
            OLVColumn column = new OLVColumn();

            column.AspectName = aspectName;

            TypedColumn <T> tcolumn = new TypedColumn <T>(column);

            Assert.IsNull(column.AspectGetter);
            tcolumn.GenerateAspectGetter();
            Assert.IsNotNull(column.AspectGetter);
            Assert.AreEqual(expectedResult, column.GetValue(person));
        }
Exemple #6
0
        public int Compare(OLVListItem x, OLVListItem y)
        {
            if (sortOrder == SortOrder.None)
            {
                return(0);
            }

            int    result = 0;
            object x1     = column.GetValue(x.RowObject);
            object y1     = column.GetValue(y.RowObject);

            // Handle nulls. Null values come last
            bool xIsNull = (x1 == null || x1 == System.DBNull.Value);
            bool yIsNull = (y1 == null || y1 == System.DBNull.Value);

            if (xIsNull || yIsNull)
            {
                if (xIsNull && yIsNull)
                {
                    result = 0;
                }
                else
                {
                    result = (xIsNull ? -1 : 1);
                }
            }
            else
            {
                result = CompareValues(x1, y1);
            }

            if (sortOrder == SortOrder.Descending)
            {
                result = 0 - result;
            }

            return(result);
        }
        private OLVListSubItem MakeSubItem(object rowObject, OLVColumn column)
        {
            object cellValue = column.GetValue(rowObject);
            OLVListSubItem subItem = new OLVListSubItem(cellValue,
                                                        column.ValueToString(cellValue),
                                                        column.GetImage(rowObject));
            if (this.UseHyperlinks && column.Hyperlink) {
                IsHyperlinkEventArgs args = new IsHyperlinkEventArgs();
                args.ListView = this;
                args.Model = rowObject;
                args.Column = column;
                args.Text = subItem.Text;
                args.Url = subItem.Text;
                this.OnIsHyperlink(args);
                subItem.Url = args.Url;
            }

            return subItem;
        }
 /// <summary>
 /// Get the first non-null value of the given column.
 /// At most 1000 rows will be considered.
 /// </summary>
 /// <param name="column"></param>
 /// <returns>The first non-null value, or null if no non-null values were found</returns>
 internal object GetFirstNonNullValue(OLVColumn column)
 {
     for (int i = 0; i < Math.Min(this.GetItemCount(), 1000); i++) {
         object value = column.GetValue(this.GetModelObject(i));
         if (value != null)
             return value;
     }
     return null;
 }
Exemple #9
0
 /// <summary>
 /// Create an event args
 /// </summary>
 /// <param name="column"></param>
 /// <param name="control"></param>
 /// <param name="r"></param>
 /// <param name="item"></param>
 /// <param name="subItemIndex"></param>
 public CellEditEventArgs(OLVColumn column, Control control, Rectangle r, OLVListItem item, int subItemIndex) {
     this.Control = control;
     this.column = column;
     this.cellBounds = r;
     this.listViewItem = item;
     this.rowObject = item.RowObject;
     this.subItemIndex = subItemIndex;
     this.value = column.GetValue(item.RowObject);
 }
        public void TestWrongName()
        {
            OLVColumn column = new OLVColumn();

            column.AspectName = "Photo.Unknown";

            TypedColumn <Person> tcolumn = new TypedColumn <Person>(column);

            tcolumn.GenerateAspectGetter();
            Assert.AreEqual("'Unknown' is not a parameter-less method, property or field of type 'System.String'", column.GetValue(this.person1));
        }