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


C# ImmutableArray.Count方法代码示例

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


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

示例1: BuildText

        private string BuildText(ImmutableArray<Todo> todos)
        {
            if (!todos.Any()) return string.Empty;

            if (todos.Count() == 1) return "1 item left";

            return $"{todos.Count()} items left";
        }
开发者ID:autechr3,项目名称:redux.NET,代码行数:8,代码来源:Footer.cs

示例2: SequnceStartsWith

            private bool SequnceStartsWith(ImmutableArray<string> header, List<string> existingHeader)
            {
                // Only try if the existing header is at least as long as the new copyright header
                if (existingHeader.Count >= header.Count())
                {
                    return !header.Where((headerLine, i) => existingHeader[i] != headerLine).Any();
                }

                return false;
            }
开发者ID:chuck-mitchell,项目名称:codeformatter,代码行数:10,代码来源:CopyrightHeaderRule.cs

示例3: CompileGetLocals

        /// <summary>
        /// Generate a class containing methods that represent
        /// the set of arguments and locals at the current scope.
        /// </summary>
        internal CommonPEModuleBuilder CompileGetLocals(
            string typeName,
            ArrayBuilder<LocalAndMethod> localBuilder,
            bool argumentsOnly,
            ImmutableArray<Alias> aliases,
            Microsoft.CodeAnalysis.CodeGen.CompilationTestData testData,
            DiagnosticBag diagnostics)
        {
            var objectType = this.Compilation.GetSpecialType(SpecialType.System_Object);
            var allTypeParameters = _currentFrame.GetAllTypeParameters();
            var additionalTypes = ArrayBuilder<NamedTypeSymbol>.GetInstance();

            EENamedTypeSymbol typeVariablesType = null;
            if (!argumentsOnly && (allTypeParameters.Length > 0))
            {
                // Generate a generic type with matching type parameters.
                // A null instance of the type will be used to represent the
                // "Type variables" local.
                typeVariablesType = new EENamedTypeSymbol(
                    this.Compilation.SourceModule.GlobalNamespace,
                    objectType,
                    _syntax,
                    _currentFrame,
                    ExpressionCompilerConstants.TypeVariablesClassName,
                    (m, t) => ImmutableArray.Create<MethodSymbol>(new EEConstructorSymbol(t)),
                    allTypeParameters,
                    (t1, t2) => allTypeParameters.SelectAsArray((tp, i, t) => (TypeParameterSymbol)new SimpleTypeParameterSymbol(t, i, tp.Name), t2));
                additionalTypes.Add(typeVariablesType);
            }

            var synthesizedType = new EENamedTypeSymbol(
                Compilation.SourceModule.GlobalNamespace,
                objectType,
                _syntax,
                _currentFrame,
                typeName,
                (m, container) =>
                {
                    var methodBuilder = ArrayBuilder<MethodSymbol>.GetInstance();

                    if (!argumentsOnly)
                    {
                        // Pseudo-variables: $exception, $ReturnValue, etc.
                        if (aliases.Length > 0)
                        {
                            var sourceAssembly = Compilation.SourceAssembly;
                            var typeNameDecoder = new EETypeNameDecoder(Compilation, (PEModuleSymbol)_currentFrame.ContainingModule);
                            foreach (var alias in aliases)
                            {
                                if (alias.IsReturnValueWithoutIndex())
                                {
                                    Debug.Assert(aliases.Count(a => a.Kind == DkmClrAliasKind.ReturnValue) > 1);
                                    continue;
                                }

                                var local = PlaceholderLocalSymbol.Create(
                                    typeNameDecoder,
                                    _currentFrame,
                                    sourceAssembly,
                                    alias);
                                var methodName = GetNextMethodName(methodBuilder);
                                var syntax = SyntaxFactory.IdentifierName(SyntaxFactory.MissingToken(SyntaxKind.IdentifierToken));
                                var aliasMethod = this.CreateMethod(container, methodName, syntax, (method, diags) =>
                                {
                                    var expression = new BoundLocal(syntax, local, constantValueOpt: null, type: local.Type);
                                    return new BoundReturnStatement(syntax, expression) { WasCompilerGenerated = true };
                                });
                                var flags = local.IsWritable ? DkmClrCompilationResultFlags.None : DkmClrCompilationResultFlags.ReadOnlyResult;
                                localBuilder.Add(MakeLocalAndMethod(local, aliasMethod, flags));
                                methodBuilder.Add(aliasMethod);
                            }
                        }

                        // "this" for non-static methods that are not display class methods or
                        // display class methods where the display class contains "<>4__this".
                        if (!m.IsStatic && (!IsDisplayClassType(m.ContainingType) || _displayClassVariables.ContainsKey(GeneratedNames.ThisProxyFieldName())))
                        {
                            var methodName = GetNextMethodName(methodBuilder);
                            var method = this.GetThisMethod(container, methodName);
                            localBuilder.Add(new CSharpLocalAndMethod("this", "this", method, DkmClrCompilationResultFlags.None)); // Note: writable in dev11.
                            methodBuilder.Add(method);
                        }
                    }

                    // Hoisted method parameters (represented as locals in the EE).
                    if (!_hoistedParameterNames.IsEmpty)
                    {
                        int localIndex = 0;
                        foreach (var local in _localsForBinding)
                        {
                            // Since we are showing hoisted method parameters first, the parameters may appear out of order
                            // in the Locals window if only some of the parameters are hoisted.  This is consistent with the
                            // behavior of the old EE.
                            if (_hoistedParameterNames.Contains(local.Name))
                            {
                                AppendLocalAndMethod(localBuilder, methodBuilder, local, container, localIndex, GetLocalResultFlags(local));
//.........这里部分代码省略.........
开发者ID:rgani,项目名称:roslyn,代码行数:101,代码来源:CompilationContext.cs

示例4: HasIgnorableAttributes

        private static Boolean HasIgnorableAttributes(ImmutableArray<AttributeData> attributes) {
            for (Int32 i = 0; i < attributes.Count(); i++) {
                AttributeData attr = attributes[i];
                if ((attr.AttributeClass.IsType(typeof(GeneratedCodeAttribute)) ||
                    (attr.AttributeClass.IsType(typeof(DebuggerNonUserCodeAttribute))))) {
                    return true;
                }
            }

            return false;
        }
开发者ID:vuder,项目名称:CodingStandardCodeAnalyzers,代码行数:11,代码来源:SymbolExtensions.cs

示例5: ArrayCreation

 public ArrayCreation(IArrayTypeSymbol arrayType, ImmutableArray<IExpression> elementValues, SyntaxNode syntax)
 {
     _arrayType = arrayType;
     this.DimensionSizes = ImmutableArray.Create<IExpression>(new IntegerLiteral(elementValues.Count(), null, syntax));
     this.ElementValues = new DimensionInitializer(elementValues);
     this.Syntax = syntax;
 }
开发者ID:SoumikMukherjeeDOTNET,项目名称:roslyn,代码行数:7,代码来源:Expression.cs

示例6: WithInheritsFrom

 private static ImmutableArray<SymbolDisplayPart> WithInheritsFrom(ImmutableArray<SymbolDisplayPart> defaultParts, IEnumerable<SymbolDisplayPart> inheritanceSuffix)
 {
     var spaceBeforeFirstTypeConstraint = defaultParts.IndexOf(new SymbolDisplayPart(SymbolDisplayPartKind.Keyword, null, "where")) - 1;
     var locationToInsert = spaceBeforeFirstTypeConstraint >= 0 ? spaceBeforeFirstTypeConstraint : defaultParts.Count();
     return defaultParts.InsertRange(locationToInsert, inheritanceSuffix);
 }
开发者ID:GrahamTheCoder,项目名称:Semver-AssemblyCompatibility,代码行数:6,代码来源:SymbolFormatter.cs

示例7: MakeTempsForDiscardArguments

        internal ImmutableArray<BoundExpression> MakeTempsForDiscardArguments(ImmutableArray<BoundExpression> arguments, ArrayBuilder<LocalSymbol> builder)
        {
            var discardsCount = arguments.Count(a => a.Kind == BoundKind.DiscardedExpression);

            if (discardsCount != 0)
            {
                arguments = arguments.SelectAsArray(
                    (arg, t) => arg.Kind == BoundKind.DiscardedExpression ?  t.Item1.MakeTempForDiscard((BoundDiscardedExpression)arg, t.Item2) : arg,
                    ValueTuple.Create(this, builder));
            }

            return arguments;
        }
开发者ID:TyOverby,项目名称:roslyn,代码行数:13,代码来源:SyntheticBoundNodeFactory.cs

示例8: MakeTempsForDiscardArguments

        internal ImmutableArray<BoundExpression> MakeTempsForDiscardArguments(ImmutableArray<BoundExpression> arguments, ArrayBuilder<LocalSymbol> builder)
        {
            var discardsCount = arguments.Count(a => a.Kind == BoundKind.DiscardExpression);

            if (discardsCount != 0)
            {
                arguments = arguments.SelectAsArray(
                    (arg, t) => arg.Kind == BoundKind.DiscardExpression ?  t.factory.MakeTempForDiscard((BoundDiscardExpression)arg, t.builder) : arg,
                    (factory: this, builder: builder));
            }

            return arguments;
        }
开发者ID:XieShuquan,项目名称:roslyn,代码行数:13,代码来源:SyntheticBoundNodeFactory.cs

示例9: GetActiveTodosCounterMessage

 private string GetActiveTodosCounterMessage(ImmutableArray<Todo> todos)
 {
     var activeTodoCount = todos.Count(todo => !todo.IsCompleted);
     var itemWord = activeTodoCount <= 1 ? "item" : "items";
     return activeTodoCount + " " + itemWord + " left";
 }
开发者ID:rid00z,项目名称:redux.NET,代码行数:6,代码来源:Footer.xaml.cs

示例10: MakeTempsForDiscardArguments

        /// <summary>
        /// If there are any discards in the arguments, create locals for each, updates the arguments and
        /// returns the symbols that were created.
        /// Returns default if no discards found.
        /// </summary>
        private ImmutableArray<LocalSymbol> MakeTempsForDiscardArguments(ref ImmutableArray<BoundExpression> loweredArguments)
        {
            int discardCount = loweredArguments.Count(a => a.Kind == BoundKind.DiscardedExpression);

            if (discardCount == 0)
            {
                return ImmutableArray<LocalSymbol>.Empty;
            }

            ArrayBuilder<LocalSymbol> temporariesBuilder = ArrayBuilder<LocalSymbol>.GetInstance(discardCount);
            loweredArguments = _factory.MakeTempsForDiscardArguments(loweredArguments, temporariesBuilder);
            return temporariesBuilder.ToImmutableAndFree();
        }
开发者ID:GuilhermeSa,项目名称:roslyn,代码行数:18,代码来源:LoweredDynamicOperationFactory.cs

示例11: CreateInvocableCompletionGroup

        private static CompletionItem CreateInvocableCompletionGroup(ImmutableArray<Symbol> symbols)
        {
            var symbol = symbols.First();
            var first = CreateSymbolCompletion(symbol);
            var numberOfOverloads = symbols.Count() - 1;

            var displayText = first.DisplayText;
            var insertionText = first.InsertionText;
            var description = string.Format(Resources.CompletionItemWithOverloads, first.Description, numberOfOverloads);
            if (!string.IsNullOrEmpty(symbol.Documentation))
                description += Environment.NewLine + symbol.Documentation;
            var glyph = first.Glyph;
            return new CompletionItem(displayText, insertionText, description, glyph, symbol);
        }
开发者ID:Samana,项目名称:HlslTools,代码行数:14,代码来源:SymbolCompletionProvider.cs


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