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


C# IList.ToDictionary方法代码示例

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


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

示例1: UpdateMarkers

        public void UpdateMarkers(IList<MediaMarker> markers, bool forceRefresh)
        {
            var markersHash = markers.ToDictionary(i => i.Id, i => i);

            List<MediaMarker> newMarkers;
            List<MediaMarker> removedMarkers;

            if (forceRefresh)
            {
                newMarkers = markers.ToList();
                removedMarkers = _previousMarkers.Values.ToList();
            }
            else
            {
                newMarkers = markers.Where(i => !_previousMarkers.ContainsKey(i.Id)).ToList();
                removedMarkers = _previousMarkers.Values.Where(i => !markersHash.ContainsKey(i.Id)).ToList();
            }

            if (removedMarkers.Any() && MarkersRemoved != null)
            {
                MarkersRemoved(removedMarkers);
            }

            if (newMarkers.Any() && NewMarkers != null)
            {
                NewMarkers(newMarkers);
            }

            _previousMarkers = markersHash;
        }
开发者ID:bondarenkod,项目名称:pf-arm-deploy-error,代码行数:30,代码来源:CaptionMarkerFactory.cs

示例2: ShowDatabases

 public void ShowDatabases(IList<string> databases)
 {
     var dict = databases.ToDictionary(i => i, i => i);
     _databaseComboBox.ValueMember = "Key";
     _databaseComboBox.DisplayMember = "Value";
     _databaseComboBox.DataSource = new BindingSource(dict, null);
 }
开发者ID:aelhadi,项目名称:opencbs,代码行数:7,代码来源:LoginView.cs

示例3: TrendMarkerLabelProvider

        public TrendMarkerLabelProvider(int polarityId)
        {
            switch (polarityId)
            {
                case PolarityIds.RagLowIsGood:
                    Labels = new List<TrendMarkerLabel> {
                        CannotBeCalculated,
                        new TrendMarkerLabel{Id = TrendMarker.Increasing, Text = "Increasing and getting worse"},
                        new TrendMarkerLabel{Id = TrendMarker.Decreasing, Text = "Decreasing and getting better"},
                        NoChange
                    };
                    break;

                case PolarityIds.RagHighIsGood:
                    Labels = new List<TrendMarkerLabel> {
                        CannotBeCalculated,
                        new TrendMarkerLabel{Id = TrendMarker.Increasing, Text = "Increasing and getting better"},
                        new TrendMarkerLabel{Id = TrendMarker.Decreasing, Text = "Decreasing and getting worse"},
                        NoChange
                    };
                    break;

                default:
                    Labels = new List<TrendMarkerLabel> {
                        CannotBeCalculated,
                        new TrendMarkerLabel{Id = TrendMarker.Increasing, Text = "Increasing"},
                        new TrendMarkerLabel{Id = TrendMarker.Decreasing, Text = "Decreasing"},
                        NoChange
                    };
                    break;
            }

            _trendMarkerToLabel = Labels.ToDictionary(x => x.Id, x => x);
        }
开发者ID:PublicHealthEngland,项目名称:fingertips-open,代码行数:34,代码来源:TrendMarkerLabelProvider.cs

示例4: ShowWriteOffOptions

 public void ShowWriteOffOptions(IList<WriteOffOption> options)
 {
     var dict = options.ToDictionary(x => x.Id, x => x.Name);
     _optionComboBox.DisplayMember = "Value";
     _optionComboBox.ValueMember = "Key";
     _optionComboBox.DataSource = new BindingSource(dict, null);
     _optionComboBox.SelectedIndex = 0;
 }
开发者ID:aelhadi,项目名称:opencbs,代码行数:8,代码来源:WriteOffOkCancelForm.cs

示例5: OperatorManager

 public OperatorManager(IList<IOperator> operators)
 {
     Operators = new ReadOnlyDictionary<char, IOperator>(operators.ToDictionary(o => o.OperatorCharacter, o => o));
     Priorities = operators.Select(o => o.Priority)
                           .Distinct()
                           .OrderBy(g => g)
                           .ToList()
                           .AsReadOnly();
 }
开发者ID:AndreyTretyak,项目名称:SpreadsheetSimulator,代码行数:9,代码来源:OperatorManager.cs

示例6: GetEntityHierarchy

 public EntityHierarchy GetEntityHierarchy(
     Entity entity,
     IList<PropertyDeleteOption> deleteOptions = null)
 {
     var deleteOptionsDict = deleteOptions == null ?
         null :
         deleteOptions.ToDictionary(x => x.HierarchyName);
     return GetEntityHierarchy(null, entity, deleteOptionsDict);
 }
