protected int GetColumnNumber(string column, TreeModel model)
        {
            Type modelType = model.GetType();
            SemanticModelAttribute attr = modelType.GetCustomAttribute <SemanticModelAttribute> ();

            if (attr == null)
            {
                // Check if the instance has the attributes
                AttributeCollection attrs = TypeDescriptor.GetAttributes(model);
                attr = (SemanticModelAttribute)attrs [typeof(SemanticModelAttribute)];
                if (attr == null)
                {
                    if (column.StartsWith("column__"))
                    {
                        int columnNum;
                        if (int.TryParse(column.Replace("column__", string.Empty), out columnNum))
                        {
                            return(columnNum);
                        }
                    }
                    else
                    {
                        return(-1);
                    }
                }
            }
            return(Array.IndexOf(attr.ColumnNames, column));
        }
		protected int GetColumnNumber (string column, TreeModel model)
		{
			Type modelType = model.GetType ();
			SemanticModelAttribute attr = modelType.GetCustomAttribute<SemanticModelAttribute> ();
			if (attr == null) {
				// Check if the instance has the attributes
				AttributeCollection attrs = TypeDescriptor.GetAttributes (model);
				attr = (SemanticModelAttribute)attrs [typeof(SemanticModelAttribute)];
				if (attr == null) {
					return -1;
				}
			}
			return Array.IndexOf (attr.ColumnNames, column);
		}
Exemple #3
0
        public override AppResult Model(string column)
        {
            TreeModel model = ModelFromWidget(resultWidget);

            if (model == null)
            {
                return(null);
            }

            if (column == null)
            {
                return(new GtkTreeModelResult(resultWidget, model, 0)
                {
                    SourceQuery = this.SourceQuery
                });
            }

            // Check if the class has the SemanticModelAttribute
            Type modelType = model.GetType();
            SemanticModelAttribute attr = modelType.GetCustomAttribute <SemanticModelAttribute> ();

            if (attr == null)
            {
                // Check if the instance has the attributes
                AttributeCollection attrs = TypeDescriptor.GetAttributes(model);
                attr = (SemanticModelAttribute)attrs [typeof(SemanticModelAttribute)];

                if (attr == null)
                {
                    return(null);
                }
            }

            int columnNumber = Array.IndexOf(attr.ColumnNames, column);

            if (columnNumber == -1)
            {
                return(null);
            }

            return(new GtkTreeModelResult(resultWidget, model, columnNumber)
            {
                SourceQuery = this.SourceQuery
            });
        }
Exemple #4
0
        public override AppResult Model(string column)
        {
            TreeView tv = resultWidget as TreeView;

            if (tv == null)
            {
                return(null);
            }

            TreeModel model = (TreeModel)AutoTestService.CurrentSession.UnsafeSync(() => tv.Model);

            if (model == null)
            {
                return(null);
            }

            // Check if the class has the SemanticModelAttribute
            Type modelType = model.GetType();
            SemanticModelAttribute attr = modelType.GetCustomAttribute <SemanticModelAttribute> ();

            if (attr == null)
            {
                // Check if the instance has the attributes
                AttributeCollection attrs = TypeDescriptor.GetAttributes(model);
                attr = (SemanticModelAttribute)attrs [typeof(SemanticModelAttribute)];

                if (attr == null)
                {
                    return(null);
                }
            }

            //AutoTestService.CurrentSession.SessionDebug.SendDebugMessage ("{0} has {1} column names: {2}", resultWidget, attr.ColumnNames.Length, string.Join (", ", attr.ColumnNames));
            int columnNumber = Array.IndexOf(attr.ColumnNames, column);

            if (columnNumber == -1)
            {
                return(null);
            }

            //AutoTestService.CurrentSession.SessionDebug.SendDebugMessage ("{0} has {1} at column {2}", resultWidget, column, columnNumber);
            return(new GtkTreeModelResult(tv, model, columnNumber));
        }
		protected int GetColumnNumber (string column, TreeModel model)
		{
			Type modelType = model.GetType ();
			SemanticModelAttribute attr = modelType.GetCustomAttribute<SemanticModelAttribute> ();
			if (attr == null) {
				// Check if the instance has the attributes
				AttributeCollection attrs = TypeDescriptor.GetAttributes (model);
				attr = (SemanticModelAttribute)attrs [typeof(SemanticModelAttribute)];
				if (attr == null) {
					return -1;
				}
			}
			return Array.IndexOf (attr.ColumnNames, column);
		}