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


C# ReadOnlyCollection.SelectMany方法代码示例

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


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

示例1: Types

 static Types()
 {
     _opaque = new Type[]{TypeName.Texref, TypeName.Samplerref, TypeName.Surfref}.ToReadOnly();
     _other = new Type[]{TypeName.Pred, TypeName.Ptr, TypeName.Bmk}.ToReadOnly();
     _scalar = Enum.GetValues(typeof(TypeName)).Cast<TypeName>().Select(t => (Type)t).Except(_opaque, _other).ToReadOnly();
     _vector = _scalar.SelectMany(t => new[] { t.v1, t.v2, t.v4 }).Where(t => t.SizeOfElement <= 128 / 8).ToReadOnly();
 }
开发者ID:xeno-by,项目名称:libptx,代码行数:7,代码来源:Types.cs

示例2: RewriteTargetMatcher

        public RewriteTargetMatcher(IMethodImporter methodImporter, ReadOnlyCollection<IRewriteTarget> targets)
        {
            ArgumentChecker.NotNull(methodImporter, () => methodImporter);
            ArgumentChecker.NotNull(targets, () => targets);

            _targets = targets
                .SelectMany(target => target.Methods, (target, method) => Tuple.Create(target, methodImporter.Import(method)))
                .ToList();
        }
开发者ID:yeswanthepuri,项目名称:Smocks,代码行数:9,代码来源:RewriteTargetMatcher.cs

示例3: Build

        /// <summary>
        /// Builds the EF-specific view of the current semantic model
        /// </summary>
        /// <returns>false if no DbContext or known entity types were discovered, true otherwise</returns>
        public bool Build()
        {
            //Bail immediately if EntityFramework is not referenced
            if (!_context.SemanticModel
                         .Compilation
                         .ReferencedAssemblyNames
                         .Any(asm => asm.Name == "EntityFramework" 
                                  && asm.Version.Major == 6))
            {
                return false;
            }
            
            var typeSymbols = _context.SemanticModel
                                      .LookupSymbols(_context.Node
                                                             .GetLocation()
                                                             .SourceSpan
                                                             .Start)
                                      .OfType<INamedTypeSymbol>();

            var symbols = typeSymbols.Where(t => t.UltimatelyDerivesFromDbContext());

            _dbContextSymbols = new ReadOnlyCollection<INamedTypeSymbol>(symbols.ToList());

            if (_dbContextSymbols.Count == 0)
                return false;

            //TODO: Need to follow any related types that hang off of the primary entities (referenced via DbSet<T>)
            var entityTypes = _dbContextSymbols.SelectMany(dbc =>
            {
                var dbSetProps = dbc.GetMembers()
                    .Where(m => m.Kind == SymbolKind.Property)
                    .Cast<IPropertySymbol>()
                    .Where(t => t.IsDbSetProperty());

                return dbSetProps;
            })
            .Select(p => p.Type)
            .OfType<INamedTypeSymbol>()
            .Where(t => t.TypeArguments.Length == 1)
            .Select(t => t.TypeArguments.First())
            .OfType<INamedTypeSymbol>();

            _entityTypeSymbols = new ReadOnlyCollection<INamedTypeSymbol>(entityTypes.ToList());

            _clsInfo = new Dictionary<ITypeSymbol, EFCodeFirstClassInfo>();
            _propertiesToCls = new Dictionary<string, List<EFCodeFirstClassInfo>>();
            foreach (var clsSymbol in _entityTypeSymbols)
            {
                var clsSymbols = clsSymbol.GetMembers()
                                              .Where(m => m.Kind == SymbolKind.Property)
                                              .Cast<IPropertySymbol>();
                var clsInfo = new EFCodeFirstClassInfo(clsSymbol);
                clsInfo.AddProperties(clsSymbols, (sym) =>
                {
                    if (!_propertiesToCls.ContainsKey(sym.Name))
                        _propertiesToCls[sym.Name] = new List<EFCodeFirstClassInfo>();
                    _propertiesToCls[sym.Name].Add(clsInfo);
                });

                _clsInfo[clsSymbol] = clsInfo;
            }
            return _clsInfo.Count > 0;
        }
开发者ID:jumpinjackie,项目名称:roslyn-ef-linq-analyzer,代码行数:67,代码来源:EFUsageContext.cs


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