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


C# IEnumerable.AsArray方法代码示例

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


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

示例1: TypeMetric

		public TypeMetric(
			bool isAbstract,
			TypeMetricKind kind,
			AccessModifierKind accessModifier,
			IEnumerable<IMemberMetric> memberMetrics,
			int linesOfCode,
			int cyclomaticComplexity,
			double maintainabilityIndex,
			int depthOfInheritance,
			IEnumerable<ITypeCoupling> classCouplings,
			string name,
			int afferentCoupling,
			int efferentCoupling,
			double instability,
			ITypeDocumentation documentation)
		{
			IsAbstract = isAbstract;
			Kind = kind;
			AccessModifier = accessModifier;
			MemberMetrics = memberMetrics;
			LinesOfCode = linesOfCode;
			CyclomaticComplexity = cyclomaticComplexity;
			MaintainabilityIndex = maintainabilityIndex;
			DepthOfInheritance = depthOfInheritance;
			ClassCouplings = classCouplings.AsArray();
			Name = name;
			AfferentCoupling = afferentCoupling;
			EfferentCoupling = efferentCoupling;
			Instability = instability;
			Documentation = documentation;
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:31,代码来源:TypeMetric.cs

示例2: CalculateFrom

		public async Task<ITypeMetric> CalculateFrom(TypeDeclarationSyntaxInfo typeNode, IEnumerable<IMemberMetric> metrics)
		{
			var memberMetrics = metrics.AsArray();
			var type = typeNode.Syntax;
			var symbol = Model.GetDeclaredSymbol(type);
			var documentation = await _documentationFactory.Create(symbol, CancellationToken.None);
			var metricKind = GetMetricKind(type);
			var source = CalculateClassCoupling(type, memberMetrics);
			var depthOfInheritance = CalculateDepthOfInheritance(type);
			var cyclomaticComplexity = memberMetrics.Sum(x => x.CyclomaticComplexity);
			var linesOfCode = memberMetrics.Sum(x => x.LinesOfCode);
			var maintainabilityIndex = CalculateAveMaintainabilityIndex(memberMetrics);
			var afferentCoupling = await CalculateAfferentCoupling(type);
			var efferentCoupling = GetEfferentCoupling(type, symbol);
			var instability = (double)efferentCoupling / (efferentCoupling + afferentCoupling);
			var modifier = GetAccessModifier(type.Modifiers);
			return new TypeMetric(
				symbol.IsAbstract,
				metricKind,
				modifier,
				memberMetrics,
				linesOfCode,
				cyclomaticComplexity,
				maintainabilityIndex,
				depthOfInheritance,
				source,
				type.GetName(),
				afferentCoupling,
				efferentCoupling,
				instability,
				documentation);
		}
开发者ID:jjrdk,项目名称:ArchiMetrics,代码行数:32,代码来源:TypeMetricsCalculator.cs

示例3: CalculateFrom

		public INamespaceMetric CalculateFrom(NamespaceDeclarationSyntaxInfo namespaceNode, IEnumerable<ITypeMetric> metrics)
		{
			const string DocumentationTypeName = "NamespaceDoc";
			var typeMetrics = metrics.AsArray();
			var documentationType = typeMetrics.FirstOrDefault(x => x.Name == DocumentationTypeName);
			IDocumentation documentation = null;
			if (documentationType != null)
			{
				documentation = documentationType.Documentation;
				typeMetrics = typeMetrics.Where(x => x.Name != DocumentationTypeName).AsArray();
			}

			var linesOfCode = typeMetrics.Sum(x => x.LinesOfCode);
			var source = typeMetrics.SelectMany(x => x.ClassCouplings)
						  .GroupBy(x => x.ToString())
						  .Select(x => new TypeCoupling(x.First().TypeName, x.First().Namespace, x.First().Assembly, x.SelectMany(y => y.UsedMethods), x.SelectMany(y => y.UsedProperties), x.SelectMany(y => y.UsedEvents)))
						  .Where(x => x.Namespace != namespaceNode.Name)
						  .OrderBy(x => x.Assembly + x.Namespace + x.TypeName)
						  .AsArray();
			var maintainabilitySource = typeMetrics.Select(x => new Tuple<int, double>(x.LinesOfCode, x.MaintainabilityIndex)).AsArray();
			var maintainabilityIndex = linesOfCode > 0 && maintainabilitySource.Any() ? maintainabilitySource.Sum(x => x.Item1 * x.Item2) / linesOfCode : 100.0;
			var cyclomaticComplexity = typeMetrics.Sum(x => x.CyclomaticComplexity);
			var depthOfInheritance = typeMetrics.Any() ? typeMetrics.Max(x => x.DepthOfInheritance) : 0;
			return new NamespaceMetric(
				maintainabilityIndex,
				cyclomaticComplexity,
				linesOfCode,
				source,
				depthOfInheritance,
				namespaceNode.Name,
				typeMetrics,
				documentation);
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:33,代码来源:NamespaceMetricsCalculator.cs

示例4: MemberMetric

		public MemberMetric(
			string codeFile,
			AccessModifierKind accessModifier,
			IHalsteadMetrics halstead,
			int lineNumber,
			int linesOfCode,
			double maintainabilityIndex,
			int cyclomaticComplexity,
			string name,
			IEnumerable<ITypeCoupling> classCouplings,
			int numberOfParameters,
			int numberOfLocalVariables,
			int afferentCoupling,
			IMemberDocumentation documentation)
		{
			_halstead = halstead;
			CodeFile = codeFile;
			AccessModifier = accessModifier;
			LineNumber = lineNumber;
			LinesOfCode = linesOfCode;
			MaintainabilityIndex = maintainabilityIndex;
			CyclomaticComplexity = cyclomaticComplexity;
			Name = name;
			ClassCouplings = classCouplings.AsArray();
			NumberOfParameters = numberOfParameters;
			NumberOfLocalVariables = numberOfLocalVariables;
			AfferentCoupling = afferentCoupling;
			Documentation = documentation;
		}
开发者ID:jjrdk,项目名称:ArchiMetrics,代码行数:29,代码来源:MemberMetric.cs

示例5: TypeDocumentation

		public TypeDocumentation(string summary, string code, string example, string remarks, string returns, IEnumerable<TypeParameterDocumentation> typeParameters)
		{
			Summary = summary;
			Code = code;
			Example = example;
			Remarks = remarks;
			Returns = returns;
			TypeParameters = typeParameters.AsArray();
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:9,代码来源:TypeDocumentation.cs

示例6: ExportsChangeEventArgs

        /// <summary>
        ///     Initializes a new instance of the <see cref="ExportsChangeEventArgs"/> class with 
        ///     the specified changed export definitions.
        /// </summary>
        /// <param name="addedExports">
        ///     An <see cref="IEnumerable{T}"/> of <see cref="ExportDefinition"/>s of the exports
        ///     that have been added.
        /// </param>
        /// <param name="removedExports">
        ///     An <see cref="IEnumerable{T}"/> of <see cref="ExportDefinition"/>s of the exports
        ///     that have been removed.
        /// </param>
        /// <param name="atomicComposition">
        ///     A <see cref="AtomicComposition"/> representing all tentative changes that will
        ///     be completed if the change is successful, or discarded if it is not. 
        ///     <see langword="null"/> if being applied outside a <see cref="AtomicComposition"/> 
        ///     or during a <see cref="ExportProvider.ExportsChanged"/> event.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="addedExports"/> or <paramref name="removedExports"/> is <see langword="null"/>.
        /// </exception>
        public ExportsChangeEventArgs(IEnumerable<ExportDefinition> addedExports,
                IEnumerable<ExportDefinition> removedExports, AtomicComposition atomicComposition)
        {
            Requires.NotNull(addedExports, "addedExports");
            Requires.NotNull(removedExports, "removedExports");

            this.AddedExports = addedExports.AsArray();
            this.RemovedExports = removedExports.AsArray();
            this.AtomicComposition = atomicComposition;
        }
开发者ID:nlhepler,项目名称:mono,代码行数:31,代码来源:ExportsChangeEventArgs.cs

示例7: ComposablePartCatalogChangeEventArgs

        /// <summary>
        ///     Initializes a new instance of the <see cref="ComposablePartCatalogChangeEventArgs"/>.
        /// </summary>
        /// <param name="addedDefinitions">
        ///     An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that 
        ///     are being added to the <see cref="ComposablePartCatalog"/>.
        /// </param>
        /// <param name="removedDefinitions">
        ///     An <see cref="IEnumerable{T}"/> of <see cref="ComposablePartDefinition"/> objects that 
        ///     are being removed from the <see cref="ComposablePartCatalog"/>.
        /// </param>
        /// <param name="atomicComposition">
        ///     A <see cref="AtomicComposition"/> representing all tentative changes that will
        ///     be completed if the change is successful, or discarded if it is not. 
        ///     <see langword="null"/> if being applied outside a <see cref="AtomicComposition"/> 
        ///     or during a <see cref="INotifyComposablePartCatalogChanged.Changed"/> event.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     <paramref name="addedDefinitions"/> or <paramref name="removedDefinitions"/> is <see langword="null"/>.
        /// </exception>
        public ComposablePartCatalogChangeEventArgs(IEnumerable<ComposablePartDefinition> addedDefinitions,
            IEnumerable<ComposablePartDefinition> removedDefinitions, AtomicComposition atomicComposition)
        {
            Requires.NotNull(addedDefinitions, "addedDefinitions");
            Requires.NotNull(removedDefinitions, "removedDefinitions");

            this.AddedDefinitions = addedDefinitions.AsArray();
            this.RemovedDefinitions = removedDefinitions.AsArray();
            this.AtomicComposition = atomicComposition;
        }
开发者ID:Ginichen,项目名称:Silverlight-Player-for-PlayReady-with-Token-Auth,代码行数:30,代码来源:ComposablePartCatalogChangeEventArgs.cs

示例8: Calculate

		public async Task<IEnumerable<INamespaceMetric>> Calculate(IEnumerable<SyntaxTree> syntaxTrees, params Assembly[] references)
		{
			var trees = syntaxTrees.AsArray();
			var declarations = _syntaxCollector.GetDeclarations(trees);
			var statementMembers = declarations.Statements.Select(s =>
				s is StatementSyntax
				? SyntaxFactory.MethodDeclaration(
					SyntaxFactory.PredefinedType(SyntaxFactory.Token(SyntaxKind.VoidKeyword)),
					Guid.NewGuid().ToString("N"))
					.WithBody(SyntaxFactory.Block((StatementSyntax)s))
					: s);
			var members = declarations.MemberDeclarations.Concat(statementMembers).AsArray();
			var anonClass = members.Any()
								? new[]
                                  {
                                      SyntaxFactory.ClassDeclaration(
                                          "UnnamedClass")
                                          .WithModifiers(
                                              SyntaxFactory.TokenList(SyntaxFactory.Token(SyntaxKind.PublicKeyword)))
                                          .WithMembers(SyntaxFactory.List(members))
                                  }
								: new TypeDeclarationSyntax[0];
			var array = declarations.TypeDeclarations
				.Concat(anonClass)
				.Cast<MemberDeclarationSyntax>()
				.AsArray();
			var anonNs = array.Any()
				? new[]
                          {
                              SyntaxFactory.NamespaceDeclaration(SyntaxFactory.ParseName("Unnamed"))
                                  .WithMembers(SyntaxFactory.List(array))
                          }
				: new NamespaceDeclarationSyntax[0];
			var namespaceDeclarations = declarations
				.NamespaceDeclarations
				.Concat(anonNs)
				.Select(x => new NamespaceDeclarationSyntaxInfo
				{
					Name = x.GetName(x),
					Syntax = x
				})
				.GroupBy(x => x.Name)
				.Select(g => new NamespaceDeclaration
				{
					Name = g.Key,
					SyntaxNodes = g.AsArray()
				})
				.AsArray();

			var metadataReferences =
				(references.Any() ? references : new[] { typeof(object).Assembly }).Select(a => MetadataReference.CreateFromFile(a.Location)).ToArray();
			var commonCompilation = CSharpCompilation.Create("x", syntaxTrees: trees, references: metadataReferences);
			var namespaceMetrics = await CalculateNamespaceMetrics(namespaceDeclarations, commonCompilation, null).ConfigureAwait(false);
			return namespaceMetrics;
		}
开发者ID:jjrdk,项目名称:ArchiMetrics,代码行数:55,代码来源:CodeMetricsCalculator.cs

示例9: MemberDocumentation

		public MemberDocumentation(string summary, string code, string example, string remarks, string returns, IEnumerable<TypeParameterDocumentation> typeParameters, IEnumerable<ParameterDocumentation> parameters, IEnumerable<ExceptionDocumentation> exceptions)
		{
			Summary = summary;
			Code = code;
			Example = example;
			Remarks = remarks;
			Returns = returns;
			TypeParameters = typeParameters.AsArray();
			Parameters = parameters.AsArray();
			Exceptions = exceptions.AsArray();
		}
开发者ID:jjrdk,项目名称:ArchiMetrics,代码行数:11,代码来源:MemberDocumentation.cs

示例10: Transform

		public Task<IEnumerable<IModelNode>> Transform(IEnumerable<IModelNode> source, IEnumerable<TransformRule> rules, CancellationToken cancellationToken)
		{
			return Task.Factory.StartNew(
				() =>
				{
					var allRules = rules.AsArray();
					var transformedVertices = from vertex in source
											  select TransformVertexRecursive(vertex, allRules);

					return transformedVertices.AsArray().AsEnumerable();
				}, 
				cancellationToken);
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:13,代码来源:SyntaxTransformer.cs

示例11: HttpDirectRoute

 /// <summary>
 /// Initializes a new instance of the <see cref="HttpDirectRoute" /> class.
 /// </summary>
 /// <param name="routeTemplate">The route template.</param>
 /// <param name="defaults">The default values.</param>
 /// <param name="constraints">The route constraints.</param>
 /// <param name="actions">The actions that are reachable via this route.</param>
 public HttpDirectRoute(
     string routeTemplate,
     HttpRouteValueDictionary defaults,
     HttpRouteValueDictionary constraints,
     IEnumerable<ReflectedHttpActionDescriptor> actions)
     : base(routeTemplate, defaults: defaults, constraints: constraints, dataTokens: null, handler: null)
 {
     if (actions != null)
     {
         Actions = actions.AsArray();
         DataTokens[RouteKeys.ActionsDataTokenKey] = Actions;
     }
 }
开发者ID:RhysC,项目名称:aspnetwebstack,代码行数:20,代码来源:HttpDirectRoute.cs

示例12: GetDeclarations

		public SyntaxDeclarations GetDeclarations(IEnumerable<SyntaxTree> trees)
		{
			var syntaxTrees = trees.AsArray();

			foreach (var root in syntaxTrees.Select(syntaxTree => syntaxTree.GetRoot()))
			{
				Visit(root);
				CheckStatementSyntax(root);
			}

			return new SyntaxDeclarations
			{
				MemberDeclarations = _members.AsArray(),
				NamespaceDeclarations = _namespaces.AsArray(),
				Statements = _statements.AsArray(),
				TypeDeclarations = _types.AsArray()
			};
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:18,代码来源:SyntaxCollector.cs

示例13: ProjectMetric

		public ProjectMetric(string name, IEnumerable<INamespaceMetric> namespaceMetrics, IEnumerable<string> referencedProjects, double relationalCohesion)
		{
			Name = name;
			RelationalCohesion = relationalCohesion;
			Dependencies = referencedProjects.AsArray();
			EfferentCoupling = Dependencies.Count();
			NamespaceMetrics = namespaceMetrics.AsArray();
			LinesOfCode = NamespaceMetrics.Sum(x => x.LinesOfCode);
			MaintainabilityIndex = LinesOfCode == 0 ? 100 : NamespaceMetrics.Sum(x => x.MaintainabilityIndex * x.LinesOfCode) / LinesOfCode;
			CyclomaticComplexity = LinesOfCode == 0 ? 0 : NamespaceMetrics.Sum(x => x.CyclomaticComplexity * x.LinesOfCode) / LinesOfCode;
			ClassCouplings = NamespaceMetrics.SelectMany(x => x.ClassCouplings).Where(x => x.Assembly != Name).Distinct(Comparer).AsArray();
			Dependendants = ClassCouplings.Select(x => x.Assembly)
				.Distinct()
				.AsArray();
			AfferentCoupling = Dependendants.Count();
			var typeMetrics = NamespaceMetrics.SelectMany(x => x.TypeMetrics).AsArray();
			Abstractness = typeMetrics.Count(x => x.IsAbstract) / (double)typeMetrics.Count();
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:18,代码来源:ProjectMetric.cs

示例14: NamespaceMetric

		public NamespaceMetric(
			double maintainabilityIndex,
			int cyclomaticComplexity,
			int linesOfCode,
			IEnumerable<ITypeCoupling> classCouplings,
			int depthOfInheritance,
			string name,
			IEnumerable<ITypeMetric> typeMetrics,
			IDocumentation documentation)
		{
			MaintainabilityIndex = maintainabilityIndex;
			CyclomaticComplexity = cyclomaticComplexity;
			LinesOfCode = linesOfCode;
			ClassCouplings = classCouplings;
			DepthOfInheritance = depthOfInheritance;
			Name = name;
			Documentation = documentation;
			TypeMetrics = typeMetrics.AsArray();
			Abstractness = TypeMetrics.Count(x => x.IsAbstract) / (double)TypeMetrics.Count();
		}
开发者ID:henrylle,项目名称:ArchiMetrics,代码行数:20,代码来源:NamespaceMetric.cs

示例15: BuildHttpRoute

        /// <summary>
        /// Builds an <see cref="IHttpRoute"/> for a particular action.
        /// </summary>
        /// <param name="routeTemplate">The tokenized route template for the route.</param>
        /// <param name="httpMethods">The HTTP methods supported by the route.</param>
        /// <param name="actions">The actions to invoke for the route.</param>
        /// <returns>The generated <see cref="IHttpRoute"/>.</returns>
        public virtual IHttpRoute BuildHttpRoute(
            string routeTemplate,
            IEnumerable<HttpMethod> httpMethods,
            IEnumerable<ReflectedHttpActionDescriptor> actions)
        {
            if (routeTemplate == null)
            {
                throw Error.ArgumentNull("routeTemplate");
            }

            HttpRouteValueDictionary defaults = new HttpRouteValueDictionary();
            HttpRouteValueDictionary constraints = new HttpRouteValueDictionary();
            if (httpMethods != null)
            {
                // Current method constraint implementation is inefficient since it matches before running the constraint.
                // Consider checking the HTTP method first in a custom route as a performance optimization.
                constraints["httpMethod"] = new HttpMethodConstraint(httpMethods.AsArray());
            }

            string detokenizedRouteTemplate = InlineRouteTemplateParser.ParseRouteTemplate(routeTemplate, defaults, constraints, ConstraintResolver);

            return BuildHttpRoute(detokenizedRouteTemplate, defaults, constraints, actions);
        }
开发者ID:RhysC,项目名称:aspnetwebstack,代码行数:30,代码来源:HttpRouteBuilder.cs


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