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


C# ISet.Any方法代码示例

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


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

示例1: MakeParametersUnique

        private static int MakeParametersUnique(ScriptAction action, ISet<Tuple<string, string>> properties, int sequence)
        {
            if (action.ConfigurationVariables == null)
            {
                return sequence;
            }

            foreach (var configVar in action.ConfigurationVariables)
            {
                var tuple = Tuple.Create(CleanInvalidCharacters(configVar.OriginalName), configVar.Value);
                if (!properties.Contains(tuple))
                {
                    if (properties.Any(p => p.Item1 == tuple.Item1 && p.Item2 != tuple.Item2))
                    {
                        var newVariableName = configVar.RemappedName + sequence;
                        sequence++;
                        action.Arguments = action.Arguments?.Replace(configVar.RemappedName, newVariableName);
                        configVar.RemappedName = newVariableName;
                    }
                }

                properties.Add(tuple);
            }

            return sequence;
        }
开发者ID:DanielBMann9000,项目名称:Migrate-assets-from-RM-server-to-VSTS,代码行数:26,代码来源:UniquePropertyResolver.cs

示例2: Negotiate

        public string Negotiate(ISet<string> server, ISet<string> client)
        {
            if (!server.Any() || !client.Any())
                return null;

            var matches = client.Intersect(server);
            if (!matches.Any())
                throw new SubProtocolNegotiationFailureException("Unable to negotiate a subprotocol");

            return matches.First();
        }
开发者ID:ReactiveMarkets,项目名称:Styx,代码行数:11,代码来源:SubProtocolNegotiator.cs

示例3: AssignTypesToDefinition

 /// <summary>
 /// Assigns the specified types to the definition.
 /// </summary>
 /// <param name="types">ITypeSymbols</param>
 /// <param name="definition">SymbolDefinition</param>
 internal void AssignTypesToDefinition(ISet<ITypeSymbol> types, SymbolDefinition definition)
 {
     if (types.Count > 0 && !types.Any(type => type == null))
     {
         definition.CandidateTypes.Clear();
         definition.CandidateTypes.UnionWith(types);
     }
 }
开发者ID:yonglehou,项目名称:PSharp,代码行数:13,代码来源:DataFlowInfo.cs

示例4: GenerateExportsAsync

		async Task<IEnumerable<Document>> GenerateExportsAsync(IEnumerable<Document> components,
			ISet<string> excludedNamespaces, 
			CancellationToken cancellation)
		{
			var attribute = compilation.FindTypeByName("Clide", "Clide", "ComponentAttribute");
			var documents = new List<Document>();

			foreach (var document in components)
			{
				var syntax = await document.GetSyntaxTreeAsync(cancellation);
				if (cancellation.IsCancellationRequested)
					return Enumerable.Empty<Document>();

				var semanticModel = compilation.GetSemanticModel(syntax);
				var visitor = new AttributedTypeCollector(semanticModel, attribute);
				visitor.Visit(syntax.GetRoot());

				foreach (var component in visitor.AnnotatedTypes)
				{
					var text = new StringBuilder();
					text.AppendLine("using System.ComponentModel.Composition;").AppendLine();
					text.Append("namespace ").AppendLine(component.ContainingNamespace.ToString());
					text.AppendLine("{");

					var policy = component.GetAttributes()
						.First(a => a.AttributeClass.Name == "ComponentAttribute" && a.AttributeClass.ContainingNamespace.Name == "Clide")
						.ConstructorArguments.Select(arg => arg.Value).Cast<CreationPolicy>().FirstOrDefault();

					text.Append("\t")
						.Append("[PartCreationPolicy(CreationPolicy.")
						.Append(policy.ToString())
						.AppendLine(")]");

					var componentInterfaces = from iface in component.AllInterfaces
											  let fullName = iface.ToDisplayString(SymbolDisplayFormat.CSharpErrorMessageFormat)
											  where fullName != "System.IDisposable" && 
												!excludedNamespaces.Any(ns => fullName.StartsWith(ns))
											  select iface;

					// Export each implemented interface
					foreach (var iface in componentInterfaces)
					{
						text.Append("\t")
							.Append("[Export(typeof(")
							.Append(iface.ToString())
							.AppendLine("))]");

						// Special-case IObservable<T>, since we need to export it with the contract 
						// of each of the base types of T in order to be able to retrieve them 
						// from the event stream by event base type.
						if (iface.IsGenericType && iface.ConstructedFrom.ToString() == "System.IObservable<T>")
						{
							var eventType = iface.TypeArguments[0].BaseType;
							while (eventType.ToDisplayString(SymbolDisplayFormat.FullyQualifiedFormat) != "object")
							{
								text.Append("\t")
									.Append("[Export(typeof(System.IObservable<")
									.Append(eventType.ToString())
									.AppendLine(">))]");

								eventType = eventType.BaseType;
							}
						}
					}

					text.Append("\t")
						.Append("partial class ")
						.Append(component.Name)
						.AppendLine(" { }")
						.AppendLine("}");

					documents.Add(document.Project.AddDocument(Path.ChangeExtension(document.Name, ".g.cs"),
						SourceText.From(text.ToString()), document.Folders));
				}
			}

			return documents;
		}
