本文整理汇总了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();
}
示例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();
}
示例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;
}