internal object Provide(ProviderPreference pref) { string fs; int j = 1; bool dtNu = false; DataRow [] dtRows; DataRow dtRow; List <string> values; List <DataRow> allRows = new List <DataRow> (); SortedDictionary <string, string> fvals; DataTable dt = null; if (rows != null) { foreach (DataRow r in rows) { allRows.Add(r); } } if (list != null) { foreach (DataRow r in list.Rows) { allRows.Add(r); } } if (pref == ProviderPreference.FilterString) { fs = string.Empty; fvals = new SortedDictionary <string, string> (); if (filterValues != null) { foreach (KeyValuePair <string, string> kvp in filterValues) { fvals [kvp.Key] = kvp.Value; } } if ((cellValue != null) && (cellFieldName != null)) { fvals [cellFieldName] = cellValue.ToString(); } if ((paramInProps != null) && (paramInValues != null)) { for (int i = 0; i < Math.Min(paramInProps.Length, paramInValues.Length); i++) { fvals [paramInProps [i].ParameterName] = paramInValues [i]; } } if ((paramOutProps != null) && (paramOutValues != null)) { for (int i = 0; i < Math.Min(paramOutProps.Length, paramOutValues.Length); i++) { fvals [paramOutProps [i].ParameterName] = paramOutValues [i]; } } if (allRows.Count > 0) { foreach (DataColumn col in allRows[0].Table.Columns) { fvals [col.ColumnName] = allRows [0] [col] + string.Empty; } } foreach (KeyValuePair <string, string> kvp in fvals) { fs += string.Format("FilterField{0}={1}&FilterValue{0}={2}&", j++, kvp.Key.Replace("&", "%26").Replace("=", "%3D"), kvp.Value.Replace("&", "%26").Replace("=", "%3D")); } return(string.IsNullOrEmpty(fs) ? string.Empty : fs.Substring(0, fs.Length - 1)); } else if ((pref == ProviderPreference.Rows) || (pref == ProviderPreference.Table)) { dt = new DataTable(); foreach (KeyValuePair <string, string> kvp in fields) { if (!dt.Columns.Contains(kvp.Key)) { dt.Columns.Add(kvp.Key); } } if ((cellFieldName != null) && !dt.Columns.Contains(cellFieldName)) { dt.Columns.Add(cellFieldName); } foreach (DataRow row in allRows) { dt.Rows.Add(row); } { dtRow = dt.NewRow(); if ((cellValue != null) && (cellFieldName != null)) { dtRow [cellFieldName] = cellValue; } if (filterValues != null) { foreach (KeyValuePair <string, string> kvp in filterValues) { dtRow [kvp.Key] = kvp.Value; } } if ((paramInProps != null) && (paramInValues != null)) { for (int i = 0; i < Math.Min(paramInProps.Length, paramInValues.Length); i++) { dtRow [paramInProps [i].ParameterName] = paramInValues [i]; } } if ((paramOutProps != null) && (paramOutValues != null)) { for (int i = 0; i < Math.Min(paramOutProps.Length, paramOutValues.Length); i++) { dtRow [paramOutProps [i].ParameterName] = paramOutValues [i]; } } dt.Rows.Add(dtRow); } if (pref == ProviderPreference.Rows) { dtRows = new DataRow [dt.Rows.Count]; dt.Rows.CopyTo(dtRows, 0); return(dtRows); } return(dt); } else if (pref == ProviderPreference.SingleValue) { if (cellValue != null) { return(cellValue); } if (paramInValues != null) { foreach (string v in paramInValues) { return(v); } } if (paramOutValues != null) { foreach (string v in paramOutValues) { return(v); } } if (filterValues.Count > 0) { foreach (string v in filterValues.Values) { return(v); } } foreach (DataRow row in allRows) { foreach (DataColumn col in row.Table.Columns) { return(row [col]); } } } else if (pref == ProviderPreference.Values) { values = new List <string> (); if (paramInValues != null) { values.AddRange(paramInValues); } if (paramOutValues != null) { values.AddRange(paramOutValues); } if (cellValue != null) { values.Add(cellValue.ToString()); } if (filterValues.Count > 0) { values.AddRange(filterValues.Values); } if (allRows.Count > 0) { foreach (DataColumn col in allRows[0].Table.Columns) { values.Add(allRows [0] [col] + string.Empty); } } return(values.ToArray()); } return(null); }
internal object Provide(ProviderPreference pref) { int num = 1; List <DataRow> list2 = new List <DataRow>(); DataTable table = null; if (this.rows != null) { foreach (DataRow row2 in this.rows) { list2.Add(row2); } } if (this.list != null) { foreach (DataRow row3 in this.list.Rows) { list2.Add(row3); } } if (pref == ProviderPreference.FilterString) { string str = string.Empty; SortedDictionary <string, string> dictionary = new SortedDictionary <string, string>(); if (this.filterValues != null) { foreach (KeyValuePair <string, string> pair in this.filterValues) { dictionary[pair.Key] = pair.Value; } } if ((this.cellValue != null) && (this.cellFieldName != null)) { dictionary[this.cellFieldName] = this.cellValue.ToString(); } if ((this.paramInProps != null) && (this.paramInValues != null)) { for (int i = 0; i < Math.Min(this.paramInProps.Length, this.paramInValues.Length); i++) { dictionary[this.paramInProps[i].ParameterName] = this.paramInValues[i]; } } if ((this.paramOutProps != null) && (this.paramOutValues != null)) { for (int j = 0; j < Math.Min(this.paramOutProps.Length, this.paramOutValues.Length); j++) { dictionary[this.paramOutProps[j].ParameterName] = this.paramOutValues[j]; } } if (list2.Count > 0) { foreach (DataColumn column in list2[0].Table.Columns) { dictionary[column.ColumnName] = list2[0][column] + string.Empty; } } foreach (KeyValuePair <string, string> pair2 in dictionary) { string introduced48 = pair2.Key.Replace("&", "%26").Replace("=", "%3D"); str = str + string.Format("FilterField{0}={1}&FilterValue{0}={2}&", num++, introduced48, pair2.Value.Replace("&", "%26").Replace("=", "%3D")); } if (!string.IsNullOrEmpty(str)) { return(str.Substring(0, str.Length - 1)); } return(string.Empty); } if ((pref == ProviderPreference.Rows) || (pref == ProviderPreference.Table)) { table = new DataTable(); foreach (KeyValuePair <string, string> pair3 in this.fields) { if (!table.Columns.Contains(pair3.Key)) { table.Columns.Add(pair3.Key); } } if ((this.cellFieldName != null) && !table.Columns.Contains(this.cellFieldName)) { table.Columns.Add(this.cellFieldName); } foreach (DataRow row4 in list2) { table.Rows.Add(row4); } DataRow row = table.NewRow(); if ((this.cellValue != null) && (this.cellFieldName != null)) { row[this.cellFieldName] = this.cellValue; } if (this.filterValues != null) { foreach (KeyValuePair <string, string> pair4 in this.filterValues) { row[pair4.Key] = pair4.Value; } } if ((this.paramInProps != null) && (this.paramInValues != null)) { for (int k = 0; k < Math.Min(this.paramInProps.Length, this.paramInValues.Length); k++) { row[this.paramInProps[k].ParameterName] = this.paramInValues[k]; } } if ((this.paramOutProps != null) && (this.paramOutValues != null)) { for (int m = 0; m < Math.Min(this.paramOutProps.Length, this.paramOutValues.Length); m++) { row[this.paramOutProps[m].ParameterName] = this.paramOutValues[m]; } } table.Rows.Add(row); if (pref == ProviderPreference.Rows) { DataRow[] array = new DataRow[table.Rows.Count]; table.Rows.CopyTo(array, 0); return(array); } return(table); } if (pref == ProviderPreference.SingleValue) { if (this.cellValue != null) { return(this.cellValue); } if (this.paramInValues != null) { string[] paramInValues = this.paramInValues; int index = 0; while (index < paramInValues.Length) { return(paramInValues[index]); } } if (this.paramOutValues != null) { string[] paramOutValues = this.paramOutValues; int num8 = 0; while (num8 < paramOutValues.Length) { return(paramOutValues[num8]); } } if (this.filterValues.Count > 0) { using (SortedDictionary <string, string> .ValueCollection.Enumerator enumerator8 = this.filterValues.Values.GetEnumerator()) { while (enumerator8.MoveNext()) { return(enumerator8.Current); } } } foreach (DataRow row5 in list2) { foreach (DataColumn column2 in row5.Table.Columns) { return(row5[column2]); } } } else if (pref == ProviderPreference.Values) { List <string> list = new List <string>(); if (this.paramInValues != null) { list.AddRange(this.paramInValues); } if (this.paramOutValues != null) { list.AddRange(this.paramOutValues); } if (this.cellValue != null) { list.Add(this.cellValue.ToString()); } if (this.filterValues.Count > 0) { list.AddRange(this.filterValues.Values); } if (list2.Count > 0) { foreach (DataColumn column3 in list2[0].Table.Columns) { list.Add(list2[0][column3] + string.Empty); } } return(list.ToArray()); } return(null); }