开发者ID:tassyo1,项目名称:Ilaro.Admin,代码行数:9,代码来源:RecordsHierarchySource.cs

示例7: ParseInput

    static void ParseInput()
    {
        n = int.Parse(Console.ReadLine());

        stationsInfo = Regex.Matches(
                ("0 --> " + Console.ReadLine()).Replace(" --> ", "►"),
                "([^►]+)►([^►]+)"
            ).Cast<Match>()
            .Select(match =>
                new KeyValuePair<string, int>(
                    match.Groups[2].Value,
                    int.Parse(match.Groups[1].Value)
                )
            ).ToArray();

        int id = 0;
        stationsByName = stationsInfo.ToDictionary(
            info => info.Key,
            info => id++
        );

        stationsByIndex = stationsByName.ToDictionary(
            kvp => kvp.Value,
            kvp => kvp.Key
        );

        var separator = new string[] { " | " };

        camerasInfo = Enumerable.Range(0, int.Parse(Console.ReadLine()))
            .Select(_ => Console.ReadLine())
            .Select(line => line.Split(separator, StringSplitOptions.None))
            .Select(match =>
                new Tuple<DateTime, int, int, int, char>(
                    DateTime.ParseExact(match[0], DateFormat, CultureInfo.InvariantCulture),
                    stationsByName[match[1]],
                    int.Parse(match[2]),
                    int.Parse(match[3]),
                    match[4][0]
                )
            ).ToArray();

        trainCapacity = int.Parse(Console.ReadLine());

#if DEBUG
        //Console.WriteLine("# INPUT");

        //Console.WriteLine(string.Join(Environment.NewLine, stationsInfo));
        //Console.WriteLine();

        //Console.WriteLine(string.Join(Environment.NewLine, camerasInfo));
        //Console.WriteLine();

        //Console.WriteLine(trainCapacity);
        //Console.WriteLine();
#endif
    }
开发者ID:dgrigorov,项目名称:TelerikAcademy-1,代码行数:56,代码来源:Program.cs

示例8: TreeClientApp

 public TreeClientApp(IList<String> sampleFiles)
 {
     timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.3) };
     timer.Tick += TimerStepForward;
     Program = String.Empty;
     ExecuteProgramCommand = new RelayCommand(ExecuteProgram);
     StepForwardCommand = new RelayCommand(StepForward, p => currentProgram != null);
     PlayCommand = new RelayCommand(Play, p => currentProgram != null);
     Samples = sampleFiles.ToDictionary(s => Path.GetFileName(s), s => new RelayCommand(o => LoadSample(s)));
 }
开发者ID:ShyAlex,项目名称:scheme-ish,代码行数:10,代码来源:TreeClientApp.cs

示例9: GetEntityHierarchy

 public EntityHierarchy GetEntityHierarchy(
     Entity entity,
     IList<PropertyDeleteOption> deleteOptions = null)
 {
     var deleteOptionsDict = deleteOptions == null ?
         null :
         deleteOptions.ToDictionary(x => x.HierarchyName);
     var index = 0;
     return GetEntityHierarchy(null, entity, deleteOptionsDict, string.Empty, ref index);
 }
开发者ID:rgonek,项目名称:Ilaro.Admin,代码行数:10,代码来源:RecordsHierarchySource.cs

示例10: Behaviors

        public ActionResult Behaviors(IList<BehaviorConfig> configs)
        {
            foreach (var config in configs)
            {
                BehaviorConfig.Update(CurrentInstance.Name, config);
            }

            var weights = configs.ToDictionary(c => c.BehaviorType, c => c.Weight);
            RecommendationEngineConfiguration.ChangeBehaviorWeights(CurrentInstance.Name, weights);

            return AjaxForm().ReloadPage();
        }
开发者ID:Kooboo,项目名称:Ecommerce,代码行数:12,代码来源:ConfigController.cs

示例11: BadShooterViewModel

 public BadShooterViewModel(string name, double radius, IList<PlayerViewModel> players, ISoundEffect audioPlayer, IGunAimPhysics gunAimPhysics)
 {
     Name = name;
     Radius = radius;
     this.players = players;
     this.audioPlayer = audioPlayer;
     this.gunAimPhysics = gunAimPhysics;
     scores = players.ToDictionary(p => p.Key, p => 0);
     animationTimer = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(10) };
     animationTimer.Tick += DispatcherTimerOnTick;
     gameTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
     gameTimer.Tick += CountDown;
 }
开发者ID:anyhotcountry,项目名称:YouthClubApp,代码行数:13,代码来源:BadShooterViewModel.cs

