当前位置: 首页>>代码示例>>C#>>正文


C# ImmutableList.Contains方法代码示例

本文整理汇总了C#中ImmutableList.Contains方法的典型用法代码示例。如果您正苦于以下问题:C# ImmutableList.Contains方法的具体用法?C# ImmutableList.Contains怎么用?C# ImmutableList.Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImmutableList的用法示例。


在下文中一共展示了ImmutableList.Contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RecoursiveCheckGraph

        private static bool RecoursiveCheckGraph(Task root, ImmutableList<Guid> previousTasks)
        {
            Contract.Requires(root != null);
            Contract.Requires(root.Inputs != null);
            Contract.Requires(previousTasks != null);

            if (previousTasks.Contains(root.Id))
            {
                Logger.Write(
                    LogCategories.Error(string.Format(
                    "{0} is cycled.", root),
                    LogCategories.TaskServices));
                return false;
            }

            foreach (var task in root.Inputs)
            {
                if (previousTasks.Contains(task.Id))
                {
                    Logger.Write(
                        LogCategories.Error(string.Format(
                        "{0} is cycled.", task),
                        LogCategories.TaskServices));
                    return false;
                }

                if (!RecoursiveCheckGraph(task, previousTasks.Add(root.Id)))
                    return false;
            }
            return true;
        }
开发者ID:kapitanov,项目名称:diploma,代码行数:31,代码来源:JobGraphCyclesValidationStrategy.cs

示例2: RecoursiveCheckGraph

        private static bool RecoursiveCheckGraph(TaskRequest root, ImmutableList<Guid> previousTasks)
        {
            if (previousTasks.Contains(root.Id))

                return false;

            foreach (var task in root.Dependencies)
            {
                if (previousTasks.Contains(task.Id))
                    return false;

                if (!RecoursiveCheckGraph(task, previousTasks.Add(root.Id)))
                    return false;
            }
            return true;
        }
开发者ID:kapitanov,项目名称:diploma,代码行数:16,代码来源:ValidateGraph.cs

示例3: FreeVariableNames

 public override ImmutableList<char> FreeVariableNames(ImmutableList<Symbol> boundVariables)
 {
     if (boundVariables.Contains(_variable))
         return ImmutableList<char>.Empty;
     else
         return new char[] { _variable.Default }.ToImmutableList();
 }
开发者ID:michaellperry,项目名称:ClipboardCalculator,代码行数:7,代码来源:BoundVariable.cs

示例4: RecoursiveCheckGraph

        private static bool RecoursiveCheckGraph(Japi.Task root, ImmutableList<Japi.Task> previousTasks)
        {
            if(previousTasks.Contains(root))
            {
                Console.WriteLine("1: {0}", root);
                return false;
            }

            foreach(var task in root.Dependencies)
            {
                if(previousTasks.Contains(task))
                {
                    Console.WriteLine("2: {0}", root);
                    return false;
                }

                if(!RecoursiveCheckGraph(task, previousTasks.Add(root)))
                    return false;
            }
            return true;
        }
开发者ID:kapitanov,项目名称:diploma,代码行数:21,代码来源:ValidateGraph.cs

示例5: 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;
        }
开发者ID:JamesWang007,项目名称:EntityFramework,代码行数:89,代码来源:ModelValidator.cs


注:本文中的ImmutableList.Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。