开发者ID:kzu,项目名称:clide,代码行数:78,代码来源:ExportsGenerator.cs

示例5: SavePreStartInitAssembliesToFile

 // this method requires global lock as the part of the fix of DevDiv bug 501777
 internal static void SavePreStartInitAssembliesToFile(string path, ISet<string> assemblies) {
     Debug.Assert(assemblies != null);
     Debug.Assert(!String.IsNullOrEmpty(path));
     Debug.Assert(!assemblies.Any(String.IsNullOrEmpty));
     bool gotLock = false;
     try {
         //put write under the global lock to avoid race condition
         CompilationLock.GetLock(ref gotLock);
         File.WriteAllLines(path, assemblies);
     }
     catch {
         try {
             File.Delete(path);
         }
         catch { }
     }
     finally {
         if (gotLock) {
             CompilationLock.ReleaseLock();
         }
     }
 }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:23,代码来源:BuildManager.cs

示例6: IsAny

 public static bool IsAny(this ITypeSymbol typeSymbol, ISet<KnownType> types)
 {
     return typeSymbol != null && types.Any(t => IsMatch(typeSymbol, t));
 }
开发者ID:dbolkensteyn,项目名称:sonarlint-vs,代码行数:4,代码来源:TypeHelper.cs

示例7: LayOutSiblingNodes

        public static List<Node> LayOutSiblingNodes(ISet<Node> toBeGrouped)
        {
            if (toBeGrouped.Count <= 1)
                return toBeGrouped.ToList();
            var groupedNodes = new List<Node>();
            var hasBeenAdded = new HashSet<Node>();
            var nextGroupTarget = toBeGrouped;

            //Remove nodes that does not depend on anything and is never referenced
            var unreferenced = toBeGrouped.Where(x => !x.SiblingDependencies.Any()
                                                       && !toBeGrouped.SiblingDependencies().Contains(x)).ToHashSet();
            nextGroupTarget.ExceptWith(unreferenced);
            while (toBeGrouped.Any())
            {
                if (!nextGroupTarget.Any())
                {
                    nextGroupTarget = toBeGrouped;
                }
                while (nextGroupTarget.Any())
                {
                    var currentLayer = GetFacadeNodes(nextGroupTarget);
                    nextGroupTarget = currentLayer.SiblingDependencies().ToHashSet();
                    if (nextGroupTarget.Any())
                    {
                        //Get the next layer to check if any of the dependencies are unique to a node of the current layer
                        var nextLayer = GetFacadeNodes(nextGroupTarget);

                        //Check if any nodes that have not been added yet has dependencies on the unique ones, in this case they arent really unique
                        var leftForNextBatch = toBeGrouped.Except(currentLayer.Union(nextLayer));
                        nextLayer.RemoveAll(x => leftForNextBatch.SiblingDependencies().Contains(x));

                        var uniqueDependencies =
                            nextLayer.Where(x => !currentLayer.All(n => n.SiblingDependencies.Contains(x)))
                                .Distinct()
                                .ToList();

                        //If there are unique dependencies, vertical layers are created to separate the unique dependency from layers that dont depend on it
                        if (uniqueDependencies.Any())
                        {
                            while (true)
                            {
                                //Check if any nodes that have not been added yet has dependencies on the unique ones, in this case they arent really unique
                                leftForNextBatch = toBeGrouped.Except(currentLayer.Union(nextLayer));
                                nextLayer.RemoveAll(x => leftForNextBatch.Any(y => y.IndirectlyDependsOn(x)));
                                var groupsToCreate = FindDependencyPatterns(currentLayer, nextLayer);
                                var toBeShared = new HashSet<Node>();
                                toBeGrouped.ExceptWith(currentLayer);

                                foreach (var dependencyGroup in groupsToCreate)
                                {
                                    var referencers = dependencyGroup.Referencers;
                                    currentLayer.RemoveRange(referencers.ToList());
                                    var dependants = dependencyGroup.Dependants.ToList();
                                    nextGroupTarget.ExceptWith(dependants);
                                    toBeGrouped.ExceptWith(dependants);
                                    hasBeenAdded.UnionWith(dependants);
                                    hasBeenAdded.UnionWith(referencers);
                                    // Add dependant to the vertical layer
                                    var depNode = CreateHorizontalLayer(dependants);
                                    // Add references to the vertical layer
                                    var referenceNode = CreateHorizontalLayer(referencers);
                                    var newList = new List<Node> {depNode, referenceNode};
                                    //Get ALL the possible candidates for the vertical layer
                                    var verticalCandidates =
                                        referencers.SelectMany(x => x.IndirectSiblingDependencies())
                                            .Except(dependants)
                                            .Union(
                                                dependants.SelectMany(x => x.IndirectSiblingDependencies()))
                                            .Distinct()
                                            .Except(hasBeenAdded).Intersect(toBeGrouped)
                                            .ToHashSet();

                                    //Get all the nodes in this current call depth
                                    var otherGroups = groupsToCreate.Except(dependencyGroup);
                                    var nodesInOtherGroups = otherGroups.
                                        SelectMany(x => x.Dependants.Union(x.Referencers)).ToHashSet();
                                    var otherNodes =
                                        toBeGrouped.Union(currentLayer)
                                            .Union(nodesInOtherGroups)
                                            .Except(verticalCandidates)
                                            .ToHashSet();

                                    var siblingDepsRelevantForNewNode = new HashSet<Node>();
                                    //If any of the other nodes depends on the vertical candidate the candidate is removed and will be placed in a later iteration of this call (it is still left in toBeGrouped)
                                    foreach (var candidate in verticalCandidates.ToList())
                                    {
                                        var otherNodesDependantOnCandidate =
                                            otherNodes.Where(x => x.IndirectlyDependsOn(candidate)).ToHashSet();
                                        if (toBeShared.Contains(candidate) || otherNodesDependantOnCandidate.Any())
                                        {
                                            verticalCandidates.Remove(candidate);
                                            toBeShared.Add(candidate);
                                        }
                                    }

                                    if (verticalCandidates.Any())
                                    {
                                        toBeGrouped.ExceptWith(verticalCandidates);
                                        nextGroupTarget.ExceptWith(verticalCandidates);
                                        hasBeenAdded.UnionWith(verticalCandidates);
//.........这里部分代码省略.........
开发者ID:davidkron,项目名称:DevArch,代码行数:101,代码来源:SiblingReorderer.cs

示例8: GetFacadeNodes

 public static List<Node> GetFacadeNodes(ISet<Node> targets)
 {
     if(!targets.Any())
         return new List<Node>();
     var allDependencies = targets.SiblingDependencies().ToList();
     var noOneDependantOn =  targets.Where(n => !allDependencies.Contains(n)).ToList();
     if (noOneDependantOn.Any())
         return noOneDependantOn;
     var indirectDepsCount = targets.ToDictionary(x => x, x => x.IndirectSiblingDependencies().Count());
     var maxDeps = indirectDepsCount.Values.Max();
     return targets.Where(x => indirectDepsCount[x] == maxDeps).ToList();
 }
开发者ID:davidkron,项目名称:DevArch,代码行数:12,代码来源:SiblingReorderer.cs

示例9: HandleConnectOnDemandAdapters

        /// <summary>
        /// Starts or stops connect on demand adapters based on current state of demanded input or output signals.
        /// </summary>
        /// <param name="inputMeasurementKeysRestriction">The set of signals to be produced by the chain of adapters to be handled.</param>
        /// <param name="inputAdapterCollection">Collection of input adapters at start of routing table calculation.</param>
        /// <param name="actionAdapterCollection">Collection of action adapters at start of routing table calculation.</param>
        /// <param name="outputAdapterCollection">Collection of output adapters at start of routing table calculation.</param>
        /// <remarks>
        /// Set the <paramref name="inputMeasurementKeysRestriction"/> to null to use full adapter routing demands.
        /// </remarks>
        protected virtual void HandleConnectOnDemandAdapters(ISet<MeasurementKey> inputMeasurementKeysRestriction, IInputAdapter[] inputAdapterCollection, IActionAdapter[] actionAdapterCollection, IOutputAdapter[] outputAdapterCollection)
        {
            ISet<IAdapter> dependencyChain;

            ISet<MeasurementKey> inputSignals;
            ISet<MeasurementKey> outputSignals;
            ISet<MeasurementKey> requestedInputSignals;
            ISet<MeasurementKey> requestedOutputSignals;

            if (inputMeasurementKeysRestriction.Any())
            {
                // When an input signals restriction has been defined, determine the set of adapters
                // by walking the dependency chain of the restriction
                dependencyChain = TraverseDependencyChain(inputMeasurementKeysRestriction, inputAdapterCollection, actionAdapterCollection, outputAdapterCollection);
            }
            else
            {
                // Determine the set of adapters in the dependency chain for all adapters in the system
                dependencyChain = TraverseDependencyChain(inputAdapterCollection, actionAdapterCollection, outputAdapterCollection);
            }

            // Get the full set of requested input and output signals in the entire dependency chain
            inputSignals = new HashSet<MeasurementKey>(dependencyChain.SelectMany(adapter => adapter.InputMeasurementKeys()));
            outputSignals = new HashSet<MeasurementKey>(dependencyChain.SelectMany(adapter => adapter.OutputMeasurementKeys()));

            // Turn connect on demand input adapters on or off based on whether they are part of the dependency chain
            if ((object)inputAdapterCollection != null)
            {
                foreach (IInputAdapter inputAdapter in inputAdapterCollection)
                {
                    if (!inputAdapter.AutoStart)
                    {
                        if (dependencyChain.Contains(inputAdapter))
                        {
                            requestedOutputSignals = new HashSet<MeasurementKey>(inputAdapter.OutputMeasurementKeys());
                            requestedOutputSignals.IntersectWith(inputSignals);
                            inputAdapter.RequestedOutputMeasurementKeys = requestedOutputSignals.ToArray();
                            inputAdapter.Enabled = true;
                        }
                        else
                        {
                            inputAdapter.RequestedOutputMeasurementKeys = null;
                            inputAdapter.Enabled = false;
                        }
                    }
                }
            }

            // Turn connect on demand action adapters on or off based on whether they are part of the dependency chain
            if ((object)actionAdapterCollection != null)
            {
                foreach (IActionAdapter actionAdapter in actionAdapterCollection)
                {
                    if (!actionAdapter.AutoStart)
                    {
                        if (dependencyChain.Contains(actionAdapter))
                        {
                            if (actionAdapter.RespectInputDemands)
                            {
                                requestedInputSignals = new HashSet<MeasurementKey>(actionAdapter.InputMeasurementKeys());
                                requestedInputSignals.IntersectWith(outputSignals);
                                actionAdapter.RequestedInputMeasurementKeys = requestedInputSignals.ToArray();
                            }

                            if (actionAdapter.RespectOutputDemands)
                            {
                                requestedOutputSignals = new HashSet<MeasurementKey>(actionAdapter.OutputMeasurementKeys());
                                requestedOutputSignals.IntersectWith(inputSignals);
                                actionAdapter.RequestedOutputMeasurementKeys = requestedOutputSignals.ToArray();
                            }

                            actionAdapter.Enabled = true;
                        }
                        else
                        {
                            actionAdapter.RequestedInputMeasurementKeys = null;
                            actionAdapter.RequestedOutputMeasurementKeys = null;
                            actionAdapter.Enabled = false;
                        }
                    }
                }
            }

            // Turn connect on demand output adapters on or off based on whether they are part of the dependency chain
            if ((object)outputAdapterCollection != null)
            {
                foreach (IOutputAdapter outputAdapter in outputAdapterCollection)
                {
                    if (!outputAdapter.AutoStart)
                    {
//.........这里部分代码省略.........
开发者ID:rmc00,项目名称:gsf,代码行数:101,代码来源:RoutingTables.cs

示例10: InSentenceFormGroup

 public static bool InSentenceFormGroup(Fact sentence, ISet<ISentenceForm> forms)
 {
     return forms.Any(form => form.Matches(sentence));
 }
开发者ID:druzil,项目名称:nggp-base,代码行数:4,代码来源:SentenceFormAdder.cs

示例11: RewriteNuspecReferences

        private void RewriteNuspecReferences(bool nuspecFileExists, ISet<string> projectRefs, string nuspecFile)
        {
            if (nuspecFileExists)
            {
                if (projectRefs.Any())
                {
                    var nuspecContents = File.ReadAllText(nuspecFile);
                    string newNuspecContents;
                    if (RxDependencies.IsMatch(nuspecContents))
                    {
                        newNuspecContents = RxDependencies.Replace(
                            nuspecContents,
            // ReSharper disable ImplicitlyCapturedClosure
                            match => "<dependencies>" +
            // ReSharper restore ImplicitlyCapturedClosure
                                     Environment.NewLine +
                                     RemoveProjectRefs(match.Groups[1].Value, projectRefs) +
                                     MakeProjectDependencies(projectRefs) +
                                     Environment.NewLine +
                                     "</dependencies>"
                            );
                    }
                    else
                    {
                        newNuspecContents = RxMetaData.Replace(
                            nuspecContents,
            // ReSharper disable ImplicitlyCapturedClosure
                            match => "<metadata>" +
            // ReSharper restore ImplicitlyCapturedClosure
                                     match.Groups[1].Value +
                                     Environment.NewLine +
                                     "<dependencies>" +
                                     Environment.NewLine +
                                     MakeProjectDependencies(projectRefs) +
                                     Environment.NewLine +
                                     "</dependencies>" +
                                     Environment.NewLine +
                                     "</metadata>"
                            );
                    }

                    if (newNuspecContents != nuspecContents)
                    {
                        File.WriteAllText(nuspecFile, newNuspecContents);
                    }
                }
            }
        }
开发者ID:tanglebones,项目名称:ch-nugetine,代码行数:48,代码来源:ReWriter.cs


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