本文整理汇总了C#中IEnumerable.Join方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.Join方法的具体用法?C# IEnumerable.Join怎么用?C# IEnumerable.Join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.Join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Format
public string Format(MethodInfo methodInfo, IEnumerable<string> arguments)
{
if (methodInfo.DeclaringType == typeof (DelegateCall))
{
return string.Format("Invoke({0})", arguments.Join(", "));
}
return string.Format("{0}{1}({2})", methodInfo.Name, FormatGenericType(methodInfo), arguments.Join(", "));
}
示例2: ForeignKeyException
public ForeignKeyException(int referredid, IEnumerable<int> referrerids, string tablename)
: base(String.Format("The entity with Id={0} is referred to by {1} entities with Id={2} and cannot be deleted.", referredid, tablename, referrerids.Join(", ")))
{
ReferredId = referredid;
ReferrerIds = referrerids.ToList();
ReferrersType = tablename;
}
示例3: Run
/// <summary>Runs a list of CMD commands.</summary>
/// <param name="commands">List of commands to execute by CMD window.</param>
/// <returns>The associated process.</returns>
public static Task<Process> Run(IEnumerable<string> commands)
{
var procStartInfo = new ProcessStartInfo
{
RedirectStandardError = false,
RedirectStandardOutput = true,
UseShellExecute = false,
FileName = "cmd",
WindowStyle = ProcessWindowStyle.Hidden,
CreateNoWindow = true,
Arguments = "/c " + commands.Join("&"),
};
var process = new Process();
process.EnableRaisingEvents = true;
process.StartInfo = procStartInfo;
var tcs = new TaskCompletionSource<Process>();
process.Exited += (sender, args) => tcs.SetResult(process);
try
{
process.Start();
}
catch (Exception e)
{
tcs.SetException(e);
}
return tcs.Task;
}
示例4: RunElevated
public static Task<Process> RunElevated(IEnumerable<string> commands)
{
var procStartInfo = new ProcessStartInfo()
{
RedirectStandardError = false,
RedirectStandardOutput = false,
FileName = "cmd",
Verb = "runas",
Arguments = "/C " + commands.Join("&"),
};
var process = new Process();
process.EnableRaisingEvents = true;
process.StartInfo = procStartInfo;
var tcs = new TaskCompletionSource<Process>();
process.Exited += (sender, args) => tcs.SetResult(process);
try
{
process.Start();
}
catch (Exception e)
{
tcs.SetException(e);
}
return tcs.Task;
}
示例5: DiffRows
IEnumerable<Result> DiffRows(IEnumerable<Row> rows1, IEnumerable<Row> rows2)
{
var rows = rows1.Join(rows2, r => r.Name, r => r.Name, (r1, r2) => new Tuple<Row, Row>(r1, r2));
var errors = rows.Select(t => DiffRows(t.Item1, t.Item2)).SelectMany(i => i);
return errors.GroupBy(e => e.Column).Select(g => new Result { Title = g.Key, Errors = g.Select(e => e.Message).Distinct().ToList() });
}
示例6: ReadAcceptType
private string ReadAcceptType(IEnumerable<string> header)
{
if (header == null || header.Count() == 0) return "*/*";
if (header.Count() == 1) return header.Single();
return header.Join(", ");
}
示例7: NounNotFound
public NounNotFound(IEnumerable<string> nouns)
{
nouns = nouns.ToList();
if (nouns.Count() == 0)
_message = "Noun not found.";
else
_message = "Ambiguous noun. Possible matches: " + nouns.Join(", ");
}
示例8: validateMatchingMimetypes
private static void validateMatchingMimetypes(MimeType mimeType, AssetTagPlan plan, IEnumerable<string> names)
{
if (plan.Subjects.Any(x => x.MimeType != mimeType))
{
var message = "Files {0} have mixed mimetype's".ToFormat(names.Join(", "));
throw new MixedMimetypeException(message);
}
}
示例9: MapScope
public static IEnumerable<string> MapScope(IEnumerable<ReferenceDataItem> collection, IEnumerable<string> config)
{
return collection.Join(
config,
s => s.Name,
r => r,
(s, r) => s.Id,
StringComparer.OrdinalIgnoreCase);
}
示例10: TestSuite
public TestSuite(IEnumerable<ITestee> parsers, IEnumerable<ITest> tests, IOutput output, IWarmup warmup = null)
{
_reruns = 1;
_repeats = 10;
_parsers = parsers;
_tests = tests;
_output = output;
_warmup = warmup;
_results = new List<TestResult>(parsers.Join(tests, m => 0, m => 0, (a, b) => new TestResult(b, a)));
}
示例11: BuildDefaultName
/// <summary>
/// Creates a default index name based on the supplied column names.
/// </summary>
/// <param name="columns">The column names used to create a default index name.</param>
/// <returns>A default index name.</returns>
public static string BuildDefaultName(IEnumerable<string> columns)
{
Check.NotNull(columns, "columns");
return string.Format(
CultureInfo.InvariantCulture,
"IX_{0}",
columns.Join(separator: "_"))
.RestrictTo(128);
}
示例12: DictionaryPath
public DictionaryPath(string path)
{
var parts = path.Trim().Split('.');
_parentParts = parts.Reverse().Skip(1).Reverse();
_parent = parts.Any()
? _parentParts.Join(".")
: String.Empty;
_key = parts.Last();
}
示例13: AssetNamesKey
public AssetNamesKey(IEnumerable<string> names)
{
_names = names.OrderBy(x => x);
_hashcode = new Lazy<int>(() =>
{
var combined = names.Join("*");
return combined.ToHash().GetHashCode();
});
}
示例14: CheckMetadataStringOperator
private IEnumerable<Node> CheckMetadataStringOperator(MappingToolDatabaseDataContext dbContext, IEnumerable<Node> nodes, GraphQueryMetadata metadataTest)
{
List<Node> filteredNodes = null;
if (metadataTest.Operator.Equals("Contains", StringComparison.InvariantCultureIgnoreCase))
{
IQueryable<Node> queryableNodes = nodes.AsQueryable();
var filteredMetadata = from dbMetadata in dbContext.udf_SearchMetadataContains(metadataTest.Name, metadataTest.Value) select dbMetadata;
int counter = filteredMetadata.Count();
filteredNodes = nodes.Join(filteredMetadata, x => x.NodeUid, y => y.NodeUid, (a, b) => a).ToList();
}
else if (metadataTest.Operator.Equals("FreeText", StringComparison.InvariantCultureIgnoreCase))
{
IQueryable<Node> queryableNodes = nodes.AsQueryable();
var filteredMetadata = from dbMetadata in dbContext.udf_SearchMetadataFreeText(metadataTest.Name, metadataTest.Value) select dbMetadata;
int counter = filteredMetadata.Count();
filteredNodes = nodes.Join(filteredMetadata, x => x.NodeUid, y => y.NodeUid, (a, b) => a).ToList();
}
else
{
filteredNodes = new List<Node>();
foreach (Node node in nodes)
{
if (metadataTest.Operator.Equals("Equals", StringComparison.InvariantCultureIgnoreCase))
{
if (node.Metadatas.Where(metadata => metadata.MetadataName == metadataTest.Name && metadata.MetadataValue.Contains(metadataTest.Value)).Count() > 0)
{
filteredNodes.Add(node);
}
}
else if (metadataTest.Operator.Equals("NotEquals", StringComparison.InvariantCultureIgnoreCase))
{
if (node.Metadatas.Where(metadata => metadata.MetadataName == metadataTest.Name && metadata.MetadataValue != metadataTest.Value).Count() > 0)
{
filteredNodes.Add(node);
}
}
}
}
return filteredNodes;
}
示例15: SetUniqueNamesForForeignKeyProperties
public static void SetUniqueNamesForForeignKeyProperties(IEnumerable<ForeignKey> foreignKeys)
{
IEnumerable<string> refsUsedMoreThanOnce = foreignKeys.Select(f => f.References).Distinct()
.GroupJoin(foreignKeys, a => a, b => b.References, (a, b) => new { References = a, Count = b.Count() })
.Where(@t => t.Count > 1)
.Select(@t => t.References);
foreignKeys.Join(refsUsedMoreThanOnce, a => a.References, b => b, (a, b) => a).ToList()
.ForEach(fk => { fk.UniquePropertyName = fk.Name + "_" + fk.References; });
}