本文整理汇总了C#中IEnumerable.?.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# IEnumerable.?.ToList方法的具体用法?C# IEnumerable.?.ToList怎么用?C# IEnumerable.?.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IEnumerable
的用法示例。
在下文中一共展示了IEnumerable.?.ToList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public IBuildToken Create(string text, string mainAssembly, IEnumerable<string> references, Action<Control> controlCreated, Action<Exception> error)
{
RemoveOutput();
var token = new BuildToken();
var refs = references?.ToList() ?? new List<string>();
// ensure we use the built-in version of Eto, not the one used by the project
if (!string.IsNullOrEmpty(mainAssembly))
refs.Insert(0, mainAssembly);
refs.RemoveAll(r => Path.GetFileName(r).ToLowerInvariant() == "eto.dll");
refs.Add(typeof(Control).Assembly.Location);
ThreadPool.QueueUserWorkItem(state =>
{
try
{
Assembly generatedAssembly;
//output = Path.Combine(Path.GetTempPath(), "EtoDesigner", Path.GetRandomFileName() + ".dll");
var result = Compile(null, refs, text, out generatedAssembly);
if (result.Success)
{
Application.Instance.Invoke(() =>
{
try
{
var type = FindControlType(generatedAssembly);
var control = InstantiateControl(type);
if (token.IsCancelled)
return;
if (control != null)
controlCreated(control);
else
error(new FormatException("Could not find control. Make sure you have a single class derived from Control."));
}
catch (Exception ex)
{
if (!token.IsCancelled)
error(ex);
}
});
}
else
{
var errorText = string.Join("\n", result.Errors);
if (!token.IsCancelled)
Application.Instance.Invoke(() => error(new FormatException(string.Format("Compile error: {0}", errorText))));
}
}
catch (Exception ex)
{
if (!token.IsCancelled)
Application.Instance.Invoke(() => error(ex));
}
});
return token;
}
示例2: MusicBar
public MusicBar(MusicScore parentScore, int count = 4, double span = 1.0, IEnumerable<MusicLane> lanes = null)
{
ParentScore = parentScore;
Count = count;
Span = span;
Lanes = lanes?.ToList() ?? new List<MusicLane>();
}
示例3: DocumentBuilder
public DocumentBuilder(
IEnumerable<Assembly> assemblies,
ImmutableArray<string> postProcessorNames,
string templateHash,
string intermediateFolder = null,
string commitFromSHA = null,
string commitToSHA = null)
{
Logger.LogVerbose("Loading plug-in...");
using (new LoggerPhaseScope("ImportPlugins", true))
{
var assemblyList = assemblies?.ToList();
_container = GetContainer(assemblyList);
_container.SatisfyImports(this);
_currentBuildInfo.CommitFromSHA = commitFromSHA;
_currentBuildInfo.CommitToSHA = commitToSHA;
if (intermediateFolder != null)
{
_currentBuildInfo.PluginHash = ComputePluginHash(assemblyList);
_currentBuildInfo.TemplateHash = templateHash;
_currentBuildInfo.DirectoryName = IncrementalUtility.CreateRandomDirectory(intermediateFolder);
}
}
Logger.LogInfo($"{Processors.Count()} plug-in(s) loaded.");
foreach (var processor in Processors)
{
Logger.LogVerbose($"\t{processor.Name} with build steps ({string.Join(", ", from bs in processor.BuildSteps orderby bs.BuildOrder select bs.Name)})");
}
_postProcessors = GetPostProcessor(postProcessorNames);
_intermediateFolder = intermediateFolder;
_lastBuildInfo = LoadLastBuildInfo();
}
示例4: HttpApiResponse
public HttpApiResponse(HttpStatusCode statusCode = HttpStatusCode.OK, HttpBody body = null, IEnumerable<HttpHeader> headers = null)
{
var headersList = headers?.ToList() ?? new List<HttpHeader>();
StatusCode = statusCode;
Headers = headersList;
Body = body;
}
示例5: MusicScore
public MusicScore(string songTitle, int bpm, Uri songUrl, int laneCount, double offset = 0, IEnumerable<string> tags = null, IEnumerable<MusicBar> bars = null)
{
SongTitle = songTitle;
BPM = bpm;
SongUrl = songUrl;
LaneCount = laneCount;
Offset = offset;
Tags = tags?.ToList() ?? new List<string>();
Bars = bars?.ToList() ?? new List<MusicBar>();
}
示例6: AddSuperhero
public void AddSuperhero(String name, IEnumerable<Skill> skills, IEnumerable<Team> teams)
{
var superhero = new Superhero
{
Name = name,
Skills = skills?.ToList(),
Teams = teams?.ToList()
};
this.superheroes.Add(superhero);
}
示例7: Manifest
public Manifest(ManifestMetadata metadata, IEnumerable<ManifestFile> files)
{
if (metadata == null)
{
throw new ArgumentNullException(nameof(metadata));
}
Metadata = metadata;
Files = files?.ToList() ?? new List<ManifestFile>();
}
示例8: Instellingen
public Instellingen(string databasepad, string bijbelpad, string templatetheme, string templateliederen, string templatebijbeltekst, int regelsperslide = 6, int regelsperbijbeltekstslide = 9, StandaardTeksten standaardTeksten = null, IEnumerable<IMapmask> masks = null)
: this()
{
DatabasePad = databasepad;
BijbelPad = bijbelpad;
TemplateTheme = templatetheme;
TemplateLied = templateliederen;
TemplateBijbeltekst = templatebijbeltekst;
RegelsPerLiedSlide = regelsperslide;
RegelsPerBijbeltekstSlide = regelsperbijbeltekstslide;
if (standaardTeksten != null)
StandaardTeksten = standaardTeksten;
masks?.ToList().ForEach(m => AddMask(m));
}
示例9: AddSuperhero
public Int32 AddSuperhero(String name, IEnumerable<Skill> skills, IEnumerable<Team> teams, Boolean isOnMission)
{
var superhero = new Superhero
{
Id = idCounter,
Name = name,
Skills = skills?.ToList(),
Teams = teams?.ToList(),
IsOnMission = isOnMission
};
this.superheroes.Add(superhero);
idCounter++;
return idCounter;
}
示例10: SqlServerEventStore
public SqlServerEventStore(string connectionString, ISingleContextUseGuard usageGuard, IEventNameMapper nameMapper = null, IEnumerable<IEventMigration> migrations = null)
{
Log.Debug("Constructor called");
_migrationFactories = migrations?.ToList() ?? new List<IEventMigration>();
nameMapper = nameMapper ?? new DefaultEventNameMapper();
ConnectionString = connectionString;
_usageGuard = usageGuard;
var eventSerializer = new SqlServerEvestStoreEventSerializer();
_cache = SqlServerEventStoreEventsCache.ForConnectionString(connectionString);
_connectionMananger = new SqlServerEventStoreConnectionManager(connectionString);
_schemaManager = new SqlServerEventStoreSchemaManager(connectionString, nameMapper);
_eventReader = new SqlServerEventStoreEventReader(_connectionMananger, _schemaManager);
_eventWriter = new SqlServerEventStoreEventWriter(_connectionMananger, eventSerializer, _schemaManager);
}
示例11: ToSelectListItems
public static List<SelectListItem> ToSelectListItems(this IEnumerable<PluginFeatureManifest> PluginDefinitions, IEnumerable<string> SelectedIds = null, bool IncludeInstructionFirst = false, string InstructionMessage = "Select a Plugin", Dictionary<string, string> AdditionalItems = null)
{
var selectedIds = SelectedIds?.ToList();
var items = PluginDefinitions
.Select(wpd => new SelectListItem { Value = wpd.Id, Text = wpd.Name, Selected = (selectedIds?.Contains(wpd.Id, StringComparer.Ordinal) ?? false) });
if (AdditionalItems != null)
items = items.Concat(AdditionalItems.Select(i => new SelectListItem { Value = i.Key, Text = i.Value, Selected = (selectedIds?.Contains(i.Key, StringComparer.Ordinal) ?? false) }));
var selectItems = items.OrderBy(i => i.Text).ToList();
if (IncludeInstructionFirst)
selectItems.Insert(0, new SelectListItem() { Value = String.Empty, Text = String.Format("<{0}>", InstructionMessage), Selected = (selectedIds?.Count ?? 0) != 0 });
return selectItems;
}
示例12: GetEnsuredBlogKeysInternal
private IEnumerable<BlogKey> GetEnsuredBlogKeysInternal(IEnumerable<BlogKey> blogKeys)
{
var blogKeyList = blogKeys?.ToList();
if (blogKeyList != null && blogKeyList.Any())
{
return blogKeyList;
}
var blogSettingsBlogKeys = this.BlogKeys;
if (!blogSettingsBlogKeys.Any())
{
string message = $"No default items found in {nameof(this.BlogKeys)}.";
throw new KeyNotFoundException(message);
}
return blogSettingsBlogKeys;
}
示例13: GetScenesAsync
public async Task<IEnumerable<Scene>> GetScenesAsync(IEnumerable<int> ids = null)
{
List<int> idList = ids?.ToList();
IQueryable<Scene> query = idList == null ?
Context.Scenes :
Context.Scenes.Where(s => idList.Contains(s.Id));
IEnumerable<Scene> scenes = await query
.Include(q => q.ApplianceSettings)
.Include(q => q.ApplianceSettings.Select(s => s.Appliance))
.Include(q => q.ApplianceSettings.Select(s => s.Appliance.Model))
.Include(q => q.ApplianceSettings.Select(s => s.Appliance).Select(a => a.Zone))
.Include(q => q.Sequence)
.Include(q => q.Schedule)
.ToListAsync();
return scenes;
}
示例14: SetEnabledDebugFacilities
public async void SetEnabledDebugFacilities(IEnumerable<string> enabledDebugFacilities)
{
var enabledDebugFacilitiesList = enabledDebugFacilities?.ToList() ?? new List<string>();
if (new HashSet<string>(this.enabledDebugFacilities).SetEquals(enabledDebugFacilitiesList))
return;
this.enabledDebugFacilities = enabledDebugFacilitiesList;
this.UpdateDebugFacilities();
if (!this.SupportsRestartlessUpdate)
return;
var enabled = this.DebugFacilities.Where(x => x.IsEnabled).Select(x => x.Name).ToList();
var disabled = this.DebugFacilities.Where(x => !x.IsEnabled).Select(x => x.Name).ToList();
var apiClient = this.apiClient.Value;
if (apiClient != null)
await apiClient.SetDebugFacilitiesAsync(enabled, disabled);
}
示例15: Run
public async Task<string> Run(
string title = null,
string initialDirectory = null,
IEnumerable<CommonFileDialogFilter> filters = null,
bool folderPicker = false)
{
if (!CommonOpenFileDialog.IsPlatformSupported)
{
return null;
}
string filePath = null;
using (var dialog = new CommonOpenFileDialog())
{
dialog.IsFolderPicker = folderPicker;
dialog.Title = title;
dialog.InitialDirectory = MakeInitialDirectoryPath(initialDirectory);
filters?.ToList().ForEach(f => dialog.Filters.Add(f));
dialog.EnsureValidNames = true;
dialog.EnsurePathExists = false;
dialog.EnsureFileExists = false;
dialog.Multiselect = false;
var handle =
(HwndSource.FromVisual(this.Window) as HwndSource)?.Handle;
var result =
await this.Window.Dispatcher.InvokeAsync(
() =>
handle.HasValue ?
dialog.ShowDialog(handle.Value) : dialog.ShowDialog());
if (result != CommonFileDialogResult.Ok)
{
return null;
}
filePath = Path.GetFullPath(dialog.FileName);
}
return filePath;
}