Exemplo n.º 1
0
        internal List <DataRowAttribute> GetRows(MethodInfo methodInfo, out DataDrivenTypeEnum dataDrivenType)
        {
            List <DataRowAttribute> rows = null;

            Attribute[] dataRowAttribute;

            dataDrivenType = DataDrivenTypeEnum.None;

            dataRowAttribute = methodInfo.GetCustomAttributes <DataRowAttribute>(false).ToArray() ?? null;
            if ((dataRowAttribute != null) && (dataRowAttribute.Length > 0))
            {
                dataDrivenType = DataDrivenTypeEnum.DataRow;
                rows           = new List <DataRowAttribute>();

                foreach (Attribute attrib in dataRowAttribute)
                {
                    rows.Add((DataRowAttribute)attrib);
                }
            }

            dataRowAttribute = methodInfo.GetCustomAttributes <DynamicDatasourceAttribute>(false).ToArray() ?? null;
            if ((dataRowAttribute != null) && (dataRowAttribute.Length > 0))
            {
                dataDrivenType = DataDrivenTypeEnum.DynamicDataSource;
                rows           = new List <DataRowAttribute>();

                foreach (object[] row in ((DynamicDatasourceAttribute)dataRowAttribute[0]).GetData(methodInfo))
                {
                    DataRowAttribute attrib = new DataRowAttribute(row);
                    attrib.DisplayName = ((DynamicDatasourceAttribute)dataRowAttribute[0]).GetDisplayName(methodInfo, row);
                    rows.Add(attrib);
                }
            }

            dataRowAttribute = methodInfo.GetCustomAttributes <DynamicDataAttribute>(false).ToArray() ?? null;
            if ((dataRowAttribute != null) && (dataRowAttribute.Length > 0))
            {
                dataDrivenType = DataDrivenTypeEnum.DynamicData;
                rows           = new List <DataRowAttribute>();

                foreach (object[] row in ((DynamicDataAttribute)dataRowAttribute[0]).GetData(methodInfo))
                {
                    DataRowAttribute attrib = new DataRowAttribute(row);
                    attrib.DisplayName = ((DynamicDataAttribute)dataRowAttribute[0]).GetDisplayName(methodInfo, row);
                    rows.Add(attrib);
                }
                ((DynamicDataAttribute)dataRowAttribute[0]).DynamicDataDisplayNameDeclaringType.GetMethod($"BuildDatasource").Invoke(null, new object[] { $"{methodInfo.DeclaringType.FullName}.{methodInfo.Name}" });
            }

            return(rows);
        }
        private List <DataRowAttribute> GetRows(MethodInfo methodInfo, out DataDrivenTypeEnum dataDrivenType)
        {
            List <DataRowAttribute> rows = null;

            Attribute[] dataRowAttribute;

            dataDrivenType = DataDrivenTypeEnum.None;

            dataRowAttribute = methodInfo.GetCustomAttributes <DataRowAttribute>(false).ToArray() ?? null;
            if ((dataRowAttribute != null) && (dataRowAttribute.Length > 0))
            {
                dataDrivenType = DataDrivenTypeEnum.DataRow;
                rows           = new List <DataRowAttribute>();

                foreach (Attribute attrib in dataRowAttribute)
                {
                    rows.Add((DataRowAttribute)attrib);
                }
            }

            dataRowAttribute = methodInfo.GetCustomAttributes <DynamicDatasourceAttribute>(false).ToArray() ?? null;
            if ((dataRowAttribute != null) && (dataRowAttribute.Length > 0))
            {
                dataDrivenType = DataDrivenTypeEnum.DynamicDataSource;
                rows           = new List <DataRowAttribute>();

                foreach (object[] row in ((DynamicDatasourceAttribute)dataRowAttribute[0]).GetData(methodInfo))
                {
                    DataRowAttribute attrib = new DataRowAttribute(row);
                    attrib.DisplayName = ((DynamicDatasourceAttribute)dataRowAttribute[0]).GetDisplayName(methodInfo, row);
                    rows.Add(attrib);
                }
            }

            dataRowAttribute = methodInfo.GetCustomAttributes <DynamicDataAttribute>(false).ToArray() ?? null;
            if ((dataRowAttribute != null) && (dataRowAttribute.Length > 0))
            {
                dataDrivenType = DataDrivenTypeEnum.DynamicData;
                rows           = new List <DataRowAttribute>();

                foreach (object[] row in ((DynamicDataAttribute)dataRowAttribute[0]).GetData(methodInfo))
                {
                    DataRowAttribute attrib = new DataRowAttribute(row);
                    attrib.DisplayName = ((DynamicDataAttribute)dataRowAttribute[0]).GetDisplayName(methodInfo, row);
                    rows.Add(attrib);
                }
            }

            return(rows);
        }