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


C# Collection.Any方法代码示例

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


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

示例1: SubjectBuffersConnected

        public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
        {
            if (!subjectBuffers.Any(b => b.ContentType.IsOfType(CssContentTypeDefinition.CssContentType)))
                return;

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);
            if (textViewAdapter == null)
                return;

            textView.Properties.GetOrCreateSingletonProperty<CssSortProperties>(() => new CssSortProperties(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<CssExtractToFile>(() => new CssExtractToFile(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<CssAddMissingStandard>(() => new CssAddMissingStandard(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<CssAddMissingVendor>(() => new CssAddMissingVendor(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<CssRemoveDuplicates>(() => new CssRemoveDuplicates(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<MinifySelection>(() => new MinifySelection(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<CssFindReferences>(() => new CssFindReferences(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<F1Help>(() => new F1Help(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<CssSelectBrowsers>(() => new CssSelectBrowsers(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<RetriggerTarget>(() => new RetriggerTarget(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<ArrowsCommandTarget>(() => new ArrowsCommandTarget(textViewAdapter, textView));

            uint cssFormatProperties;
            ErrorHandler.ThrowOnFailure(EditorExtensionsPackage.PriorityCommandTarget.RegisterPriorityCommandTarget(0, new CssFormatProperties(textView), out cssFormatProperties));
            textView.Closed += delegate { ErrorHandler.ThrowOnFailure(EditorExtensionsPackage.PriorityCommandTarget.UnregisterPriorityCommandTarget(cssFormatProperties)); };
        }
开发者ID:jaredpar,项目名称:WebEssentials2013,代码行数:25,代码来源:CssCreationListener.cs

示例2: SubjectBuffersConnected

        public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
        {
            if (textView.Properties.ContainsProperty("TsCommandFilter"))
                return;

            if (!subjectBuffers.Any(b => b.ContentType.IsOfType("TypeScript")))
                return;

            var adapter = EditorAdaptersFactoryService.GetViewAdapter(textView);
            var filter = textView.Properties.GetOrCreateSingletonProperty<TsCommandFilter>("TsCommandFilter", () => new TsCommandFilter(textView, CompletionBroker, _standardClassifications));

            int tries = 0;

            // Ugly ugly hack
            // Keep trying to register our filter until after the JSLS CommandFilter
            // is added so we can catch completion before JSLS swallows all of them.
            // To confirm this, click Debug, New Breakpoint, Break at Function, type
            // Microsoft.VisualStudio.JSLS.TextView.TextView.CreateCommandFilter,
            // then make sure that our last filter is added after that runs.
            while (true)
            {
                IOleCommandTarget next;
                adapter.AddCommandFilter(filter, out next);
                filter.Next = next;

                if (IsJSLSInstalled(next) || ++tries > 10)
                    return;
                await Task.Delay(500);
                adapter.RemoveCommandFilter(filter);    // Remove the too-early filter and try again.
            }
        }
开发者ID:rosieks,项目名称:Rosieks.VisualStudio.Angular,代码行数:31,代码来源:TypeScriptIntellisenseController.cs

示例3: SubjectBuffersConnected

        public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason,
            Collection<ITextBuffer> subjectBuffers)
        {
            if (textView.Properties.ContainsProperty("JsCommandFilter"))
                return;

            if (!subjectBuffers.Any(b => b.ContentType.IsOfType("JavaScript")))
                return;

            var adapter = EditorAdaptersFactoryService.GetViewAdapter(textView);
            var filter = textView.Properties.GetOrCreateSingletonProperty("JsCommandFilter",
                () => new JsCommandFilter(textView, CompletionBroker, _standardClassifications));

            int tries = 0;
            while (true)
            {
                IOleCommandTarget next;
                adapter.AddCommandFilter(filter, out next);
                filter.Next = next;

                if (IsJSLSInstalled(next) || ++tries > 10)
                    return;
                await Task.Delay(500);
                adapter.RemoveCommandFilter(filter); // Remove the too-early filter and try again.
            }
        }
开发者ID:asebak,项目名称:ui5-visualstudio-plugin,代码行数:26,代码来源:JavaScriptCompletionController.cs

示例4: Distinct

        public static IEnumerable<DataRow> Distinct(this IEnumerable<DataRow> dataRowCollection, DataTable schemaTable, byte distinctIndex)
        {
            ICollection<object[]> objectArrayCollection = new Collection<object[]>();

            foreach (DataRow dataRow in dataRowCollection)
            {
                if (!objectArrayCollection.Any())
                {
                    objectArrayCollection.Add(dataRow.ItemArray);
                }
                else
                {
                    if (objectArrayCollection.All(
                        distinctDataRowArray =>
                        {
                            object dateColumnInDataRow = dataRow.ItemArray[distinctIndex];
                            object distinctDateColumnInCollection = distinctDataRowArray[distinctIndex];

                            return (dataRow.ItemArray.Length == distinctDataRowArray.Length)
                                   && ((dateColumnInDataRow != null) && (distinctDateColumnInCollection != null)
                                       && !dataRow.ItemArray.SequenceEqual(distinctDataRowArray));
                        }))
                    {
                        objectArrayCollection.Add(dataRow.ItemArray);
                    }
                }
            }

            foreach (object[] objectArray in objectArrayCollection)
            {
                DataRow newRow = schemaTable.NewRow();
                newRow.ItemArray = objectArray;
                yield return newRow;
            }
        }
开发者ID:unsalersoz,项目名称:Extensions,代码行数:35,代码来源:DataRowExtensions.cs

示例5: AddAndCleanWebConfigModification

        /// <summary>
        /// Method to add one or multiple WebConfig modifications
        /// NOTE: There should not have 2 modifications with the same Owner.
        /// </summary>
        /// <param name="webApp">The current Web Application</param>
        /// <param name="webConfigModificationCollection">The collection of WebConfig modifications to remove-and-add</param>
        /// <remarks>All SPWebConfigModification Owner should be UNIQUE !</remarks>
        public void AddAndCleanWebConfigModification(SPWebApplication webApp, Collection<SPWebConfigModification> webConfigModificationCollection)
        {
            // Verify emptyness
            if (webConfigModificationCollection == null || !webConfigModificationCollection.Any())
            {
                throw new ArgumentNullException("webConfigModificationCollection");
            }

            SPWebApplication webApplication = SPWebService.ContentService.WebApplications[webApp.Id];

            // Start by cleaning up any existing modification for all owners
            // By Good practice, owners should be unique, so we do this to remove duplicates entries if any.
            var owners = webConfigModificationCollection.Select(modif => modif.Owner).Distinct().ToList();
            this.RemoveExistingModificationsFromOwner(webApplication, owners);

            // Add WebConfig modifications
            foreach (var webConfigModification in webConfigModificationCollection)
            {
                webApplication.WebConfigModifications.Add(webConfigModification);
            }

            // Commit modification additions to the specified web application
            webApplication.Update();

            // Push modifications through the farm
            webApplication.WebService.ApplyWebConfigModifications();

            // Wait for timer job
            WaitForWebConfigPropagation(webApplication.Farm);
        }
开发者ID:NunoEdgarGub1,项目名称:Dynamite,代码行数:37,代码来源:WebConfigModificationHelper.cs

示例6: PlayBackgroundWorker

        private void PlayBackgroundWorker()
        {
            _song.Sort();

            //Build a dictionary of notes per note time
            //Should really do all this not on the gui thread...
            //var uniqueNoteTimes = _song.ConvertAll(x => x.NoteTime).Distinct();

            double lastNoteTime = 0;
            Collection<SongNote> simulatneousSongNotes = new Collection<SongNote>();

            //Iterate through song playing notes
            foreach (SongNote note in _song)
            {
                if (note.NoteTime != lastNoteTime && simulatneousSongNotes.Any())
                {
                    SendNoteEvents(simulatneousSongNotes);

                    //FIX ME!!!! PLEASE!!!
                    Thread.Sleep(CalculateNoteDuration(note));
                    simulatneousSongNotes = new Collection<SongNote>();
                }

                simulatneousSongNotes.Add(note);
                lastNoteTime = note.NoteTime;
            }
            //Finally send the last notes in the song
            //Probably a nicer way of handling this..
            SendNoteEvents(simulatneousSongNotes);
        }
开发者ID:hortonal,项目名称:MrKeys,代码行数:30,代码来源:SongPlayer.cs

示例7: ProcessInputBindingsAsync

        protected virtual async Task ProcessInputBindingsAsync(object input, string functionInstanceOutputPath, Binder binder,
            Collection<FunctionBinding> inputBindings, Collection<FunctionBinding> outputBindings,
            Dictionary<string, object> bindingData, Dictionary<string, string> environmentVariables)
        {
            // if there are any input or output bindings declared, set up the temporary
            // output directory
            if (outputBindings.Count > 0 || inputBindings.Any())
            {
                Directory.CreateDirectory(functionInstanceOutputPath);
            }

            // process input bindings
            foreach (var inputBinding in inputBindings)
            {
                string filePath = Path.Combine(functionInstanceOutputPath, inputBinding.Metadata.Name);
                using (FileStream stream = File.OpenWrite(filePath))
                {
                    // If this is the trigger input, write it directly to the stream.
                    // The trigger binding is a special case because it is early bound
                    // rather than late bound as is the case with all the other input
                    // bindings.
                    if (inputBinding.Metadata.IsTrigger)
                    {
                        if (input is string)
                        {
                            using (StreamWriter sw = new StreamWriter(stream))
                            {
                                await sw.WriteAsync((string)input);
                            }
                        }
                        else if (input is byte[])
                        {
                            byte[] bytes = input as byte[];
                            await stream.WriteAsync(bytes, 0, bytes.Length);
                        }
                        else if (input is Stream)
                        {
                            Stream inputStream = input as Stream;
                            await inputStream.CopyToAsync(stream);
                        }
                    }
                    else
                    {
                        // invoke the input binding
                        BindingContext bindingContext = new BindingContext
                        {
                            Binder = binder,
                            BindingData = bindingData,
                            DataType = DataType.Stream,
                            Value = stream
                        };
                        await inputBinding.BindAsync(bindingContext);
                    }
                }

                environmentVariables[inputBinding.Metadata.Name] = Path.Combine(functionInstanceOutputPath,
                    inputBinding.Metadata.Name);
            }
        }
开发者ID:Azure,项目名称:azure-webjobs-sdk-script,代码行数:59,代码来源:ScriptFunctionInvokerBase.cs

示例8: AddAndCleanWebConfigModification

        /// <summary>
        /// Method to add one or multiple WebConfig modifications
        /// NOTE: There should not have 2 modifications with the same Owner.
        /// </summary>
        /// <param name="web">The current Web Application</param>
        /// <param name="webConfigModificationCollection">The collection of WebConfig modifications to remove-and-add</param>
        /// <remarks>All SPWebConfigModification Owner should be UNIQUE !</remarks>
        public void AddAndCleanWebConfigModification(SPWebApplication webApp, Collection<SPWebConfigModification> webConfigModificationCollection)
        {
            // Verify emptyness
            if (webConfigModificationCollection == null || !webConfigModificationCollection.Any())
            {
                throw new ArgumentNullException("webConfigModificationCollection");
            }

            SPWebApplication webApplication = SPWebService.ContentService.WebApplications[webApp.Id];

            // Start by cleaning up any existing modification for all owners
            foreach (var owner in webConfigModificationCollection.Select(modif => modif.Owner).Distinct())
            {
                // Remove all modification by the same owner.
                // By Good practice, owner should be unique, so we do this to remove duplicates entries if any.
                this.RemoveExistingModificationsFromOwner(webApplication, owner);
            }

            if (webApplication.Farm.TimerService.Instances.Count > 1)
            {
                // HACK:
                //
                // When there are multiple front-end Web servers in the
                // SharePoint farm, we need to wait for the timer job that
                // performs the Web.config modifications to complete before
                // continuing. Otherwise, we may encounter the following error
                // (e.g. when applying Web.config changes from two different
                // features in rapid succession):
                //
                // "A web configuration modification operation is already
                // running."
                WaitForOnetimeJobToFinish(
                   webApplication.Farm,
                   "Microsoft SharePoint Foundation Web.Config Update",
                   120);
            }

            // Add WebConfig modifications
            foreach (var webConfigModification in webConfigModificationCollection)
            {
                webApplication.WebConfigModifications.Add(webConfigModification);
            }

            // Commit modification additions to the specified web application
            webApplication.Update();

            // Push modifications through the farm
            webApplication.WebService.ApplyWebConfigModifications();

            if (webApplication.Farm.TimerService.Instances.Count > 1)
            {
                WaitForOnetimeJobToFinish(
                   webApplication.Farm,
                   "Microsoft SharePoint Foundation Web.Config Update",
                   120);
            }
        }
开发者ID:GAlexandreBastien,项目名称:Dynamite-2010,代码行数:64,代码来源:WebConfigModificationHelper.cs

示例9: ContainsAttribute

        private static bool ContainsAttribute(Collection<CustomAttribute> customAttributes, string attributeTypeName)
        {
            if (customAttributes == null)
            {
                return false;
            }

            return customAttributes.Any(x => x.AttributeType.FullName.Contains(attributeTypeName));
        }
开发者ID:Catel,项目名称:Catel.Fody,代码行数:9,代码来源:CecilExtensions.members.cs

示例10: GetCategoryAttributeValuesForMultiselect

        private CategoryAttributeValue GetCategoryAttributeValuesForMultiselect(CategoryAttribute attribute, AttributeValueModel attributeValue)
        {
            var selectedOptions = new Collection<CategoryAttributeOption>();
            for (var i = 0; i < attribute.Options.Count; i++)
                if (bool.Parse(attributeValue.Values[i]))
                    selectedOptions.Add(attribute.Options.ElementAt(i));

            return selectedOptions.Any() ? new CategoryAttributeValue { Attribute = attribute, SelectedOptions = selectedOptions } : null;
        }
开发者ID:bwrobel,项目名称:Experts,代码行数:9,代码来源:CategoryAttributeHelper.cs

示例11: AddEditorBrowsableAttribute

 void AddEditorBrowsableAttribute(Collection<CustomAttribute> customAttributes)
 {
     if (customAttributes.Any(x=>x.AttributeType.Name == "EditorBrowsableAttribute"))
     {
         return;
     }
     var customAttribute = new CustomAttribute(EditorBrowsableConstructor);
     customAttribute.ConstructorArguments.Add(new CustomAttributeArgument(EditorBrowsableStateType, AdvancedStateConstant));
     customAttributes.Add(customAttribute);
 }
开发者ID:mdabbagh88,项目名称:Publicize,代码行数:10,代码来源:TypeProcessor.cs

示例12: SubjectBuffersConnected

        public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
        {
            if (subjectBuffers.Any(b => b.ContentType.IsOfType(LiveScriptContentTypeDefinition.LiveScriptContentType)))
                return;

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);

            textView.Properties.GetOrCreateSingletonProperty(() => new EnterIndentation(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty(() => new CommentCommandTarget(textViewAdapter, textView, "#"));
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:10,代码来源:CoffeeScriptCreationListener.cs

示例13: SubjectBuffersConnected

        public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
        {
            if (!subjectBuffers.Any(b => b.ContentType.IsOfType("JSON")))
                return;

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);
            if (textViewAdapter == null)
                return;

            textView.Properties.GetOrCreateSingletonProperty<FormatCommandTarget>(() => new FormatCommandTarget(textViewAdapter, textView));
        }
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:11,代码来源:JsonCreationListener.cs

示例14: SubjectBuffersConnected

        public void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers)
        {
            if (!subjectBuffers.Any(b => b.ContentType.IsOfType(LessContentTypeDefinition.LessContentType)))
                return;

            var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);
            if (textViewAdapter == null)
                return;

            textView.Properties.GetOrCreateSingletonProperty<LessExtractVariableCommandTarget>(() => new LessExtractVariableCommandTarget(textViewAdapter, textView));
            textView.Properties.GetOrCreateSingletonProperty<LessExtractMixinCommandTarget>(() => new LessExtractMixinCommandTarget(textViewAdapter, textView));
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:12,代码来源:LessCreationListener.cs

示例15: SubjectBuffersConnected

		public async void SubjectBuffersConnected(IWpfTextView textView, ConnectionReason reason, Collection<ITextBuffer> subjectBuffers) {
			if (!subjectBuffers.Any(b => b.ContentType.IsOfType("CSharp") || b.ContentType.IsOfType("Basic")))
				return;

			// VS2010 only creates TextViewAdapters later; wait for it to exist.
			await Dispatcher.Yield();

			var textViewAdapter = EditorAdaptersFactoryService.GetViewAdapter(textView);
			if (textViewAdapter == null)
				return;
			ITextDocument document;
			if (!TextDocumentFactoryService.TryGetTextDocument(textView.TextDataModel.DocumentBuffer, out document))
				return;

			textView.Properties.GetOrCreateSingletonProperty(() => new GoToDefinitionInterceptor(ReferenceProviders, ServiceProvider, textViewAdapter, textView, document));
		}
开发者ID:sharwell,项目名称:Ref12,代码行数:16,代码来源:TextViewListener.cs


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