本文整理汇总了C#中ImmutableList.IndexOf方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableList.IndexOf方法的具体用法?C# ImmutableList.IndexOf怎么用?C# ImmutableList.IndexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImmutableList
的用法示例。
在下文中一共展示了ImmutableList.IndexOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: VerifyRootPrincipal
private IProperty VerifyRootPrincipal(
IProperty principalProperty,
Dictionary<IProperty, IProperty> verifiedProperties,
ImmutableList<IForeignKey> visitedForeignKeys,
out string errorMessage)
{
errorMessage = null;
IProperty rootPrincipal;
if (verifiedProperties.TryGetValue(principalProperty, out rootPrincipal))
{
return rootPrincipal;
}
var rootPrincipals = new Dictionary<IProperty, IForeignKey>();
foreach (var foreignKey in principalProperty.DeclaringEntityType.GetForeignKeys())
{
for (var index = 0; index < foreignKey.Properties.Count; index++)
{
if (principalProperty == foreignKey.Properties[index])
{
var nextPrincipalProperty = foreignKey.PrincipalKey.Properties[index];
if (visitedForeignKeys.Contains(foreignKey))
{
var cycleStart = visitedForeignKeys.IndexOf(foreignKey);
var cycle = visitedForeignKeys.GetRange(cycleStart, visitedForeignKeys.Count - cycleStart);
errorMessage = Strings.CircularDependency(cycle.Select(fk => fk.ToString()).Join());
continue;
}
rootPrincipal = VerifyRootPrincipal(nextPrincipalProperty, verifiedProperties, visitedForeignKeys.Add(foreignKey), out errorMessage);
if (rootPrincipal == null)
{
if (principalProperty.RequiresValueGenerator)
{
rootPrincipals[principalProperty] = foreignKey;
}
continue;
}
if (principalProperty.RequiresValueGenerator)
{
ShowError(Strings.ForeignKeyValueGenerationOnAdd(
principalProperty.Name,
principalProperty.DeclaringEntityType.DisplayName(),
Property.Format(foreignKey.Properties)));
return principalProperty;
}
rootPrincipals[rootPrincipal] = foreignKey;
}
}
}
if (rootPrincipals.Count == 0)
{
if (errorMessage != null)
{
return null;
}
if (!principalProperty.RequiresValueGenerator)
{
ShowError(Strings.PrincipalKeyNoValueGenerationOnAdd(principalProperty.Name, principalProperty.DeclaringEntityType.DisplayName()));
return null;
}
return principalProperty;
}
if (rootPrincipals.Count > 1)
{
var firstRoot = rootPrincipals.Keys.ElementAt(0);
var secondRoot = rootPrincipals.Keys.ElementAt(1);
ShowWarning(Strings.MultipleRootPrincipals(
rootPrincipals[firstRoot].DeclaringEntityType.DisplayName(),
Property.Format(rootPrincipals[firstRoot].Properties),
firstRoot.DeclaringEntityType.DisplayName(),
firstRoot.Name,
Property.Format(rootPrincipals[secondRoot].Properties),
secondRoot.DeclaringEntityType.DisplayName(),
secondRoot.Name));
return firstRoot;
}
errorMessage = null;
rootPrincipal = rootPrincipals.Keys.Single();
verifiedProperties[principalProperty] = rootPrincipal;
return rootPrincipal;
}