本文整理汇总了C#中IEnumerable.?.Select方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.?.Select方法的具体用法?C# IEnumerable.?.Select怎么用?C# IEnumerable.?.Select使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.?.Select方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetEnsuredBlogKeys
public ICollection<string> GetEnsuredBlogKeys(IEnumerable<string> blogKeys)
{
var blogKeyList = blogKeys?.Select(x => new BlogKey(x));
var ensuredBlogKeys = this.GetEnsuredBlogKeys(blogKeyList);
return ensuredBlogKeys;
}
示例2: MappedDrift
static public IEnumerable<MeasurementBound1DIntAtTime> MappedDrift(
IEnumerable<MeasurementBound1DIntAtTime> Source,
Int64 DriftTimeFixed,
Int64 DriftNano) =>
Source
?.Select(BoundPreDrift =>
BoundPreDrift.BoundOffset((Int64)(((BoundPreDrift.Time - DriftTimeFixed) * BoundPreDrift.Bound * DriftNano) / 1e+9)));
示例3: CreateSuperhero
public Superhero CreateSuperhero(string superheroName, string secretIdentity, string cityName, IEnumerable<string> powerNames)
{
if (string.IsNullOrEmpty(superheroName) ||
superheroName.Length < MinSuperheroNameLength ||
superheroName.Length > MaxSuperherNameLength)
{
throw new ArgumentException("Invalid supehero name");
}
var superhero = new Superhero
{
SuperheroName = superheroName,
SecretIdentity = secretIdentity,
City = this.LoadOrCreateCity(cityName),
Powers = powerNames?.Select(this.LoadOrCreatePower)
.ToList()
};
using (this.unitOfWork)
{
this.superheroes.Add(superhero);
this.unitOfWork.Commit();
}
return superhero;
}
示例4: GenericDataValueProvider
public GenericDataValueProvider(System.Reflection.MemberInfo member, IValueProvider inner, IEnumerable<string> sensitiveProperties)
{
if (member == null) throw new ArgumentNullException("member");
if (inner == null) throw new ArgumentNullException("inner");
Member = member;
Inner = inner;
SensitiveProperties = sensitiveProperties?.Select(p => p.ToLowerInvariant());
}
示例5: CreateUserDto
public static UserDto CreateUserDto(this User user, IEnumerable<Login> logins)
{
var userDto = user.CreateUserDto();
userDto.Logins = logins?.Select(CreateLoginDto).ToArray() ?? new LoginDto[0];
return userDto;
}
示例6: Pkcs7EncryptionHandler
/// <summary>
/// Initialisiert eine neue Instanz der <see cref="Pkcs7EncryptionHandler"/> Klasse.
/// </summary>
/// <param name="senderCertificate">Das X509-Zertifikat des Absenders (PKCS#12)</param>
/// <param name="receiverCertificate">Das X509-Zertifikat des Empfängers</param>
/// <param name="oldSenderCertificates">Die abgelaufenen X509-Zertifikate des Absenders</param>
public Pkcs7EncryptionHandler(X509Certificate2 senderCertificate, X509Certificate2 receiverCertificate, IEnumerable<X509Certificate2> oldSenderCertificates = null)
{
#if NET45
_encryptionHandler = new NativePkcs7EncryptionHandler(senderCertificate, receiverCertificate, oldSenderCertificates);
#else
var senderCert = new Pkcs12Store(new MemoryStream(senderCertificate.Export(X509ContentType.Pkcs12)), new char[0]);
var receiverCert = new Org.BouncyCastle.X509.X509CertificateParser().ReadCertificate(receiverCertificate.RawData);
var oldSenderCerts = oldSenderCertificates?.Select(cert => new Pkcs12Store(new MemoryStream(cert.Export(X509ContentType.Pkcs12)), new char[0]));
_encryptionHandler = new BouncyCastlePkcs7EncryptionHandler(senderCert, receiverCert, oldSenderCerts);
#endif
}
示例7: GetMessages
/// <summary>
/// Возвращает сообщения с указанными идентификаторами, либо если
/// идентификаторы не указаны, возвращает текущие выделенные сообщения.
/// </summary>
public static IEnumerable<IForumMessageInfo> GetMessages(
IServiceProvider serviceProvider,
IEnumerable<int> messageIds)
{
return
messageIds
?.Select(msgId => (IForumMessageInfo)DatabaseManager.GetMessageWithForum(serviceProvider, msgId))
?? serviceProvider
.GetRequiredService<IActiveMessagesService>()
.ActiveMessages;
}
示例8: AddPackage
/// <summary>
/// Adds a package.
/// </summary>
/// <param name="packageId">The package identifier.</param>
/// <param name="packageSources">The package sources.</param>
/// <param name="versionRange">The version range.</param>
/// <param name="getLatest">If set to <c>true</c>, the latest version of the package will always be downloaded.</param>
/// <param name="allowPrereleaseVersions">If set to <c>true</c>, allow prerelease versions.</param>
/// <param name="allowUnlisted">If set to <c>true</c>, allow unlisted versions.</param>
/// <param name="exclusive">If set to <c>true</c>, only use the package sources defined for this package.</param>
public void AddPackage(string packageId, IEnumerable<string> packageSources = null, string versionRange = null,
bool getLatest = false, bool allowPrereleaseVersions = false, bool allowUnlisted = false, bool exclusive = false)
{
if (_packages.ContainsKey(packageId))
{
throw new ArgumentException($"A package with the ID {packageId} has already been added");
}
_packages.Add(packageId, new Package(_currentFramework, packageId,
packageSources?.Select(_sourceRepositories.CreateRepository).ToList(),
versionRange, getLatest, allowPrereleaseVersions, allowUnlisted, exclusive));
}
示例9: BuildContext
private IEnumerable<IContextItem> BuildContext(IEnumerable<KeyValuePair<string, string>> parameters, IConfiguration config)
{
// build any context from the query string and http request
var parameterContext = parameters?.Select(p => p.ToContextItem()).ToArray() ?? new IContextItem[] { };
// build any context from the config files
var configContext = config?.ContextItems?.ToArray() ?? new IContextItem[] { };
// build any context from the plugins - they get to see any context generated so far
var pluginContext = this.pluginContextProvider.Contribute(parameterContext.Union(configContext)) ?? new IContextItem[] { };
// squish it all together. add parameters last so they can overide stuff generated by the plugins
return configContext.Union(pluginContext).Union(parameterContext).ToArray();
}
示例10: MapPeopleList
public IEnumerable<PersonViewModel> MapPeopleList(IEnumerable<PersonDto> peopleDtoList)
{
return peopleDtoList?.Select(MapPerson).ToList();
}
示例11: PostCreate
private void PostCreate(HostService hostService, IEnumerable<FileAndType> files)
{
using (new LoggerPhaseScope("ReportModelLoadInfo", true))
{
if (!hostService.ShouldTraceIncrementalInfo)
{
return;
}
var allFiles = files?.Select(f => f.File) ?? new string[0];
var loadedFiles = hostService.Models.Select(m => m.FileAndType.File);
IncrementalContext.ReportModelLoadInfo(hostService, allFiles.Except(loadedFiles), null);
IncrementalContext.ReportModelLoadInfo(hostService, loadedFiles, BuildPhase.PreBuildBuild);
}
}
示例12: ToSelectListItems
public static List<SelectListItem> ToSelectListItems(this IEnumerable<PluginFeatureManifest> PluginFeatureDefinitions, IEnumerable<PluginFeatureManifest> SelectedItems)
{
return PluginFeatureDefinitions.ToSelectListItems(SelectedItems?.Select(i => i.Id), false, null);
}
示例13: SetTreeEntrySuitingSelectedPath
static public IEnumerable<MemoryStruct.ITreeViewEntry> SetTreeEntrySuitingSelectedPath(
this IEnumerable<MemoryStruct.ITreeViewEntry> SetTreeEntryRoot,
IEnumerable<string> SelectedPathListNodeLabel)
{
if (null == SetTreeEntryRoot || null == SelectedPathListNodeLabel)
{
return null;
}
var PathListNodeLabelLessFormatting =
SelectedPathListNodeLabel?.Select(Label => Label?.RemoveXmlTag()?.Trim())?.ToArray();
var PathListNodeLabelNext =
PathListNodeLabelLessFormatting?.FirstOrDefault();
if (null == PathListNodeLabelNext)
{
return null;
}
var SetTreeEntryRootSuitingPathNodeNext =
SetTreeEntryRoot
?.Where(TreeEntry => (TreeEntry?.Text?.RemoveXmlTag()?.Trim()).EqualsIgnoreCase(PathListNodeLabelNext))
?.ToArray();
if (null == SetTreeEntryRootSuitingPathNodeNext)
{
return null;
}
if (PathListNodeLabelLessFormatting.Length < 2)
{
return SetTreeEntryRootSuitingPathNodeNext;
}
return
SetTreeEntryRootSuitingPathNodeNext
.Select((LinxTreeEntryPasend) =>
SetTreeEntrySuitingSelectedPath(
LinxTreeEntryPasend.Child,
SelectedPathListNodeLabel.Skip(1)))
?.Where((Kandidaat) => null != Kandidaat)
?.ConcatNullable();
}
示例14: MapBorrowTransactionList
public IEnumerable<BorrowViewModel> MapBorrowTransactionList(IEnumerable<BorrowDto> borrowDtoList)
{
return borrowDtoList?.Select(MapBorrowViewModel).ToList();
}
示例15: EditMember
public Task EditMember(string serverId, string userId, bool? mute = null, bool? deaf = null, IEnumerable<object> roles = null)
{
CheckReady();
if (serverId == null) throw new NullReferenceException(nameof(serverId));
if (userId == null) throw new NullReferenceException(nameof(userId));
IEnumerable<string> newRoles = roles?.Select(x =>
{
if (x is string)
return x as string;
else if (x is Role)
return (x as Role).Id;
else
throw new ArgumentException("Roles must be a collection of string or Role.", nameof(roles));
});
return _api.EditMember(serverId, userId, mute: mute, deaf: deaf, roles: newRoles);
}