示例12: CategoryAreaDataWriter

        public CategoryAreaDataWriter(IAreasReader areasReader, IGroupDataReader groupDataReader, WorksheetInfo worksheet,
            ProfileDataWriter profileDataWriter, CategoryAreaType categoryAreaType)
            : base(areasReader, groupDataReader, worksheet, profileDataWriter)
        {
            _categoryAreaTypeId = categoryAreaType.CategoryTypeId;

            categories = areasReader.GetCategories(_categoryAreaTypeId);

                subnationalCategoryIdToCategoryAreaMap = categories
                    .ToDictionary<Category, int, IArea>(
                    category => category.Id,
                    category => CategoryArea.New(category)
                    );
        }
开发者ID:PublicHealthEngland,项目名称:fingertips-open,代码行数:14,代码来源:CategoryAreaDataWriter.cs

示例13: SelectStartingTeamForGameweek

        public TeamSelection SelectStartingTeamForGameweek(IList<PredictedPlayerScore> predictedPlayerScores)
        {
            if(predictedPlayerScores.Count != 15)throw new Exception("Incorrect number of players to select starting team from");

            var selection = new TeamSelection
                                {
                                    Team = SelectTeam(predictedPlayerScores)
                                };
            selection.PredictedTotalTeamScore = CalculatePredictedTeamScore(
                predictedPlayerScores.ToDictionary(ps => ps.Player.Id, ps => ps.PredictedScore),
                selection.Team);

            return selection;
        }
开发者ID:robinweston,项目名称:fantasyfootballrobot,代码行数:14,代码来源:TeamGameweekSelector.cs

示例14: TaskList

 public TaskList(IEnumerable<TaskTable> tasks, IEnumerable<CategoryTable> categories, int currentPosition = 0)
 {
     _tasks = tasks.ToList();
     _taskDictionary = _tasks.ToDictionary(task => task.Id);
     _category = categories.ToDictionary(cat => cat.Id);
     _enumerator = new TaskEnumerator(this) { CurrentPosition = currentPosition };
 }
开发者ID:okrotowa,项目名称:Mosigra.Yorsh,代码行数:7,代码来源:TaskList.cs

示例15: Parse

        /// <summary>
        /// Parse stream output declarations.
        /// Format is "[slot :] semantic[index][.mask] ; ...".
        /// </summary>
        /// <param name="entries">The parsed entries.</param>
        /// <param name="strides">The output strides.</param>
        /// <param name="streams">The output declarations to parse.</param>
        public static void Parse(IList<ShaderStreamOutputDeclarationEntry> entries, out int[] strides, string[] streams, IList<Variable> fields)
        {
            strides = new int[4];

            var fieldsBySemantic = fields.ToDictionary(x => Semantic.Parse(x.Qualifiers.OfType<Semantic>().Single().Name));

            for (int streamIndex = 0; streamIndex < streams.Length; ++streamIndex)
            {
                // Parse multiple declarations separated by semicolon
                var stream = streams[streamIndex];
                foreach (var streamOutput in stream.Split(';'))
                {
                    // Parse a single declaration: "[slot :] semantic[index][.mask]"
                    var match = streamOutputRegex.Match(streamOutput);
                    if (!match.Success)
                        throw new InvalidOperationException("Could not parse stream output.");

                    var streamOutputDecl = new ShaderStreamOutputDeclarationEntry();

                    // Split semantic into (name, index)
                    var semantic = Semantic.Parse(match.Groups[3].Value);

                    streamOutputDecl.SemanticName = semantic.Key;
                    streamOutputDecl.SemanticIndex = semantic.Value;
                    //if (streamOutputDecl.SemanticName == "$SKIP")
                    //    streamOutputDecl.SemanticName = null;

                    var matchingField = fieldsBySemantic[semantic];
                    var matchingFieldType = matchingField.Type.TypeInference.TargetType ?? matchingField.Type;

                    if (matchingFieldType is VectorType)
                        streamOutputDecl.ComponentCount = (byte)((VectorType)matchingFieldType).Dimension;
                    else if (matchingFieldType is ScalarType)
                        streamOutputDecl.ComponentCount = 1;
                    else
                        throw new InvalidOperationException(string.Format("Could not recognize type of stream output for {0}.", matchingField));
                        
                    var mask = match.Groups[5].Value;
                    ParseMask(mask, ref streamOutputDecl.StartComponent, ref streamOutputDecl.ComponentCount);

                    byte.TryParse(match.Groups[2].Value, out streamOutputDecl.OutputSlot);

                    streamOutputDecl.Stream = streamIndex;

                    strides[streamOutputDecl.OutputSlot] += streamOutputDecl.ComponentCount * sizeof(float);
                    entries.Add(streamOutputDecl);
                }
            }
        }
开发者ID:Powerino73,项目名称:paradox,代码行数:56,代码来源:StreamOutputParser.cs


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