本文整理汇总了C#中IEnumerable.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.ToString方法的具体用法?C# IEnumerable.ToString怎么用?C# IEnumerable.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetSelectCommandText
public static string GetSelectCommandText(string SchemeName, string SourceName, IEnumerable<string> Columns)
{
string sourceName = SourceName;
string str = Columns.ToString(p => p, ",");
return !string.IsNullOrEmpty(str) ?
string.Format("SELECT {0} FROM {1}{2}", str, !string.IsNullOrEmpty(SchemeName) ? SchemeName + "." : null, sourceName) :
null;
}
示例2: Generate
/// <summary>
/// Generates the specified assemblies using.
/// </summary>
/// <param name="assembliesUsing">The assemblies using.</param>
/// <param name="aspects">The aspects.</param>
/// <returns></returns>
public string Generate(List<Assembly> assembliesUsing, IEnumerable<IAspect> aspects)
{
var Builder = new StringBuilder();
Builder.AppendLineFormat(@"
public {0}()
{1}
{{
{2}
}}",
DeclaringType.Name + "Derived",
DeclaringType.IsInterface ? "" : ":base()",
aspects.ToString(x => x.SetupDefaultConstructor(DeclaringType)));
return Builder.ToString();
}
示例3: ResolveTypes
private ICallable ResolveTypes(object conversionContext, object[] arguments,
IEnumerable<ICommand> nameCandidates)
{
// If there are more arguments than the longest command can handle, concatenate the rest of the string
// arguments into one.
// TODO: Efficient lookup
int maxParamCount = nameCandidates.Max(c => c.ParameterTypes.Length);
if(maxParamCount > 0 && arguments.Length > maxParamCount)
{
String joined = String.Join(" ", arguments.Skip(maxParamCount - 1));
Array.Resize(ref arguments, maxParamCount);
arguments[maxParamCount - 1] = joined;
}
// TODO: Efficient lookup
IEnumerable<ICommand> typeCandidates = nameCandidates
.Where(c => c.ParameterTypes.Length == arguments.Length);
// TODO: Taking the first one that succeeds, may need something smarter though?
foreach(ICommand command in typeCandidates)
{
object[] args = ConvertAll(conversionContext, arguments, command.ParameterTypes.ToArray());
if(args != null)
return new CommandCallable(command, args);
}
throw new InvalidOperationException("Incorrect arguments. Usage: " + nameCandidates.ToString("; "));
}
示例4: MakeIdList
/// <summary>
/// Make a string that corresponds to a list of guids.
/// </summary>
public static string MakeIdList(IEnumerable<Guid> objects)
{
return objects.ToString(",", guid => Convert.ToBase64String(guid.ToByteArray()));
}
示例5: ExecuteSql
/// <summary>
/// Executes a collection of sql commands that returns no result set
/// and takes no parameters, using the provided connection.
/// This method can be used effectively where the database vendor
/// supports the execution of several sql statements in one
/// ExecuteNonQuery. However, for database vendors like Microsoft
/// Access and MySql, the sql statements will need to be split up
/// and executed as separate transactions.
/// </summary>
/// <param name="statements">A valid sql statement object (typically "insert",
/// "update" or "delete"). Note_ that this assumes that the
/// sqlCommand is not a stored procedure.</param>
/// <param name="transaction">A valid transaction object in which the
/// sql must be executed, or null</param>
/// <returns>Returns the number of rows affected</returns>
/// <exception cref="DatabaseWriteException">Thrown if there is an
/// error writing to the database. Also outputs error messages to the log.
/// </exception>
/// <future>
/// In future override this method with methods that allow you to
/// pass in stored procedures and parameters.
/// </future>
public virtual int ExecuteSql(IEnumerable<ISqlStatement> statements, IDbTransaction transaction)
{
var inTransaction = false;
ArgumentValidationHelper.CheckArgumentNotNull(statements, "statements");
IDbConnection con = null;
try
{
IDbCommand cmd;
if (transaction != null)
{
inTransaction = true;
con = transaction.Connection;
if (con.State != ConnectionState.Open)
{
con.Open();
}
cmd = CreateCommand(con);
cmd.Transaction = transaction;
}
else
{
con = OpenConnection;
cmd = CreateCommand(con);
transaction = con.BeginTransaction();
cmd.Transaction = transaction;
}
var totalRowsAffected = 0;
foreach (SqlStatement statement in statements)
{
statement.SetupCommand(cmd);
try
{
totalRowsAffected += cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw new DatabaseWriteException
("There was an error executing the statement : " + Environment.NewLine + cmd.CommandText, ex);
}
statement.DoAfterExecute(this, transaction, cmd);
}
if (!inTransaction)
{
transaction.Commit();
}
return totalRowsAffected;
}
catch (Exception ex)
{
Log.Log
("Error writing to database : " + Environment.NewLine
+ ExceptionUtilities.GetExceptionString(ex, 10, true), LogCategory.Exception);
Log.Log("Sql: " + statements, LogCategory.Exception);
if (transaction != null)
{
transaction.Rollback();
}
throw new DatabaseWriteException
("There was an error writing to the database. Please contact your system administrator."
+ Environment.NewLine + "The command executeNonQuery could not be completed. :" + statements,
"The command executeNonQuery could not be completed.", ex, statements.ToString(), ErrorSafeConnectString());
}
finally
{
if (!inTransaction)
{
if (con != null && con.State != ConnectionState.Closed)
{
con.Close();
}
}
}
}
示例6: ExecuteAsSingleThread
private QueryResult ExecuteAsSingleThread(IEnumerable<String> myLines, IGraphQL myIGraphQL, SecurityToken mySecurityToken, TransactionToken myTransactionToken, VerbosityTypes myVerbosityType, IEnumerable<String> comments = null)
{
#region data
QueryResult queryResult = null;
Int64 numberOfLine = 0;
var aggregatedResults = new List<IEnumerable<IVertexView>>();
Stopwatch StopWatchLines = new Stopwatch();
#endregion
#region check lines and execute query
StopWatchLines.Reset();
StopWatchLines.Start();
foreach (var _Line in myLines)
{
numberOfLine++;
if (String.IsNullOrWhiteSpace(_Line))
{
continue;
}
#region Skip comments
if (IsComment(_Line, comments))
continue;
#endregion
#region execute query
var tempResult = myIGraphQL.Query(mySecurityToken, myTransactionToken, _Line);
#endregion
#region Add errors and break execution
if (tempResult.TypeOfResult == ResultType.Failed)
{
if (tempResult.Error.Message.Equals("Mal-formed string literal - cannot find termination symbol."))
Debug.WriteLine("Query at line [" + numberOfLine + "] [" + _Line + "] failed with " + tempResult.Error.ToString() + " add next line...");
if (myVerbosityType == VerbosityTypes.Errors)
{
queryResult = new QueryResult(_Line, ImportFormat, 0L, ResultType.Failed, tempResult.Vertices, tempResult.Error);
break;
}
}
aggregatedResults.Add(tempResult.Vertices);
#endregion
}
StopWatchLines.Stop();
#endregion
//add the results of each query into the queryResult
if(queryResult != null)
queryResult = new QueryResult(myLines.ToString(), ImportFormat, Convert.ToUInt64(StopWatchLines.ElapsedMilliseconds), queryResult.TypeOfResult, AggregateListOfListOfVertices(aggregatedResults), queryResult.Error);
else
queryResult = new QueryResult(myLines.ToString(), ImportFormat, Convert.ToUInt64(StopWatchLines.ElapsedMilliseconds), ResultType.Successful, AggregateListOfListOfVertices(aggregatedResults));
return queryResult;
}
示例7: GetBooleanAndPathCollection
private static void GetBooleanAndPathCollection(this IEdmModel model, IEdmEntitySet entitySet, IEdmValueTerm term, string booleanPropertyName, string pathsPropertyName, out bool? boolean, out IEnumerable<string> paths)
{
boolean = null;
paths = new string[0];
var annotation = model.FindVocabularyAnnotation(entitySet, term);
if (annotation == null)
{
return;
}
var recordExpression = (IEdmRecordExpression)annotation.Value;
var booleanExpression = (IEdmBooleanConstantExpression)recordExpression.Properties.Single(p => p.Name == booleanPropertyName).Value;
var collectionExpression = (IEdmCollectionExpression)recordExpression.Properties.Single(p => p.Name == pathsPropertyName).Value;
var pathsTemp = new List<string>();
foreach (IEdmPathExpression pathExpression in collectionExpression.Elements)
{
var pathBuilder = new StringBuilder();
foreach (var path in pathExpression.Path)
{
pathBuilder.AppendFormat("{0}.", path);
}
pathBuilder.Remove(pathBuilder.Length - 1, 1);
pathsTemp.Add(paths.ToString());
}
boolean = booleanExpression.Value;
paths = pathsTemp;
}
示例8: cargarDataGridViewConciliacionAutomatica
public void cargarDataGridViewConciliacionAutomatica(DataGridView dgv, IEnumerable<Object> lista, String p_modoEdicion, bool crea_encabezados)
{
try
{
Trace.TraceInformation(dgv.ToString());
Trace.TraceInformation(lista.ToString());
if (crea_encabezados)
{
//dgv.Rows.Clear();
dgv.Columns.Clear();
foreach (var item in lista)
{
Type t = item.GetType();
PropertyInfo[] pi = t.GetProperties();
foreach (PropertyInfo p in pi)
{
DataGridViewColumn columna = new DataGridViewColumn();
DataGridViewCell cell = new DataGridViewTextBoxCell();
columna.CellTemplate = cell;
columna.Name = p.Name;
columna.HeaderText = p.Name;
columna.ReadOnly = true;
columna.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
switch ( columna.Name )
{
case "NIVEL": columna.Visible = false; break;
case "IdArchivoTarjetaDetalle": columna.Visible = false; break;
}
dgv.Columns.Add(columna);
}
break;
}
DataGridViewCheckBoxColumn doWork = new DataGridViewCheckBoxColumn();
doWork.Name = "CONCILIAR";
doWork.HeaderText = "CONCILIAR";
doWork.FalseValue = "0";
doWork.TrueValue = "1";
dgv.Columns.Add(doWork);
} //crea_encabezados
var i=0;
foreach (object item in lista)
{
this.progressBar1.BringToFront();
dgv.Refresh();
//System.Threading.Thread.Sleep(10);
Application.DoEvents();
this.progressBar1.Increment(i++);
var row = dgv.Rows.Add();
dgv.Rows[row].HeaderCell.Value = i.ToString();
Type t = item.GetType();
PropertyInfo[] pi = t.GetProperties();
foreach (PropertyInfo p in pi)
{
Console.WriteLine(p.Name + " " + p.GetValue(item, null));
dgv.Rows[row].Cells[p.Name].Value = p.GetValue(item, null);
}
if (p_modoEdicion == "SI")
{
dgv.Rows[row].Cells["CONCILIAR"].Value = true;
}
switch (dgv.Rows[row].Cells["NIVEL"].Value.ToString())
{
case "-1": dgv.Rows[row].Cells["CONCILIAR"].Value = false;
dgv.Rows[row].ReadOnly = true;
dgv.Rows[row].DefaultCellStyle.BackColor = Color.White;
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.Black;
break;
case "1": dgv.Rows[row].DefaultCellStyle.BackColor = Color.DarkGreen;
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.White;
dgv.Rows[row].Cells["CONCILIAR"].Value = true;
break;
case "2": dgv.Rows[row].DefaultCellStyle.BackColor = Color.LightBlue; break;
case "3": dgv.Rows[row].DefaultCellStyle.BackColor = Color.Orange; break;
case "4": dgv.Rows[row].DefaultCellStyle.BackColor = Color.OrangeRed; break;
default:
dgv.Rows[row].Cells["CONCILIAR"].Value = false;
dgv.Rows[row].ReadOnly = true;
dgv.Rows[row].DefaultCellStyle.BackColor = Color.White;
dgv.Rows[row].DefaultCellStyle.ForeColor = Color.Black;
break;
}
dgv.Rows[row].Cells["FECHA_PAGO"].Value = dgv.Rows[row].Cells["FECHA_PAGO"].Value .ToString().Remove(10);
}
dgv.AutoResizeRowHeadersWidth(DataGridViewRowHeadersWidthSizeMode.AutoSizeToAllHeaders);
//.........这里部分代码省略.........
示例9: CreateMessage
public static String CreateMessage(IEnumerable<ICommand> candidates)
{
return "Incorrect arguments. Usage: " + candidates.ToString("; ");
}
示例10: ReferenceAllTypesInClosedGenericParametersWithReferences
public void ReferenceAllTypesInClosedGenericParametersWithReferences(
Tuple<IInnerInterface, InnerEventArgs, InnerDelegate> arg0,
List<InnerEnum> innerEnums,
InnerStruct[] innerStructs,
Lazy<InnerStruct.InnerStructInnerEnum> innerStructInnerEnum,
IEnumerable<InnerStruct.IInnerStructInnerInterface> innerStructInnerInterface,
Dictionary<InnerStruct.InnerStructInnerStruct, InnerStruct.InnerStructInnerClass> innerStructInnerClassByInnerStructInnerStruct,
Func<InnerAbstractClass, InnerAbstractClass.InnerAbstractClassInnerEnum, InnerAbstractClass.IInnerAbstractClassInnerInterface> getInnerAbstractClass,
List<Dictionary<InnerAbstractClass.InnerAbstractClassStruct, IEnumerable<InnerImplementingClass[]>>> stuff)
{
string toStringHolder;
toStringHolder = arg0.ToString();
toStringHolder = arg0.Item1.ToString();
toStringHolder = arg0.Item2.ToString();
toStringHolder = arg0.Item3.ToString();
toStringHolder = innerEnums.ToString();
toStringHolder = innerEnums.First().ToString();
toStringHolder = innerStructs.ToString();
toStringHolder = innerStructs[0].ToString();
toStringHolder = innerStructInnerEnum.ToString();
toStringHolder = innerStructInnerEnum.Value.ToString();
toStringHolder = innerStructInnerInterface.ToString();
toStringHolder = innerStructInnerInterface.ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.Keys.First().ToString();
toStringHolder = innerStructInnerClassByInnerStructInnerStruct.Values.First().ToString();
toStringHolder = getInnerAbstractClass.ToString();
toStringHolder = stuff.ToString();
toStringHolder = stuff[0].ToString();
toStringHolder = stuff[0].Keys.First().ToString();
toStringHolder = stuff[0].Values.First().ToString();
toStringHolder = stuff[0].Values.First().First().ToString();
}
示例11: ReadWebPartUsageCSV
private static void ReadWebPartUsageCSV(string sourceWebPartType, string usageFilePath, string outPutFolder, out IEnumerable<WebPartDiscoveryInput> objWPDInput)
{
string exceptionCommentsInfo1 = string.Empty;
Logger.LogInfoMessage("[ReadWebPartUsageCSV] [START] Calling function ImportCsv.ReadMatchingColumns<WebPartDiscoveryInput>");
objWPDInput = null;
objWPDInput = ImportCSV.ReadMatchingColumns<WebPartDiscoveryInput>(usageFilePath, Constants.CsvDelimeter);
Logger.LogInfoMessage("[ReadWebPartUsageCSV] [END] Read all the WebParts Usage Details from Discovery Usage File and saved in List - out IEnumerable<WebPartDiscoveryInput> objWPDInput, for processing.");
try
{
if (objWPDInput.Any())
{
Logger.LogInfoMessage("[START] ReadWebPartUsageCSV - After Loading InputCSV ");
objWPDInput = from p in objWPDInput
where p.WebPartType.ToLower() == sourceWebPartType.ToLower()
select p;
exceptionCommentsInfo1 = objWPDInput.ToString();
Logger.LogInfoMessage("[END] ReadWebPartUsageCSV - After Loading InputCSV");
}
}
catch (Exception ex)
{
System.Console.ForegroundColor = System.ConsoleColor.Red;
Logger.LogErrorMessage("[ReadWebPartUsageCSV] Exception Message: " + ex.Message + ", Exception Comments:" + exceptionCommentsInfo1);
System.Console.ResetColor();
ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, Constants.NotApplicable, "ReplaceWebPart", ex.Message, ex.ToString(), "ReadWebPartUsageCSV()", ex.GetType().ToString(), exceptionCommentsInfo1);
}
}
示例12: PopulateAnswerOrCommentLabel
/// ------------------------------------------------------------------------------------
/// <summary>
/// Populates the answer or comment label.
/// </summary>
/// <param name="details">The list of answers or comments.</param>
/// <param name="label">The label that has the "Answer:" or "Comment:" label.</param>
/// <param name="contents">The label that is to be populated with the actual answer(s)
/// or comment(s).</param>
/// <param name="sLabelMultiple">The text to use for <see cref="label"/> if there are
/// multiple answers/comments.</param>
/// ------------------------------------------------------------------------------------
private static void PopulateAnswerOrCommentLabel(IEnumerable<string> details,
Label label, Label contents, string sLabelMultiple)
{
label.Visible = contents.Visible = details != null;
if (label.Visible)
{
label.Show();
label.Text = (details.Count() == 1) ? (string)label.Tag : sLabelMultiple;
contents.Text = details.ToString(Environment.NewLine + "\t");
}
}
示例13: CreateAutoFieldProperties
AutoGeneratedFieldProperties[] CreateAutoFieldProperties(IEnumerable source, IEnumerator en)
{
Data = null;
JsonData = "";
if (this.SerializationMode == SerializationMode.Complex)
{
Data = source;
return null;
}
if (source == null) return null;
if (source is string && source.ToString().StartsWith("http"))
{
this.JsonData = "'{0}'".FormatWith(source);
this.IsUrl = true;
return null;
}
ITypedList typed = source as ITypedList;
PropertyDescriptorCollection props = typed == null ? null : typed.GetItemProperties(new PropertyDescriptor[0]);
Type prop_type;
ArrayList retVal = new ArrayList();
if (props == null)
{
object fitem = null;
prop_type = null;
PropertyInfo prop_item = source.GetType().GetProperty("Item",
BindingFlags.Instance | BindingFlags.Static |
BindingFlags.Public, null, null,
new Type[] { typeof(int) }, null);
if (prop_item != null)
{
prop_type = prop_item.PropertyType;
if (prop_type.IsInterface)
{
prop_type = null;
}
}
if (prop_type == null || prop_type == typeof(object))
{
if (en.MoveNext())
{
fitem = en.Current;
this.firstRecord = fitem;
}
if (fitem != null)
{
prop_type = fitem.GetType();
}
}
if (fitem != null && fitem is ICustomTypeDescriptor)
{
props = TypeDescriptor.GetProperties(fitem);
}
else if (prop_type != null)
{
if (IsBindableType(prop_type))
{
AutoGeneratedFieldProperties field = new AutoGeneratedFieldProperties();
((IStateManager)field).TrackViewState();
field.Name = "Item";
field.DataField = BoundField.ThisExpression;
field.Type = prop_type;
retVal.Add(field);
}
else
{
if (prop_type.IsArray)
{
Data = source;
return null;
}
else
{
props = TypeDescriptor.GetProperties(prop_type);
}
}
}
}
if (props != null && props.Count > 0)
{
foreach (PropertyDescriptor current in props)
{
if (this.IsBindableType(current.PropertyType) || this.IsComplexField(current.Name))
{
AutoGeneratedFieldProperties field = new AutoGeneratedFieldProperties();
field.Name = current.Name;
field.DataField = current.Name;
//.........这里部分代码省略.........
示例14: ChooseRendering
/// ------------------------------------------------------------------------------------
/// <summary>
/// Determines if this rule applies to the given question, and if so, will attempt to
/// select a rendering to use.
/// </summary>
/// ------------------------------------------------------------------------------------
public string ChooseRendering(string question, IEnumerable<Word> term, IEnumerable<string> renderings)
{
if (!Valid)
return null;
Regex regExQuestion = null;
try
{
regExQuestion = new Regex(string.Format(m_questionMatchingPattern, "(?i:" + term.ToString(@"\W+") + ")"), RegexOptions.CultureInvariant);
}
catch (ArgumentException ex)
{
ErrorMessageQ = ex.Message;
}
if (regExQuestion != null && regExQuestion.IsMatch(question))
{
Regex regExRendering;
try
{
regExRendering = new Regex(m_renderingMatchingPattern, RegexOptions.Compiled | RegexOptions.CultureInvariant);
}
catch (ArgumentException ex)
{
ErrorMessageR = ex.Message;
return null;
}
return renderings.FirstOrDefault(rendering => regExRendering.IsMatch(rendering.Normalize(NormalizationForm.FormC)));
}
return null;
}
示例15: GetPercentile
/// <summary>
/// Gets the item at a specific percentile formatted as a string for Flot.
/// </summary>
/// <param name="Results">The results.</param>
/// <param name="Percentile">The percentile.</param>
/// <returns>The string formatted for flot</returns>
private static string GetPercentile(IEnumerable<Core.Result> Results, decimal Percentile)
{
int Count = 0;
return Results.ToString(x => "[" + (++Count).ToString() + "," + x.Percentile(Percentile).Time.ToString() + "]", ",");
}