本文整理汇总了C#中IDictionary.All方法的典型用法代码示例。如果您正苦于以下问题:C# IDictionary.All方法的具体用法?C# IDictionary.All怎么用?C# IDictionary.All使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IDictionary
的用法示例。
在下文中一共展示了IDictionary.All方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddForeignsDelete
private void AddForeignsDelete(
DbCommand cmd,
Entity entity,
IDictionary<string, DeleteOption> options)
{
if (options.All(x => x.Value == DeleteOption.Nothing || x.Value == DeleteOption.AskUser))
return;
var sbDeletes = new StringBuilder();
var recordHierarchy = _hierarchySource.GetRecordHierarchy(entity);
foreach (var subRecord in recordHierarchy.SubRecordsHierarchies)
{
var deleteOption = DeleteOption.Nothing;
if (options.ContainsKey(subRecord.Entity.Name))
{
deleteOption = options[subRecord.Entity.Name];
}
switch (deleteOption)
{
case DeleteOption.SetNull:
sbDeletes.AppendLine(GetSetToNullUpdateSql(cmd, entity, subRecord));
break;
case DeleteOption.CascadeDelete:
var deletes = GetDeleteRelatedEntityDeleteSql(cmd, subRecord).Reverse();
sbDeletes.AppendLine(string.Join(Environment.NewLine, deletes));
break;
}
}
cmd.CommandText = sbDeletes + cmd.CommandText;
}
示例2: ContainsAllTags
public static bool ContainsAllTags(ObjectivesResultsCollection x, IDictionary<string, string> tags)
{
var xTags = x.Tags.Tags;
return tags.All((dictTag =>
(xTags.Any((xTag =>
(dictTag.Key == xTag.Name && dictTag.Value == xTag.Value))))));
}
示例3: ConditionsMet
public bool ConditionsMet(IDictionary<string, bool> playerState, IDictionary<string, bool> conditions)
{
return
conditions.All(
c =>
(!c.Value && (!playerState.ContainsKey(c.Key) || !playerState[c.Key])) ||
(c.Value && (playerState.ContainsKey(c.Key) && playerState[c.Key])));
}
示例4: GetUniqueName
public static string GetUniqueName(IDictionary<string, ApiObject> objects, string name, IDictionary<string, ApiObject> otherObjects, IDictionary<string, ApiObject> schemaObjects)
{
for (var i = 0; i < 100; i++)
{
var unique = name + i;
if (schemaObjects.All(p => p.Value.Name != unique) && objects.All(p => p.Value.Name != unique) && otherObjects.All(p => p.Value.Name != unique))
return unique;
}
foreach (var suffix in Suffixes)
{
for (var i = 0; i < 100; i++)
{
var unique = name + suffix + i;
if (schemaObjects.All(p => p.Value.Name != unique) && objects.All(p => p.Value.Name != unique) && otherObjects.All(p => p.Value.Name != unique))
return unique;
}
}
throw new InvalidOperationException("Could not find a unique name for object: " + name);
}
示例5: JustAttributes
static bool JustAttributes(IDictionary<string, CfgMetadata> meta, object node) {
if(meta.All(kv => kv.Value.ListType == null))
return true;
foreach(var pair in meta.Where(kv=>kv.Value.ListType != null)){
var list = (IList)meta[pair.Key].Getter(node);
if (list != null && list.Count > 0)
return false;
}
return true;
}
示例6: GetUniqueKey
public static string GetUniqueKey(IDictionary<string, ApiObject> objects, string key, IDictionary<string, ApiObject> otherObjects)
{
for (var i = 0; i < 100; i++)
{
var unique = key + i;
if (objects.All(p => !string.Equals(p.Key, unique, StringComparison.OrdinalIgnoreCase))
&& otherObjects.All(p => !string.Equals(p.Key, unique, StringComparison.OrdinalIgnoreCase)))
return unique;
}
foreach (var suffix in Suffixes)
{
for (var i = 0; i < 100; i++)
{
var unique = key + suffix + i;
if (objects.All(p => !string.Equals(p.Key, unique, StringComparison.OrdinalIgnoreCase))
&& otherObjects.All(p => !string.Equals(p.Key, unique, StringComparison.OrdinalIgnoreCase)))
return unique;
}
}
throw new InvalidOperationException("Could not find a key name for object: " + key);
}
示例7: CheckForExistingProperty
private static object CheckForExistingProperty(object item2, PropertyInfo fi, IDictionary<string, object> result)
{
var newValue = fi.GetValue(item2, null);
if (result.All(x => x.Key != fi.Name))
{
return newValue;
}
var foundProperty = result.Single(x => x.Key == fi.Name);
if (!foundProperty.Value.Equals(newValue))
{
throw new Exception("Merging Property with different values - " + fi.Name);
}
return newValue;
}
示例8: WaitChildForCompleted
void WaitChildForCompleted (ObjectValue val, IDictionary<ObjectValue, bool> evaluatingList, bool hasMore)
{
view.WriteOutput ("\n ");
var mark = view.Buffer.CreateMark (null, view.InputLineEnd, true);
var iteration = 0;
GLib.Timeout.Add (100, () => {
if (!val.IsEvaluating) {
PrintChildValueAtMark (val, mark);
lock (mutex) {
// Maybe We don't need this lock because children evaluation is done synchronously
evaluatingList[val] = true;
if (evaluatingList.All (x => x.Value))
FinishPrinting (hasMore);
}
return false;
}
string prefix = "\t" + val.Name + ": ";
if (++iteration == 5) {
SetLineText (prefix + GettextCatalog.GetString ("Evaluating"), mark);
} else if (iteration > 5 && (iteration - 5) % 10 == 0) {
string points = string.Join ("", Enumerable.Repeat (".", iteration / 10));
SetLineText (prefix + GettextCatalog.GetString ("Evaluating") + " " + points, mark);
}
return true;
});
}
示例9: AddObjectToObjectCollectionOrLink
private void AddObjectToObjectCollectionOrLink(ApiObject obj, string key, IDictionary<string, ApiObject> objects)
{
if (obj == null || !obj.Properties.Any())
return;
if (objects.All(o => o.Value.Name != obj.Name))
{
objects.Add(key, obj);
}
else
{
if (!linkKeysWithObjectNames.ContainsKey(key))
linkKeysWithObjectNames.Add(key, obj.Name);
}
}
示例10: SetProperties
/// <summary>
/// Sets the values of the Configuration properties.
/// </summary>
/// <param name="properties"></param>
public void SetProperties(IDictionary<string, string> properties)
{
if (this.sessionFactory == null && properties != null && properties.Count > 0)
properties.All
(
current =>
{
this.OverrideProperty(current.Key, current.Value);
return true;
}
);
}
示例11: AddObjectToObjectCollectionOrLink
private void AddObjectToObjectCollectionOrLink(ApiObject obj, string key, IDictionary<string, ApiObject> objects, IDictionary<string, ApiObject> otherObjects)
{
if (obj == null || (!obj.Properties.Any() && obj.Type == null))
return;
if (schemaObjects.All(o => o.Value.Name != obj.Name) && objects.All(o => o.Value.Name != obj.Name) && otherObjects.All(o => o.Value.Name != obj.Name))
{
objects.Add(key, obj);
}
else
{
if (UniquenessHelper.HasSameProperties(obj, objects, key, otherObjects, schemaObjects))
{
if (string.IsNullOrWhiteSpace(obj.GeneratedCode) && !linkKeysWithObjectNames.ContainsKey(key))
linkKeysWithObjectNames.Add(key, obj.Name);
}
else if(!objects.ContainsKey(key))
{
obj.Name = UniquenessHelper.GetUniqueName(objects, obj.Name, schemaObjects, schemaObjects);
objects.Add(key, obj);
}
}
}
示例12: PostTestResultToAppveyor
private static void PostTestResultToAppveyor(IDictionary<string, PlatformResult> dict)
{
var tempResult = ResultKind.NoError;
var tempPlatform = Enumerable.Empty<string>();
if (dict.Any(it => it.Value.Result.Kind == ResultKind.Fail))
{
if (dict.All (it => it.Value.Result.Kind == ResultKind.Fail))
tempPlatform = new[]{ "All" };
else
tempPlatform = dict.Where (it => it.Value.Result.Kind == ResultKind.Fail).Select(it=>it.Value.Platform);
}
else if (dict.Any(it => it.Value.Result.Kind == ResultKind.Error))
{
if (dict.All (it => it.Value.Result.Kind == ResultKind.Error))
tempPlatform = new[]{ "All" };
else
tempPlatform = dict.Where (it => it.Value.Result.Kind == ResultKind.Error).Select(it=>it.Value.Platform);
}
else if (dict.Any(it => it.Value.Result.Kind == ResultKind.Ignore))
{
if (dict.All (it => it.Value.Result.Kind == ResultKind.Ignore))
tempPlatform = new[]{ "All" };
else
tempPlatform = dict.Where (it => it.Value.Result.Kind == ResultKind.Ignore).Select(it=>it.Value.Platform);
}
else if (dict.All(it => it.Value.Result.Kind == ResultKind.Success))
{
if (dict.All (it => it.Value.Result.Kind == ResultKind.Success))
tempPlatform = new[]{ "All" };
else
tempPlatform = dict.Where (it => it.Value.Result.Kind == ResultKind.Success).Select(it=>it.Value.Platform);
}
else
{
if (dict.All (it => it.Value.Result.Kind == ResultKind.NoError))
tempPlatform = new[]{ "All" };
else
tempPlatform = dict.Where (it => it.Value.Result.Kind == ResultKind.NoError).Select(it=>it.Value.Platform);
}
string outcome = null;
switch (tempResult)
{
case ResultKind.Success:
outcome = "Passed";
break;
case ResultKind.Fail:
outcome = "Failed";
break;
case ResultKind.Error:
outcome = "NotRunnable";
break;
case ResultKind.Ignore:
outcome = "Ignored";
break;
case ResultKind.NoError:
outcome = "Inconclusive";
break;
}
var result = dict.Values.Select (it=>it.Result).First();
var fullName = string.Format("{0}.{1}.{2} [{3}]", result.Test.Name, result.Test.Fixture.Name,
result.Test.Fixture.Assembly.Name, tempPlatform);
var json = string.Format(@"{{
'testName': '{0}',
'testFramework': '{1}',
'fileName': '{2}',
'outcome': '{3}',
'durationMilliseconds': '{4}',
'ErrorMessage': '',
'ErrorStackTrace': '',
'StdOut': '{5}',
'StdErr': ''
}}",
fullName.EscapeJson(),
"PclUnit",
result.Test.Fixture.Assembly.Name.EscapeJson(),
outcome.EscapeJson(),
(result.EndTime - result.StartTime).Milliseconds,
result.Output.EscapeJson()
);
PostToAppVeyor(json);
}
示例13: PrintResult
public static void PrintResult(IDictionary<string, PlatformResult> dict)
{
if (dict.All(it => it.Value.Result != null))
{
if (AppVeyor)
{
PostTestResultToAppveyor(dict);
}
var result = dict.Select(it => it.Value.Result).First();
if (TeamCity)
{
Console.WriteLine("##teamcity[testStarted name='{2}.{1}.{0}' captureStandardOutput='true']",
result.Test.Name.TeamCityEncode(),
result.Test.Fixture.Name.TeamCityEncode(),
result.Test.Fixture.Assembly.Name.TeamCityEncode());
}
else if(Verbose)
{
Console.Write(result.Test.Fixture.Assembly.Name + ".");
Console.Write(result.Test.Fixture.Name + ".");
}
if (TeamCity || Verbose) {
Console.WriteLine (result.Test.Name);
}
foreach (var grpResult in dict.GroupBy(it => it.Value.Result.Kind))
{
if (Verbose || TeamCity) {
Console.Write ("{0}:", grpResult.Key);
foreach (var keyValuePair in grpResult) {
Console.Write (" ");
Console.Write (keyValuePair.Value.Platform);
}
}
if (TeamCity)
{
switch (grpResult.Key)
{
case ResultKind.Fail:
case ResultKind.Error:
Console.WriteLine(
"##teamcity[testFailed name='{2}.{1}.{0}' message='See log or details']",
result.Test.Name.TeamCityEncode(),
result.Test.Fixture.Name.TeamCityEncode(),
result.Test.Fixture.Assembly.Name.TeamCityEncode());
break;
case ResultKind.Ignore:
Console.WriteLine(
"##teamcity[testIgnored name='{2}.{1}.{0}' message='See log or details']",
result.Test.Name.TeamCityEncode(),
result.Test.Fixture.Name.TeamCityEncode(),
result.Test.Fixture.Assembly.Name.TeamCityEncode());
break;
}
}
if (Verbose || TeamCity) {
Console.WriteLine ();
}
}
if (Verbose || TeamCity) {
var span = new TimeSpan ();
foreach (var r in dict.Select(it => it.Value.Result)) {
span += (r.EndTime - r.StartTime);
}
Console.WriteLine ("avg time:{0}", new TimeSpan (span.Ticks / dict.Count));
}
if (Verbose || TeamCity) {
foreach (var lup in dict.ToLookup(it => it.Value.Result.Output)) {
var name = String.Join (",", lup.Select (it => it.Value.Platform));
Console.WriteLine ("{0}:", name);
Console.WriteLine (lup.Key);
}
}
if (TeamCity)
{
Console.WriteLine("##teamcity[testFinished name='{2}.{1}.{0}' duration='{3}']",
result.Test.Name.TeamCityEncode(),
result.Test.Fixture.Name.TeamCityEncode(),
result.Test.Fixture.Assembly.Name.TeamCityEncode(),
(result.EndTime - result.StartTime).TotalMilliseconds);
}
else
{
if (dict.Any(it => it.Value.Result.Kind == ResultKind.Fail))
{
if (Verbose)
Console.WriteLine ("!!!!!!!!!!!!!!!!!!!!!!!!!");
else if (dict.All(it => it.Value.Result.Kind == ResultKind.Fail))
Console.Write("! ");
else
Console.Write ("!{0} ", dict.Where (it => it.Value.Result.Kind == ResultKind.Fail).Count ());
}
else if (dict.Any(it => it.Value.Result.Kind == ResultKind.Error))
//.........这里部分代码省略.........
示例14: GetUniqueName
private string GetUniqueName(IDictionary<string, ApiEnum> enums, string name)
{
for (var i = 0; i < 9; i++)
{
var unique = name + suffixes[i];
if (enums.All(p => p.Key != unique))
return unique;
}
for (var i = 0; i < 100; i++)
{
var unique = name + "A" + i;
if (enums.All(p => p.Key != unique))
return unique;
}
throw new InvalidOperationException("Could not find a unique name for enum");
}
示例15: match
// Returns true if the row matches the key/value pairs.
bool match(Item i, IDictionary<string, object> constraints)
{
return constraints.All(
c => i.values.ContainsKey(c.Key) && i.values[c.Key].Equals(c.Value)
);
}