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


C# IEnumerable.?.ToList方法代码示例

本文整理汇总了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;
		}
开发者ID:picoe,项目名称:Eto,代码行数:60,代码来源:BaseCompiledInterfaceBuilder.cs

示例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>();
 }
开发者ID:marihachi,项目名称:CrystalResonanceForDesktop,代码行数:7,代码来源:MusicBar.cs

示例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();
 }
开发者ID:dotnet,项目名称:docfx,代码行数:32,代码来源:DocumentBuilder.cs

示例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;
        }
开发者ID:kswoll,项目名称:sexy-http,代码行数:8,代码来源:HttpApiResponse.cs

示例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>();
		}
开发者ID:marihachi,项目名称:CrystalResonanceForDesktop,代码行数:10,代码来源:MusicScore.cs

示例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);
        }
开发者ID:szabototo89,项目名称:aspdotnet-web-development,代码行数:11,代码来源:AdhocApplicationRepository.cs

示例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>();
        }
开发者ID:leloulight,项目名称:dnx,代码行数:11,代码来源:Manifest.cs

示例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));
 }
开发者ID:ErikDeRoos,项目名称:koningskerk-beamteam,代码行数:14,代码来源:Instellingen.cs

示例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;
        }
开发者ID:szabototo89,项目名称:aspdotnet-web-development,代码行数:15,代码来源:AdhocApplicationRepository.cs

示例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);
        }
开发者ID:mlidbom,项目名称:Composable.Monolithic,代码行数:16,代码来源:SqlServerEventStore.cs

示例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;
        }
开发者ID:garysharp,项目名称:Disco,代码行数:17,代码来源:PluginExtensions.cs

示例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;
        }
开发者ID:sebnilsson,项目名称:Blaven,代码行数:19,代码来源:BlogSettingsHelper.cs

示例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;
        }
开发者ID:TheGapFillers,项目名称:Auluxa,代码行数:19,代码来源:EfApplicationRepository.cs

示例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);
        }
开发者ID:johnhk,项目名称:SyncTrayzor,代码行数:20,代码来源:SyncthingDebugFacilitiesManager.cs

示例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;
        }
开发者ID:ruche7,项目名称:VoiceroidUtil,代码行数:41,代码来源:OpenFileDialogService.cs


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